// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 2005 // // Description: paint the selected toon node attribute. // // The second parameter is used to display the attribute name being painted // in 3dPaint tool. // global proc paintToonAttribute( string $attr, string $attrName ) { // global variable which will contain the attribute name // used by 3D paint scripts. global string $g3dPaintAttrName ; string $toons[] = `ls -sl -dag -type "pfxToon"`; string $paintObj = ""; string $toon = ""; if( size($toons) < 1 ){ string $objs[] = `ls -sl -dag -type "mesh"`; if( size( $objs ) > 0 ){ $paintObj = $objs[0]; string $cons[] = `listConnections -d 1 -type pfxToon ($paintObj + ".outMesh")`; if( size( $cons ) > 0 ){ $toon = $cons[0]; } } if( $toon == "" ){ $objs = `ls -sl -dag -type "nurbsSurface"`; if( size( $objs ) > 0 ){ $paintObj = $objs[0]; string $cons[] = `listConnections -d 1 -type nurbsTessellate ($paintObj + ".local")`; if( size( $cons ) > 0 ){ string $tess = $cons[0]; $cons = `listConnections -d 1 -type pfxToon ($tess + ".outputPolygon")`; if( size( $cons ) > 0 ){ $toon = $cons[0]; } } } } if( $toon == "" ){ $objs = `ls -sl -dag -type "subdiv"`; if( size( $objs ) > 0 ){ $paintObj = $objs[0]; string $cons[] = `listConnections -d 1 -type subdivToPoly ($paintObj + ".outSubdiv")`; if( size( $cons ) > 0 ){ string $tess = $cons[0]; $cons = `listConnections -d 1 -type pfxToon ($tess + ".outMesh")`; if( size( $cons ) > 0 ){ $toon = $cons[0]; } } } } if( $toon == "" ){ global string $gPaintAttrOnObjCleanupCmd; if( $gPaintAttrOnObjCleanupCmd != "" ){ // If we're already painting on a toon 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 toon object on which to paint. // string $args[]; tokenize $gPaintAttrOnObjCleanupCmd " " $args; if( size($args) > 4 ){ $paintObj = $args[4]; if( $paintObj != "" ){ $toon = findTypeInHistory( $args[4], "pfxToon", 1,1 ); } } } } if( $toon == "" ){ warning( (uiRes("m_paintToonAttribute.kNoToonLine"))); return; } } else { $toon = $toons[0]; string $cons[] = `listConnections -s 1 ($toon + ".inputSurface")`; if( size( $cons ) < 1 ){ string $fmt = (uiRes("m_paintToonAttribute.kNoObjects")); warning( `format -s $toon $fmt` ); return; } if( size( $cons ) > 2 ){ string $fmt = (uiRes("m_paintToonAttribute.kSingleMap")); warning( `format -s $cons[0] $fmt` ); } $paintObj = $cons[0]; string $type = nodeType( $paintObj ); if( $type == "transform" ){ string $sh[] = `ls -shapes -dag $paintObj`; if( size($sh) > 0 ){ $type = nodeType( $sh[0] ); } } if( $type != "mesh" ){ if( $type == "nurbsTessellate" ){ $cons = `listConnections -d 1 ($paintObj + ".inputSurface")`; if( size( $cons ) > 0 ){ $paintObj = $cons[0]; } } else if( $type == "subdivToPoly" ){ $cons = `listConnections -d 1 ($paintObj + ".inSubdiv")`; if( size( $cons ) > 0 ){ $paintObj = $cons[0]; } } else if( ($type == "pfxHair") || ($type == "pfxToon") || ($type == "stroke") ){ warning( (uiRes("m_paintToonAttribute.kCantPaint"))); return; } } } if( $toon != "" && $paintObj != "" ){ if( $attr == "lineOffsetMap" ){ // line offset should be non zero float $lineOffset = getAttr( $toon + ".lineOffset" ); if( $lineOffset == 0.0 ){ print( (uiRes("m_paintToonAttribute.kLineOffset"))); setAttr ($toon + ".lineOffset") 2.0; } } // set the global variable which is used by 3d Paint tool to display // the attribute name $g3dPaintAttrName = $attrName ; paintAttributeOnObject ($toon + "." + $attr) $paintObj 0.2; } }