//James Parks 12-02-03 //Mega Randomization Script /////////////////////// //switch various controls on or off as they're needed /////////////////////// global proc staticStates() { floatFieldGrp -e -en 0 animRange; radioButtonGrp -e -en 1 objShapeSelect; radioButtonGrp -e -en 0 shapeTypeSelect; floatFieldGrp -e -en 0 stepValue; //checkBoxGrp -e -en 0 jitterSelect; } global proc animStates() { floatFieldGrp -e -en 1 animRange; //radioButtonGrp -e -en 0 -sl 1 objShapeSelect; //radioButtonGrp -e -en 0 -sl 1 shapeTypeSelect; floatFieldGrp -e -en 1 stepValue; //checkBoxGrp -e -en 1 jitterSelect; } global proc placementStates() { radioButtonGrp -e -en 0 -sl 1 shapeTypeSelect; checkBoxGrp -e -en 1 rotateAxesGrp; floatFieldGrp -e -en 1 rotMin; floatFieldGrp -e -en 1 rotMax; checkBoxGrp -e -en 1 scaleAxesGrp; floatFieldGrp -e -en 1 scaleMin; floatFieldGrp -e -en 1 scaleMax; checkBoxGrp -e -en 1 udAttrCheckGrp; textFieldGrp -e -en 1 udAttrName; floatFieldGrp -e -en 1 udMin; floatFieldGrp -e -en 1 udMax; } global proc shapeStates() { radioButtonGrp -e -en 1 shapeTypeSelect; checkBoxGrp -e -en 0 rotateAxesGrp; floatFieldGrp -e -en 0 rotMin; floatFieldGrp -e -en 0 rotMax; checkBoxGrp -e -en 0 scaleAxesGrp; floatFieldGrp -e -en 0 scaleMin; floatFieldGrp -e -en 0 scaleMax; checkBoxGrp -e -en 0 udAttrCheckGrp; textFieldGrp -e -en 0 udAttrName; floatFieldGrp -e -en 0 udMin; floatFieldGrp -e -en 0 udMax; } /////////////////////// //The Mega Rand GUI /////////////////////// global proc jpMegaRand() { //Create a window string $win = "megaRandWin"; if (`window -exists $win`) deleteUI -window $win; window -title "Mega-Rand" -minimizeButton true -maximizeButton false -rtf true -wh 495 345 $win; int $poMin = `playbackOptions -q -min`; int $poMax = `playbackOptions -q -max`; rowColumnLayout -nr 2 -rh 1 265 -rh 2 50; rowColumnLayout -nc 2 -cw 1 230 -cw 2 255; frameLayout -label "Rand Options" -borderStyle "in" -cll 0 -li 10 -la "center" -mw 5 -mh 5 //-w 500 ; columnLayout; radioButtonGrp -nrb 2 -cal 1 "left" -l1 "Static" -l2 "Animated" -sl 1 -cc1 "staticStates()" -cc2 "animStates()" staticAnimSelect ; floatFieldGrp -numberOfFields 2 -en 0 -label "Start/End" -value1 $poMin -value2 $poMax -cal 1 "left" -cw 1 80 -cw 2 60 -cw 3 60 animRange; rowColumnLayout -nc 2 -cw 1 140 ; floatFieldGrp -numberOfFields 1 -en 0 -label "Key Step" -value1 1 -cal 1 "left" -cw 1 80 -cw 2 60 stepValue; // checkBoxGrp // -numberOfCheckBoxes 1 // -en 0 // -label "Jitter" // -value1 0 // //-cal 1 "left" // -cw 1 40 // -cw 2 20 // jitterSelect; setParent ..; radioButtonGrp -nrb 2 -en 1 -cal 1 "left" -l1 "Placement" -l2 "Shape" -sl 1 -cc1 "placementStates()" -cc2 "shapeStates()" objShapeSelect; radioButtonGrp -nrb 2 -en 0 -cal 1 "left" -l1 "Whole Object" -l2 "Selected Verts" -sl 1 shapeTypeSelect; //text -l ""; radioButtonGrp -nrb 2 -en 1 -cal 1 "left" -l1 "Object Space" -l2 "World Space" -sl 1 objWorldSelect; radioButtonGrp -nrb 2 -en 1 -cal 1 "left" -l1 "Relative" -l2 "Absolute" -sl 1 relAbsSelect; setParent ..; setParent ..; frameLayout -label "Attribute Array" -borderStyle "in" -cll 0 -li 10 -la "center" -mw 5 -mh 5 //-w 500 ; columnLayout; checkBoxGrp -numberOfCheckBoxes 3 -label "Translate" -labelArray3 "X" "Y" "Z" -value1 1 -value2 1 -value3 1 -cal 1 "left" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 translateAxesGrp; floatFieldGrp -numberOfFields 3 -label "Min" -value1 0.2 -value2 0.2 -value3 0.2 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 transMin; floatFieldGrp -numberOfFields 3 -label "Max" -value1 1.0 -value2 1.0 -value3 1.0 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 transMax; checkBoxGrp -numberOfCheckBoxes 3 -label "Rotate" -labelArray3 "X" "Y" "Z" -value1 1 -value2 1 -value3 1 -cal 1 "left" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 rotateAxesGrp; floatFieldGrp -numberOfFields 3 -label "Min" -value1 0 -value2 0 -value3 0 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 rotMin; floatFieldGrp -numberOfFields 3 -label "Max" -value1 360 -value2 360 -value3 360 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 rotMax; checkBoxGrp -numberOfCheckBoxes 3 -label "Scale" -labelArray3 "X" "Y" "Z" -value1 1 -value2 1 -value3 1 -cal 1 "left" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 scaleAxesGrp; floatFieldGrp -numberOfFields 3 -label "Min" -value1 0.2 -value2 0.2 -value3 0.2 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 scaleMin; floatFieldGrp -numberOfFields 3 -label "Max" -value1 1.0 -value2 1.0 -value3 1.0 -cal 1 "right" -cw 1 60 -cw 2 60 -cw 3 60 -cw 4 60 scaleMax; checkBoxGrp -numberOfCheckBoxes 1 -l "User Defined Attribute" -v1 0 -cal 1 "left" //-cw 1 60 //-cw 2 120 udAttrCheckGrp; textFieldGrp -tx "...Channel Name..." udAttrName; rowColumnLayout -nc 2; floatFieldGrp -numberOfFields 1 -l "Min" -cal 1 "left" -cw 1 40 -v1 0 udMin; floatFieldGrp -numberOfFields 1 -l "Max" -cal 1 "left" -cw 1 40 -v1 1 udMax; setParent ..; setParent ..; setParent ..; setParent ..; frameLayout -label "" -borderStyle "in" -cll 0 -li 10 -la "center" -mw 5 -mh 5 //-w 500 ; rowLayout -nc 4 -cw 1 110 -cw 2 110 -cw 3 110 -cw 4 110 -w 440 ; button -label "Randomize Me" -w 100 -c "randChoice()"; button -label "Help" -w 100 -c "helpWin()"; button -label "Reset" -w 100 -c "jpMegaRand()"; button -label "Close" -w 100 -c ("deleteUI " + $win); showWindow $win; window -e -wh 495 345 $win; } global proc helpWin() { string $helpWin = "megaRandHelpWin"; if (`window -exists $helpWin`) deleteUI $helpWin; window -t "Mega Rand Help" -wh 405 230 -rtf 1 $helpWin; rowColumnLayout -nr 17 -rh 1 15 -rh 2 15 -rh 3 15 -rh 4 15 -rh 5 15 -rh 6 15 -rh 7 15 -rh 8 15 -rh 9 15 -rh 10 15 -rh 11 15 -rh 12 15 -rh 13 15 -rh 14 15 -rh 15 15 -rh 16 15 -rh 17 15 ; text -al "left" -l "Static"; text -al "left" -l "Animated"; text -al "left" -l " Start/End"; text -al "left" -l " Key Step"; text -al "left" -l " Jitter"; text -al "left" -l "Placement"; text -al "left" -l "Shape"; text -al "left" -l "Whole Object"; text -al "left" -l "Selected Verts"; text -al "left" -l "Object Space"; text -al "left" -l "World Space"; text -al "left" -l "Relative"; text -al "left" -l "Absolute"; text -al "left" -l "Attribute Array"; text -al "left" -l ""; text -al "right" -l "Note"; text -al "left" -l ""; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l " = "; text -al "left" -l ""; text -al "left" -l " = "; text -al "left" -l ""; text -al "left" -l "Randomize object placement"; text -al "left" -l "Randomize the animation of an object"; text -al "left" -l "The start and end frames of the animation"; text -al "left" -l "Number of frames between random keys"; text -al "left" -l "Adds a little randomness to the key spacing"; text -al "left" -l "Randomize the placement of an entire object"; text -al "left" -l "Randomize the vertices of a poly object"; text -al "left" -l "Randomize every vertex of a poly object"; text -al "left" -l "Randomze selected vertices of a poly object"; text -al "left" -l "Randomize in Object Space"; text -al "left" -l "Randomize in World Space"; text -al "left" -l "Randomize relative to the current value"; text -al "left" -l "Randomize within an absolute range"; text -al "left" -l "Pick the attributes and the range you want to randomize"; text -al "left" -l ""; text -al "left" -l "Mega-Rand automatically grays out non-applicable controls"; showWindow $helpWin; window -e -wh 390 280 megaRandHelpWin; } global proc nyiProc() { string $nyiWin = "nyiWin"; if (`window -exists $nyiWin`) deleteUI $nyiWin; window -t "Not Yet Implemented" -wh 405 230 -rtf 1 $nyiWin; columnLayout; text -l "Not yet implemented"; showWindow $nyiWin; window -e -wh 405 230 nyiWin; } //////////////////////// //Pick the randomization method //////////////////////// global proc randChoice() { int $staticAnim = `radioButtonGrp -q -sl staticAnimSelect`; int $placeShape = `radioButtonGrp -q -sl objShapeSelect`; if($staticAnim == 1) { if($placeShape == 1) staticPlacementRand(); if($placeShape == 2) staticShapeObjectVertexRand(); }//end if if($staticAnim == 2) { if($placeShape == 1) placeAnimRand(); if($placeShape == 2) shapeAnimRand(); }//end if }//end proc randChoice global proc placeAnimRand() { string $selObjects[] = `ls -sl`; int $objWorld = `radioButtonGrp -q -sl objWorldSelect`; int $relAbs = `radioButtonGrp -q -sl relAbsSelect`; string $objWorldText = "-os"; string $relAbsText = "-r"; if($objWorld == 2) $objWorldText = "-ws"; if($relAbs == 2) $relAbsText = "-a"; float $minTime = `floatFieldGrp -q -v1 animRange`; float $maxTime = `floatFieldGrp -q -v2 animRange`; float $step = `floatFieldGrp -q -v1 stepValue`; int $traX = `checkBoxGrp -q -v1 translateAxesGrp`; int $traY = `checkBoxGrp -q -v2 translateAxesGrp`; int $traZ = `checkBoxGrp -q -v3 translateAxesGrp`; int $rotX = `checkBoxGrp -q -v1 rotateAxesGrp`; int $rotY = `checkBoxGrp -q -v2 rotateAxesGrp`; int $rotZ = `checkBoxGrp -q -v3 rotateAxesGrp`; int $scaX = `checkBoxGrp -q -v1 scaleAxesGrp`; int $scaY = `checkBoxGrp -q -v2 scaleAxesGrp`; int $scaZ = `checkBoxGrp -q -v3 scaleAxesGrp`; int $udCheck = `checkBoxGrp -q -v1 udAttrCheckGrp`; float $traXmin = `floatFieldGrp -q -v1 transMin`; float $traXmax = `floatFieldGrp -q -v1 transMax`; float $traYmin = `floatFieldGrp -q -v2 transMin`; float $traYmax = `floatFieldGrp -q -v2 transMax`; float $traZmin = `floatFieldGrp -q -v3 transMin`; float $traZmax = `floatFieldGrp -q -v3 transMax`; float $rotXmin = `floatFieldGrp -q -v1 rotMin`; float $rotXmax = `floatFieldGrp -q -v1 rotMax`; float $rotYmin = `floatFieldGrp -q -v2 rotMin`; float $rotYmax = `floatFieldGrp -q -v2 rotMax`; float $rotZmin = `floatFieldGrp -q -v3 rotMin`; float $rotZmax = `floatFieldGrp -q -v3 rotMax`; float $scaXmin = `floatFieldGrp -q -v1 scaleMin`; float $scaXmax = `floatFieldGrp -q -v1 scaleMax`; float $scaYmin = `floatFieldGrp -q -v2 scaleMin`; float $scaYmax = `floatFieldGrp -q -v2 scaleMax`; float $scaZmin = `floatFieldGrp -q -v3 scaleMin`; float $scaZmax = `floatFieldGrp -q -v3 scaleMax`; string $udString = `textFieldGrp -q -tx udAttrName`; float $udMin = `floatFieldGrp -q -v1 udMin`; float $udMax = `floatFieldGrp -q -v1 udMax`; for($frame = $minTime; $frame <= $maxTime; $frame = $frame + $step) { for($obj in $selObjects) { select $obj; if($traX == 1) { float $randomX = `rand $traXmin $traXmax`; float $curVal = getAttr ($obj + ".tx"); //setAttr ($obj + ".tx") ($randomX + $curVal); //xform -r -os -t $randomX 0 0; xform $relAbsText $objWorldText -t $randomX 0 0; setKeyframe -t $frame -at translateX $obj; } if($traY == 1) { float $randomY = `rand $traYmin $traYmax`; float $curVal = getAttr ($obj + ".ty"); //setAttr ($obj + ".ty") ($randomY + $curVal); //xform -r -os -t 0 $randomY 0; xform $relAbsText $objWorldText -t 0 $randomY 0; setKeyframe -t $frame -at translateY $obj; } if($traZ == 1) { float $randomZ = `rand $traZmin $traZmax`; float $curVal = getAttr ($obj + ".tz"); //setAttr ($obj + ".tz") ($randomZ + $curVal); //xform -r -os -t 0 0 $randomZ; xform $relAbsText $objWorldText -t 0 0 $randomZ; setKeyframe -t $frame -at translateZ $obj; } if($rotX == 1) { float $randomX = `rand $rotXmin $rotXmax`; float $curVal = getAttr ($obj + ".rx"); //xform -r -os -ro $randomX 0 0; xform $relAbsText $objWorldText -ro $randomX 0 0; float $thisRotX = `getAttr ($obj + ".rx")`; if($thisRotX >= 360) setAttr ($obj + ".rx") ($thisRotX % 360); setKeyframe -t $frame -at rotateX $obj; } if($rotY == 1) { float $randomY = `rand $rotYmin $rotYmax`; float $curVal = getAttr ($obj + ".ry"); //xform -r -os -ro 0 $randomY 0; xform $relAbsText $objWorldText -ro 0 $randomY 0; float $thisRotY = `getAttr ($obj + ".ry")`; if($thisRotY >= 360) setAttr ($obj + ".ry") ($thisRotY % 360); setKeyframe -t $frame -at rotateY $obj; } if($rotZ == 1) { float $randomZ = `rand $rotZmin $rotZmax`; float $curVal = getAttr ($obj + ".rz"); //xform -r -os -ro 0 0 $randomZ; xform $relAbsText $objWorldText -ro 0 0 $randomZ; float $thisRotZ = `getAttr ($obj + ".rz")`; if($thisRotZ >= 360) setAttr ($obj + ".rz") ($thisRotZ % 360); setKeyframe -t $frame -at rotateZ $obj; } if($scaX == 1) { float $randomX = `rand $scaXmin $scaXmax`; float $curVal = getAttr ($obj + ".sx"); setAttr ($obj + ".sx") ($randomX + $curVal); setKeyframe -t $frame -at scaleX $obj; }//end if if($scaY == 1) { float $randomY = `rand $scaYmin $scaYmax`; float $curVal = getAttr ($obj + ".sy"); setAttr ($obj + ".sy") ($randomY + $curVal); setKeyframe -t $frame -at scaleY $obj; }//end if if($scaZ == 1) { float $randomZ = `rand $scaZmin $scaZmax`; float $curVal = getAttr ($obj + ".sz"); setAttr ($obj + ".sz") ($randomZ + $curVal); setKeyframe -t $frame -at scaleZ $obj; }//end if if($udCheck == 1) { string $udAttrs[]; int $numOfChannels = `tokenize $udString ", " $udAttrs`; for($udAttr in $udAttrs) { float $randomUD = `rand $udMin $udMax`; float $curVal = getAttr ($obj + "." + $udAttr); setAttr ($obj + "." + $udAttr) ($randomUD + $curVal); setKeyframe -t $frame -at $udAttr $obj; }//end for }//end if select $selObjects; }//end for: object }//end for: time print "Randomization Finished"; }//end proc placeAnimRand global proc shapeAnimRand() { //Place user data into a variable int $shapeType = `radioButtonGrp -q -sl shapeTypeSelect`; string $selObjects[] = `ls -sl`; int $objWorld = `radioButtonGrp -q -sl objWorldSelect`; int $relAbs = `radioButtonGrp -q -sl relAbsSelect`; string $objWorldText = "-os"; string $relAbsText = "-r"; if($relAbs == 2) $relAbsText = "-a"; float $minTime = `floatFieldGrp -q -v1 animRange`; float $maxTime = `floatFieldGrp -q -v2 animRange`; float $step = `floatFieldGrp -q -v1 stepValue`; int $traX = `checkBoxGrp -q -v1 translateAxesGrp`; int $traY = `checkBoxGrp -q -v2 translateAxesGrp`; int $traZ = `checkBoxGrp -q -v3 translateAxesGrp`; float $traXmin = `floatFieldGrp -q -v1 transMin`; float $traXmax = `floatFieldGrp -q -v1 transMax`; float $traYmin = `floatFieldGrp -q -v2 transMin`; float $traYmax = `floatFieldGrp -q -v2 transMax`; float $traZmin = `floatFieldGrp -q -v3 transMin`; float $traZmax = `floatFieldGrp -q -v3 transMax`; for($frame = $minTime; $frame <= $maxTime; $frame = $frame + $step) { //statement for randomizing the entire Object if($shapeType == 1) { //set the number of vertices int $vertexCount[] = `polyEvaluate -v`; int $n= $vertexCount[0]; for($i=0;$i<$n;$i++) { //create three random values of the loop float $randomX = `rand $traXmin $traXmax`; float $randomY = `rand $traYmin $traYmax`; float $randomZ = `rand $traZmin $traZmax`; string $yourObj = ($selObjects[0] + ".vtx[" + $i + "]"); select -r $yourObj; vector $origVals = `xform -q -t -ws $yourObj`; if($objWorld == 2) { $objWorldText = "-ws"; if ($traX == 0) $randomX = $origVals.x; if ($traY == 0) $randomY = $origVals.y; if ($traZ == 0) $randomZ = $origVals.z; }//end if else { if($traX == 0) $randomX = 0; if($traY == 0) $randomY = 0; if($traZ == 0) $randomZ = 0; }//end else move $relAbsText $objWorldText $randomX $randomY $randomZ; setKeyframe -t $frame $yourObj; select $selObjects; }//end for: $i }//end if //statement for randomizing Selected Vertices if($shapeType == 2) { string $selectedVertices[] = `ls -sl -fl`; for($vertex in $selectedVertices) { //create three random values of the loop float $randomX = `rand $traXmin $traXmax`; float $randomY = `rand $traYmin $traYmax`; float $randomZ = `rand $traZmin $traZmax`; select $vertex; vector $origVals = `xform -q -t -ws $vertex`; if($objWorld == 2) { $objWorldText = "-ws"; if ($traX == 0) $randomX = $origVals.x; if ($traY == 0) $randomY = $origVals.y; if ($traZ == 0) $randomZ = $origVals.z; }//end if else { if($traX == 0) $randomX = 0; if($traY == 0) $randomY = 0; if($traZ == 0) $randomZ = 0; }//end else move $relAbsText $objWorldText $randomX $randomY $randomZ ; setKeyframe -t $frame $vertex; select $selObjects; }//end for: vertices }//end if }//end for: $frame print "Randomization Finished"; }//end proc shapeAnimRand global proc staticPlacementRand() { string $selObjects[] = `ls -sl`; int $objWorld = `radioButtonGrp -q -sl objWorldSelect`; int $relAbs = `radioButtonGrp -q -sl relAbsSelect`; string $objWorldText = "-os"; string $relAbsText = "-r"; if($objWorld == 2) $objWorldText = "-ws"; if($relAbs == 2) $relAbsText = "-a"; int $traX = `checkBoxGrp -q -v1 translateAxesGrp`; int $traY = `checkBoxGrp -q -v2 translateAxesGrp`; int $traZ = `checkBoxGrp -q -v3 translateAxesGrp`; int $rotX = `checkBoxGrp -q -v1 rotateAxesGrp`; int $rotY = `checkBoxGrp -q -v2 rotateAxesGrp`; int $rotZ = `checkBoxGrp -q -v3 rotateAxesGrp`; int $scaX = `checkBoxGrp -q -v1 scaleAxesGrp`; int $scaY = `checkBoxGrp -q -v2 scaleAxesGrp`; int $scaZ = `checkBoxGrp -q -v3 scaleAxesGrp`; int $udCheck = `checkBoxGrp -q -v1 udAttrCheckGrp`; float $traXmin = `floatFieldGrp -q -v1 transMin`; float $traXmax = `floatFieldGrp -q -v1 transMax`; float $traYmin = `floatFieldGrp -q -v2 transMin`; float $traYmax = `floatFieldGrp -q -v2 transMax`; float $traZmin = `floatFieldGrp -q -v3 transMin`; float $traZmax = `floatFieldGrp -q -v3 transMax`; float $rotXmin = `floatFieldGrp -q -v1 rotMin`; float $rotXmax = `floatFieldGrp -q -v1 rotMax`; float $rotYmin = `floatFieldGrp -q -v2 rotMin`; float $rotYmax = `floatFieldGrp -q -v2 rotMax`; float $rotZmin = `floatFieldGrp -q -v3 rotMin`; float $rotZmax = `floatFieldGrp -q -v3 rotMax`; float $scaXmin = `floatFieldGrp -q -v1 scaleMin`; float $scaXmax = `floatFieldGrp -q -v1 scaleMax`; float $scaYmin = `floatFieldGrp -q -v2 scaleMin`; float $scaYmax = `floatFieldGrp -q -v2 scaleMax`; float $scaZmin = `floatFieldGrp -q -v3 scaleMin`; float $scaZmax = `floatFieldGrp -q -v3 scaleMax`; string $udString = `textFieldGrp -q -tx udAttrName`; float $udMin = `floatFieldGrp -q -v1 udMin`; float $udMax = `floatFieldGrp -q -v1 udMax`; for($obj in $selObjects) { select $obj; if($traX == 1) { float $randomX = `rand $traXmin $traXmax`; float $curVal = getAttr ($obj + ".tx"); //setAttr ($obj + ".tx") ($randomX + $curVal); //xform -r -os -t $randomX 0 0; xform $relAbsText $objWorldText -t $randomX 0 0; } if($traY == 1) { float $randomY = `rand $traYmin $traYmax`; float $curVal = getAttr ($obj + ".ty"); //setAttr ($obj + ".ty") ($randomY + $curVal); //xform -r -os -t 0 $randomY 0; xform $relAbsText $objWorldText -t 0 $randomY 0; } if($traZ == 1) { float $randomZ = `rand $traZmin $traZmax`; float $curVal = getAttr ($obj + ".tz"); //setAttr ($obj + ".tz") ($randomZ + $curVal); //xform -r -os -t 0 0 $randomZ; xform $relAbsText $objWorldText -t 0 0 $randomZ; } if($rotX == 1) { float $randomX = `rand $rotXmin $rotXmax`; float $curVal = getAttr ($obj + ".rx"); //xform -r -os -ro $randomX 0 0; xform $relAbsText $objWorldText -ro $randomX 0 0; float $thisRotX = `getAttr ($obj + ".rx")`; if($thisRotX >= 360) setAttr ($obj + ".rx") ($thisRotX % 360); } if($rotY == 1) { float $randomY = `rand $rotYmin $rotYmax`; float $curVal = getAttr ($obj + ".ry"); //xform -r -os -ro 0 $randomY 0; xform $relAbsText $objWorldText -ro 0 $randomY 0; float $thisRotY = `getAttr ($obj + ".ry")`; if($thisRotY >= 360) setAttr ($obj + ".ry") ($thisRotY % 360); } if($rotZ == 1) { float $randomZ = `rand $rotZmin $rotZmax`; float $curVal = getAttr ($obj + ".rz"); //xform -r -os -ro 0 0 $randomZ; xform $relAbsText $objWorldText -ro 0 0 $randomZ; float $thisRotZ = `getAttr ($obj + ".rz")`; if($thisRotZ >= 360) setAttr ($obj + ".rz") ($thisRotZ % 360); } if($scaX == 1) { float $randomX = `rand $scaXmin $scaXmax`; float $curVal = getAttr ($obj + ".sx"); setAttr ($obj + ".sx") ($randomX + $curVal); } if($scaY == 1) { float $randomY = `rand $scaYmin $scaYmax`; float $curVal = getAttr ($obj + ".sy"); setAttr ($obj + ".sy") ($randomY + $curVal); } if($scaZ == 1) { float $randomZ = `rand $scaZmin $scaZmax`; float $curVal = getAttr ($obj + ".sz"); setAttr ($obj + ".sz") ($randomZ + $curVal); } if($udCheck == 1) { string $udAttrs[]; int $numOfChannels = `tokenize $udString ", " $udAttrs`; for($udAttr in $udAttrs) { float $randomUD = `rand $udMin $udMax`; float $curVal = getAttr ($obj + "." + $udAttr); setAttr ($obj + "." + $udAttr) ($randomUD + $curVal); } } select $selObjects; }//end for print "Randomization Finished"; }//end proc staticPlacementRand global proc staticShapeObjectVertexRand() { //Place user data into a variable int $shapeType = `radioButtonGrp -q -sl shapeTypeSelect`; string $selObjects[] = `ls -sl`; int $traX = `checkBoxGrp -q -v1 translateAxesGrp`; int $traY = `checkBoxGrp -q -v2 translateAxesGrp`; int $traZ = `checkBoxGrp -q -v3 translateAxesGrp`; float $traXmin = `floatFieldGrp -q -v1 transMin`; float $traXmax = `floatFieldGrp -q -v1 transMax`; float $traYmin = `floatFieldGrp -q -v2 transMin`; float $traYmax = `floatFieldGrp -q -v2 transMax`; float $traZmin = `floatFieldGrp -q -v3 transMin`; float $traZmax = `floatFieldGrp -q -v3 transMax`; //statement for randomizing the entire Object if($shapeType == 1) { //set the number of vertices int $vertexCount[] = `polyEvaluate -v`; int $n= $vertexCount[0]; for($i=0;$i<$n;$i++) { //create three random values of the loop float $randomX = `rand $traXmin $traXmax`; float $randomY = `rand $traYmin $traYmax`; float $randomZ = `rand $traZmin $traZmax`; string $yourObj = ($selObjects[0] + ".vtx[" + $i + "]"); select -r $yourObj; if ($traX == 0) { $randomX = 0; } if ($traY == 0) { $randomY = 0; } if ($traZ == 0) { $randomZ = 0; } move -r -os -wd $randomX $randomY $randomZ; select $selObjects; } } //statement for randomizing Selected Vertices if($shapeType == 2) { string $selectedVertices[] = `ls -sl -fl`; for($vertex in $selectedVertices) { //create three random values of the loop float $randomX = `rand $traXmin $traXmax`; float $randomY = `rand $traYmin $traYmax`; float $randomZ = `rand $traZmin $traZmax`; if ($traX == 0) { $randomX = 0; } if ($traY == 0) { $randomZ = 0; } if ($traZ == 0) { $randomY = 0; } polyMoveVertex -ws 0 -ltx $randomX -lty $randomY -ltz $randomZ $vertex ; select $selObjects; } } print "Randomization Finished"; }//end proc staticShapeObjectVertexRand jpMegaRand;