global proc tighten(float $zzTightenMultiplier) { global int $zzIsClicked; $zzIsClicked = 1; string $selObjs[] = `ls -sl`; int $numSelObjs = `size $selObjs`; if ( $numSelObjs != 0 ) { for ( $obj in $selObjs ) { // setup variables for animated attributes int $numKeys = `keyframe -query -keyframeCount $obj`; int $numKeysSelected = `keyframe -q -selected -keyframeCount`; string $objectAnimConnections[] = `listConnections -d false -c true -type "animCurve" $obj`; string $animatedAttribs[]; int $sizeOfIt = `size $objectAnimConnections`; for ( $num = 0; $num < $sizeOfIt; $num+=2 ) { string $attrib[]; string $entry = $objectAnimConnections[$num]; tokenize ( $entry, ".", $attrib ); $animatedAttribs[( $num/2 )] = $attrib[1]; //print ( "iteration: " + $num + "\n" ); } // now that we have an array with all animated attributes of an object, we can determine // which keys on each attribute are selected, and find out tangent information. for ( $attrib in $animatedAttribs ) { // this will now allow us to get an array of individual keys on each attribute string $objAttrib = $obj + "." + $attrib; float $keyList[] = `keyframe -query -selected ( $obj + "." + $attrib )`; for ( $key in $keyList ) { string $temp = $key; float $tangentInX[] = `keyTangent -t $key -q -ix $objAttrib`; float $tangentOutX[] = `keyTangent -t $key -q -ox $objAttrib`; float $tangentInY[] = `keyTangent -t $key -q -iy $objAttrib`; float $tangentOutY[] = `keyTangent -t $key -q -oy $objAttrib`; //float $magnitudeIn = `sqrt( ( $tangentInX[0]*$tangentInX[0] ) + ( $tangentInY[0]*$tangentInY[0] ))`; //float $magnitudeOut = `sqrt( ( $tangentOutX[0]*$tangentOutX[0] ) + ( $tangentOutY[0]*$tangentOutY[0] ))`; //float $angleIn = `atan( $tangentInY[0] / $tangentInX[0] )`; //float $angleOut = `atan( $tangentOutY[0] / $tangentOutX[0] )`; //float $tightInX = $magnitudeIn * ( `cos ( $angleIn/2 )` ); //float $tightOutX = $magnitudeOut * ( `cos ( $angleIn/2 )` ); //float $tightInY = $magnitudeIn * ( `sin ( $angleIn/2 )` ); //float $tightOutY = $magnitudeOut * ( `sin ( $angleIn/2 )` ); //print ( "angles: " + $angleIn + " : " + $angleOut + "\n" ); keyTangent -e -a -t $key -ix $tangentInX[0] -iy ($tangentInY[0]/2) -ox $tangentOutX[0] -oy ($tangentOutY[0]/2) $objAttrib; } } } } print ( "selected keyframes tightened for selected objects\n" ); }