/*--------------------------------Updated 3-29-2008---- FB refine Joints -v1.0- by Chris "Funky Bunnies" Whitaker ======================================================== Website: www.FunkyBunnies3d.com ======================================================== -Concept: This simple script was made to easily create twist-joints and the like -The Basics: Select the joint you want to bissect, use FBrefineJoints and it will create a new joint in the middle of the currently selected one. ======================================================== -Sorry, I couldn't decide if I should beef up this script or not, so I decided to leave it simple however, it would be quite simple to make the bone slide along the length of its parent bone or allow for multiple bones to be created and interpolate accordingly. I'll leave that to you if you want to do it, or if enough people request it I can add it in. ========================================================================== // please contact me with any suggestions or bugs \\ //----------------------------------------------------------------------\\ // Contact Me: Chris@FunkyBunnies3d.com \\ ========================================================================== ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Generic Disclaimer: Use at your own risk. I won't be responsible for anything bad that happens to your objects, scenes, or your car.// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ global proc FBrefineJoints() { string $selection[] = `ls -sl -o`; for ($i=0;$i<`size $selection`;$i++) { if (`objectType $selection[$i]` == "joint") { select -r $selection[$i]; string $child[] = `pickWalk -d down`; if ($child[0] == "") { warning ($selection[$i]+" has no children"); break; } float $parentRadius = `getAttr ($selection[$i] + ".radius")`; float $childRadius = `getAttr ($child[0] + ".radius")`; float $childpos[] = `xform -q -ws -piv $child[0]`; float $jointpos[] = `xform -q -ws -piv $selection[$i]`; float $newX = ($childpos[0]-$jointpos[0])/2.0 + $jointpos[0]; float $newY = ($childpos[1]-$jointpos[1])/2.0 + $jointpos[1]; float $newZ = ($childpos[2]-$jointpos[2])/2.0 + $jointpos[2]; string $newJt =`insertJoint $selection[$i]`; move -a $newX $newY $newZ ($newJt+".scalePivot") ($newJt + ".rotatePivot"); setAttr ($newJt + ".radius") (($parentRadius+$childRadius)/2); if ( size (`match("twist"+"[0-9]*") $selection[$i]`) ) rename $newJt (`substitute ("_twist"+"[0-9]*") $selection[$i] "_twist#"`); else rename $newJt ($selection[$i]+"_twist"); } } } FBrefineJoints();