// nudge window // by Jeremy Cantor // March 30, 2000 global float $transNudgeIncrValue = 0.1; global float $rotNudgeIncrementValue = 1.0; global string $transAxisSpace; global string $rotAxisSpace; //create temporary object & perform camera axis nudge global proc zoom_nudge(float $byHowMuch, int $zPosNeg) { string $whatPicked[] = `selectedNodes`; //create temporary aim object..get translation values $aimNudger = `polyCube -n aimNudger`; pointConstraint $whatPicked[0] $aimNudger; float $xyzTrans[3] = `xform -q -ws -t $aimNudger`; delete $aimNudger; //reCreate aim obj & move into position $aimNudger = `polyCube -n aimNudger`; move -ws $xyzTrans[0] $xyzTrans[1] $xyzTrans[2] $aimNudger; //what is current camera? string $lookingThru = `lookThru -q`; //if current camera contains the word "Shape", select its parent instead if (match("Shape", $lookingThru) == "Shape") {string $lookingThruDad[] = `listRelatives -p $lookingThru`; $lookingThru = $lookingThruDad[0];} //point temporary aim object toward camera aimConstraint -aimVector 1 0 0 $lookingThru $aimNudger; //nudge aimNudger along camera axis move -r -os ($byHowMuch * $zPosNeg) 0 0 $aimNudger; //get new translation values from aimNudger & calculate deltas float $xyzTransNew[3] = `xform -q -ws -t $aimNudger`; $xyzTrans[0] = $xyzTransNew[0] - $xyzTrans[0]; $xyzTrans[1] = $xyzTransNew[1] - $xyzTrans[1]; $xyzTrans[2] = $xyzTransNew[2] - $xyzTrans[2]; //nudge selected node(s) select -r $whatPicked; move -r -ws $xyzTrans[0] $xyzTrans[1] $xyzTrans[2]; delete $aimNudger; } //nudge attribute global proc attribute_nudge(float $byHowMuch, int $aPosNeg) { string $whatObjects[] = `ls -sl`; global string $gChannelBoxName; string $whatAttrs[] = `channelBox -q -sma $gChannelBoxName`; if (size($whatAttrs) == 0) warning "No attributes selected\n"; else { int$numObjs; for ($numObjs = 0; $numObjs < size($whatObjects); $numObjs ++) { int $numAttrs; for ($numAttrs = 0; $numAttrs < size($whatAttrs); $numAttrs ++) { string $currentAttr = $whatObjects[$numObjs]+"."+$whatAttrs[$numAttrs]; if (`objExists $currentAttr`) setAttr $currentAttr (`getAttr $currentAttr` + $byHowMuch*$aPosNeg); else print ("Note: " + $currentAttr + " does not exist.\n"); } } } } //get translation space & nudge increment & move accordingly global proc translation_nudge(string $tXYZ, int $tPosNeg) { string $whatPicked[] = `selectedNodes`; if (size($whatPicked) == 0) warning "Nothing selected"; else { int $transAxisSpaceInt = `radioButtonGrp -q -sl trans_space_radio_button`; float $transNudgeIncrValue = `floatSliderGrp -q -v trans_nudge_increment_slider`; switch($transAxisSpaceInt) {case 1: $transAxisSpace = "-ws"; manipMoveContext -e -mode 2 Move; break; case 2: $transAxisSpace = "-os"; manipMoveContext -e -mode 0 Move; break; case 3: $transAxisSpace = "-ls"; manipMoveContext -e -mode 1 Move; break; case 4: $transAxisSpace = "fcurve";} if ($transAxisSpace != "fcurve") { switch($tXYZ) {case "X": move -r $transAxisSpace ($transNudgeIncrValue * $tPosNeg) 0 0; break; case "Y": move -r $transAxisSpace 0 ($transNudgeIncrValue * $tPosNeg) 0; break; case "Z": move -r $transAxisSpace 0 0 ($transNudgeIncrValue * $tPosNeg); break; case "C": zoom_nudge $transNudgeIncrValue $tPosNeg; break; case "A": attribute_nudge $transNudgeIncrValue $tPosNeg;} } else { switch($tXYZ) {case "X": keyframe -e -an "keys" -r -tc ($transNudgeIncrValue * $tPosNeg); break; case "Y": keyframe -e -an "keys" -r -vc ($transNudgeIncrValue * $tPosNeg); break; case "Z": warning "No Z values in Graph Editor\n"; break; case "C": warning "No camera in Graph Editor\n"; break; case "A": warning "No attributes in Graph Editor\n";} } } } //create temporary objects & perform planar rotation nudge global proc planar_rotation_nudge(float $byHowMuch, int $rPosNeg) { string $whatPicked[] = `selectedNodes`; if (size($whatPicked) > 1) warning ("Cannot perform planar nudge on multiple objects\n"); else { //create aim obj..get xform values $aimNudger = `group -empty -n aimNudger`; pointConstraint $whatPicked[0] $aimNudger; string $lookingThruRot = `lookThru -q`; //if current camera contains the word "Shape", select its parent instead if (match("Shape", $lookingThruRot) == "Shape") {string $lookingThruRotDad[] = `listRelatives -p $lookingThruRot`; $lookingThruRot = $lookingThruRotDad[0];} aimConstraint -aimVector 1 0 0 $lookingThruRot $aimNudger; float $xyzTrans[3] = `xform -q -ws -t $aimNudger`; float $xyzAim[3] = `xform -q -ws -ro $aimNudger`; delete $aimNudger; //recreate aim obj & child..copy xforms from old aim obj to new aim obj $aimNudger = `group -empty -n $aimNudger`; $childOfAimNudger = `group -empty -n childOfAimNudger`; parent $childOfAimNudger $aimNudger; move -ws $xyzTrans[0] $xyzTrans[1] $xyzTrans[2]$aimNudger; rotate -ws $xyzAim[0] $xyzAim[1] $xyzAim[2] $aimNudger; //rotate childOfAimNudger to match selected node float $xyzRot[3] = `xform -q -ws -ro $whatPicked[0]`; rotate -ws $xyzRot[0] $xyzRot[1] $xyzRot[2] $childOfAimNudger; //nudge aimNudger rotate -r -os ($byHowMuch * (-$rPosNeg)) 0 0 $aimNudger; //get new rotation values from childOfAimNudger float $xyzRot[3] = `xform -q -ws -ro $childOfAimNudger`; //nudge selected node select -r $whatPicked; rotate -ws $xyzRot[0] $xyzRot[1] $xyzRot[2]; delete $aimNudger; } } //get rotation space & nudge increment & rotate accordingly global proc rotation_nudge(string $rXYZ, int $rPosNeg) { string $whatPicked[] = `selectedNodes`; if (size($whatPicked) == 0) warning "Nothing selected"; else { int $rotAxisSpaceInt = `radioButtonGrp -q -sl rot_space_radio_button`; float $rotNudgeIncrValue = `floatSliderGrp -q -v rot_nudge_increment_slider`; switch($rotAxisSpaceInt) {case 1: $rotAxisSpace = "-os"; manipRotateContext -e -mode 0 Rotate; break; case 2: $rotAxisSpace = "-ws"; manipRotateContext -e -mode 1 Rotate; break; default: $rotAxisSpace = "-eu"; manipRotateContext -e -mode 2 Rotate;} switch($rXYZ) {case "X": rotate -r $rotAxisSpace ($rotNudgeIncrValue * $rPosNeg) 0 0; break; case "Y": rotate -r $rotAxisSpace 0 ($rotNudgeIncrValue * $rPosNeg) 0; break; case "Z": rotate -r $rotAxisSpace 0 0 ($rotNudgeIncrValue * $rPosNeg); break; case "P": planar_rotation_nudge $rotNudgeIncrValue $rPosNeg;} } } global proc nudgeWindow() { string $pressW = "buildXYZTransMM; if( `popupMenu -exists tempMM` ) { deleteUI tempMM; };"; string $pressE = "buildXYZRotMM; if( `popupMenu -exists tempMM` ) { deleteUI tempMM; };"; if ((`window -ex nudgeWindow`) == true) deleteUI nudgeWindow; if (`windowPref -q -ex nudgeWindow`) { if ((`windowPref -q -w nudgeWindow`) != 226) windowPref -e -w 226 nudgeWindow; if ((`windowPref -q -h nudgeWindow`) != 300) windowPref -e -h 300 nudgeWindow; } window -title "Nudge" -mxb true -mnb true -s true nudgeWindow; rowColumnLayout -nr 9 -rh 1 10 -rh 2 22 -rh 3 45 -rh 4 25 -rh 5 45 -rh 6 22 -rh 7 45 -rh 8 25 -rh 9 45 -co 2 "left" 8 -co 3 "left" 8 -co 4 "left" 8 -co 5 "left" 8 -co 6 "left" 8 -co 7 "left" 8 -co 8 "left" 8 -co 9 "left" 8; // row 1 - blank button for spacing button -vis false; rowColumnLayout -nc 1 -cw 1 205; button -label "TRANSLATION NUDGE" -al "center" -h 22 -c ($pressW); setParent ..; gridLayout -numberOfRowsColumns 2 5 -cellWidthHeight 41 20; button -label "+ X" -w 41 -h 20 -c "translation_nudge X 1"; button -label "+ Y" -w 41 -h 20 -c "translation_nudge Y 1"; button -label "+ Z" -w 41 -h 20 -c "translation_nudge Z 1"; button -label "+ Cam" -w 41 -h 20 -c "translation_nudge C 1"; button -label "+ A" -w 41 -h 20 -c "translation_nudge A 1"; button -label "- X" -w 41 -h 20 -c "translation_nudge X -1"; button -label "- Y" -w 41 -h 20 -c "translation_nudge Y -1"; button -label "- Z" -w 41 -h 20 -c "translation_nudge Z -1"; button -label "- Cam" -w 41 -h 20 -c "translation_nudge C -1"; button -label "- A" -w 41 -h 20 -c "translation_nudge A -1"; setParent ..; radioButtonGrp -nrb 4 -cw 1 60 -cw 2 50 -cw 3 50 -cw 4 50 -sl 1 -labelArray4 "world" "obj" "loc" "fcv" -on1 ($pressW + " manipMoveContext -e -mode 2 Move") -on2 ($pressW + " manipMoveContext -e -mode 0 Move") -on3 ($pressW + " manipMoveContext -e -mode 1 Move") trans_space_radio_button; floatSliderGrp -field true -cw 1 45 -minValue 0.01 -maxValue 1 -fieldMinValue 0 -fieldMaxValue 100 -value 0.1 -pre 2 -s 0.01 trans_nudge_increment_slider; // row 6 rowColumnLayout -nc 1 -cw 1 164; button -label "ROTATION NUDGE" -al "center" -h 22 -c ($pressE); setParent ..; gridLayout -numberOfRowsColumns 2 4 -cellWidthHeight 41 20; button -label "+ X" -w 41 -h 20 -c "rotation_nudge X 1"; button -label "+ Y" -w 41 -h 20 -c "rotation_nudge Y 1"; button -label "+ Z" -w 41 -h 20 -c "rotation_nudge Z 1"; button -label "+ P" -w 41 -h 20 -c "rotation_nudge P 1"; button -label "- X" -w 41 -h 20 -c "rotation_nudge X -1"; button -label "- Y" -w 41 -h 20 -c "rotation_nudge Y -1"; button -label "- Z" -w 41 -h 20 -c "rotation_nudge Z -1"; button -label "- P" -w 41 -h 20 -c "rotation_nudge P -1"; setParent ..; radioButtonGrp -nrb 3 -cw 1 70 -cw 2 70 -cw 3 70 -sl 1 -labelArray3 "local" "global" "gimbal" -on1 ($pressE + " manipRotateContext -e -mode 0 Rotate") -on2 ($pressE + " manipRotateContext -e -mode 1 Rotate") -on3 ($pressE + " manipRotateContext -e -mode 2 Rotate") rot_space_radio_button; floatSliderGrp -field true -cw 1 45 -minValue 0.1 -maxValue 10 -fieldMinValue 0 -fieldMaxValue 360 -value 1 -pre 1 -s 0.1 rot_nudge_increment_slider; // gridLayout -numberOfRowsColumns 1 5 -cellWidthHeight 41 20; // button -label "<<<" -w 41 -h 20 -c "rotation_nudge X 1"; // button -label "<" -w 41 -h 20 -c "rotation_nudge Y 1"; // button -label "attr" -w 41 -h 20 -en false; // button -label ">" -w 41 -h 20 -c "rotation_nudge Z 1"; // button -label ">>>" -w 41 -h 20 -c "rotation_nudge P 1"; // setParent ..; // floatSliderGrp -field true -cw 1 45 // -minValue 0.0 -maxValue 10 // -fieldMinValue 0 // -value 1 -pre 2 attr_nudge_increment_slider; showWindow nudgeWindow; } nudgeWindow;