// =========================================================================== // 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. // =========================================================================== proc updateFolliclesWithDefaultMap(string $polyObj) { string $folliclesList[] = `listConnections -sh 1 -t follicle ($polyObj + ".outMesh")`; int $mapSetId = 0; string $defMap = "map1"; for($i = 0; $i < size($folliclesList); $i ++) { setAttr ($folliclesList[$i] + ".mapSetName") -type "string" $defMap; } } proc string getUVSetNameFromValue(string $polyObj, string $uvSetName) { string $uvAttrList[] = `listAttr -m -st uvSetName $polyObj`; string $emptyString; for($i = 0; $i < size($uvAttrList); $i++) { string $polyUVAttr = $polyObj + "." + $uvAttrList[$i]; string $attrValid = `getAttr $polyUVAttr`; if($attrValid == $uvSetName) return $polyUVAttr; } return $emptyString; } proc int checkExistenceOfUV(string $polyObj, string $folliclesList[]) { string $mapSetName; if(size($folliclesList)) $mapSetName = `getAttr ($folliclesList[0] + ".mapSetName")`; string $attrValue = getUVSetNameFromValue($polyObj, $mapSetName); if(size($attrValue)) return 1; return 0; } global proc string hairGetUVSetOfHairSystem(string $hairSys, string $shapeObj) { string $outMeshAttr = $shapeObj + ".outMesh"; string $connFollicles[] = `listConnections -sh 1 -t follicle $outMeshAttr`; if(checkExistenceOfUV($shapeObj, $connFollicles) == 0) { updateFolliclesWithDefaultMap($shapeObj); return ($shapeObj + ".uvSet[0].uvSetName"); } string $usedMapSetName; if(size($connFollicles)) $usedMapSetName = `getAttr ($connFollicles[0] + ".mapSetName")`; string $attrValue = getUVSetNameFromValue($shapeObj, $usedMapSetName); return $attrValue; }