// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // paintHairTexture // // Description: paint the selected hairSystem node attribute. // The second parameter is used to display the attribute name being painted // in 3dPaint tool. global proc paintHairTexture( string $attr, string $attrName ) { // global variable which will contain the attribute name // used by 3D paint scripts. global string $g3dPaintAttrName ; string $sel[] = `ls -sl`; convertHairSelection( "hairSystems" ); string $hsys[] = getSelectedHairSystems(); if( size($hsys) < 1 ){ global string $gPaintAttrOnObjCleanupCmd; if( $gPaintAttrOnObjCleanupCmd != "" ){ // If we're already painting on a hair object, it's likely that the // mesh selected is a temporary mesh. We'll retrieve the name of the // actual mesh from the cleanup callback, and extract the implicit // hair system on which we want to paint. // string $args[]; tokenize $gPaintAttrOnObjCleanupCmd " " $args; if( size($args) > 4 ){ string $hairSys = findTypeInHistory( $args[4], "hairSystem", 1,1 ); if( $hairSys != "" ){ $hsys[0] = $hairSys; } } } } if( size($hsys) < 1 ){ warning((uiRes("m_paintHairTexture.kNoHairSelected"))); return; } string $follicles[] = hairCurvesFromSystem( $hsys[0] ); if( size($follicles) < 1 ){ warning((uiRes("m_paintHairTexture.kNoFollicles"))); select -r $sel; return; } string $follicle = $follicles[0]; string $cons[] = `listConnections -d 1 ($follicle + ".inputSurface")`; if( size( $cons ) < 1 ){ $cons = `listConnections -d 1 ($follicle + ".inputMesh")`; if( size( $cons ) < 1 ){ string $fmt = (uiRes("m_paintHairTexture.kNoInputObject")); warning( `format -s $follicle $fmt`); select -r $sel; return; } } select -r $sel; // set the global variable which is used by 3d Paint tool to display // the attribute name $g3dPaintAttrName = $attrName ; paintAttributeOnObject ($hsys[0] + "." + $attr) $cons[0] 0.6; }