////////////////////////////////////////////////////////////////////// // // created by: Michael Paixao // // usefull for adding things like buttons and what-not, // good in cloth sim objects, follicles follow normal angles! // // how-to: // // polygons // // select a vertex,UV,edge or face, or a couple // run the tool... done! // kinda... // select the object you want to move and follow // then connect any way you like (parent constraint etc.. // // // NURBS // // select either surface point or surface UV // run the tool, same steps as polygons from here // // // things that can cause problems are UV's on top of // eachother // // questions, comments, or tool requests can be sent to: // // info@simpletofind.ca // ////////////////////////////////////////////////////////////////////// { string $sel[]; string $buffer[]; int $token; string $face[]; float $uvPos[]; ConvertSelectionToUVs; $sel = `ls -sl -fl`; // checks the if the group exists, then creates it if no, cleans it up as well // if ( `objExists "follicleGroup"` == 0 ) { select -cl; group -em -n "follicleGroup"; setAttr -lock true -keyable false "follicleGroup.tx"; setAttr -lock true -keyable false "follicleGroup.ty"; setAttr -lock true -keyable false "follicleGroup.tz"; setAttr -lock true -keyable false "follicleGroup.rx"; setAttr -lock true -keyable false "follicleGroup.ry"; setAttr -lock true -keyable false "follicleGroup.rz"; setAttr -lock true -keyable false "follicleGroup.sx"; setAttr -lock true -keyable false "follicleGroup.sy"; setAttr -lock true -keyable false "follicleGroup.sz"; } for ( $uv in $sel ) { // finds the source obj for the UV and its current UV map // $token = `tokenize $uv "." $buffer`; select -r $buffer[0]; pickWalk -d down; $inObj = `ls -sl`; $foll = `createNode follicle`; select -r $foll; pickWalk -d up; $follTop = `ls -sl`; // makes the necessary connections for the follicle to follow the mesh // // nurbs vs poly // if ( `attributeExists "outMesh" $inObj[0]`) { eval("connectAttr -f "+$inObj[0]+".outMesh "+$foll+".inputMesh\;"); select -r $uv; $uvPos = `polyEditUV -q`; } if ( `attributeExists "local" $inObj[0]`) { eval("connectAttr -f "+$inObj[0]+".local "+$foll+".inputSurface\;"); select -r $uv; $uvPos = `nurbsEditUV -q`; $size = `size $uvPos`; if($size == 0) { int $token, $token2; string $buffer[], $buffer2[]; $token = `tokenize $uv "[]" $buffer`; $uMa = `ls -sl -o`; select -r ($uMa[0] + ".u[99999999]"); string $uMax[] = `ls -sl`; $token2 = `tokenize $uMax[0] "[]" $buffer2`; float $uFloat = $buffer2[$token2-1]; $uFloat = $uFloat; $vMa = `ls -sl -o`; select -r ($vMa[0] + ".v[99999999]"); string $vMax[] = `ls -sl`; $token2 = `tokenize $vMax[0] "[]" $buffer2`; float $vFloat = $buffer2[$token2-1]; $vFloat = $vFloat; float $uLoc = $buffer[$token-2]; float $vLoc = $buffer[$token-1]; print ($uLoc / $uFloat);print "\n"; print ($vLoc / $vFloat);print "\n"; $uvPos[0] = $uLoc / $uFloat; $uvPos[1] = $vLoc / $vFloat; } } eval("connectAttr -f "+$inObj[0]+".worldMatrix "+$foll+".inputWorldMatrix\;"); eval("connectAttr -f "+$foll+".outTranslate "+$follTop[0]+".translate\;"); eval("connectAttr -f "+$foll+".outRotate "+$follTop[0]+".rotate\;"); setAttr ($foll+".parameterU") $uvPos[0]; setAttr ($foll+".parameterV") $uvPos[1]; // parents the follicle into the follicleGroup // select -r $follTop[0]; select -tgl "follicleGroup"; parent; } select -r $sel; }