//Control Box Setup utility for skeletons //By: Alex Hogan //Date: July 3rd, 2003 // //Description: // Recursively travels down a skeleton and creates a control box for each joint, parent costrainging the joint to the control box. // global proc controlBoxSetup() { // Expand the Inital Bone selection to the whole sub-hierarchy // and load the selection into $ccName string Array. select -hi; string $ahName[]; $ahName = `ls -sl -type joint`; // Get the size of $ahName to determine how many times to run the loop // Clear the Selection int $ahSize = size($ahName); select -cl; // For Loop that Creates the Controller Box, moves it to the correct location and then // Parent Constrains the bone to it. for ($i=0;$i < $ahSize; $i++) { //create linear NURBS curve box at origin and scale down a bit curve -n ( $ahName[$i] + "_Ctrl") -d 1 -p -0.5 0.5 0.5 -p -0.5 0.5 -0.5 -p 0.5 0.5 -0.5 -p 0.5 0.5 0.5 -p -0.5 0.5 0.5 -p -0.5 -0.5 0.5 -p -0.5 -0.5 -0.5 -p -0.5 0.5 -0.5 -p -0.5 0.5 0.5 -p 0.5 0.5 0.5 -p 0.5 -0.5 0.5 -p -0.5 -0.5 0.5 -p -0.5 -0.5 -0.5 -p 0.5 -0.5 -0.5 -p 0.5 -0.5 0.5 -p -0.5 -0.5 0.5 -p -0.5 -0.5 -0.5 -p 0.5 -0.5 -0.5 -p 0.5 0.5 -0.5 -p -0.5 0.5 -0.5 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 ; xform -s .7 .7 .7 ; //move box to the current joint $newXformArray = `xform -q -t -ws $ahName[$i]`; xform -a -t $newXformArray[0] $newXformArray[1] $newXformArray[2] ($ahName[$i] + "_Ctrl"); //freeze box transformations makeIdentity -apply true -t 1 -r 1 -s 1 -jointOrient ($ahName[$i] + "_Ctrl"); //update scene window because it looks cooler that way refresh; //creates the constraints for the joints - swith to point and orient constraints if more flexibility is necessary parentConstraint -mo -w 1 ($ahName[$i] + "_Ctrl") $ahName[$i] ; //orientConstraint -mo -w 1 ($ahName[$i] + "_Ctrl") $ahName[$i] ; //pointConstraint -mo -w 1 ($ahName[$i] + "_Ctrl") $ahName[$i] ; } }