// Copyright © 2007 Jason Gill All rights reserved // www.3dgill.com // // This script moves whatever is selected in random amounts within the specified limit. // // Example Use: // // If you have a scene with strong winds and you need something like a piece of cloth to flop back and forth,. // Select the vertices on the object and use the tool to create a couple blend shapes. // global proc jgRandomMoveProc(int $shapeSpace, int $cylinderAxis, float $minX, float $maxX, float $minY, float $maxY, float $minZ, float $maxZ) { for ($selection in `ls -sl`) { float $fullCircle = (deg_to_rad(rand(0, 360))); select -r $selection; if ($shapeSpace == 1) { move -r (rand($minX, $maxX)) (rand($minY, $maxY)) (rand($minZ, $maxZ)); } if ($shapeSpace == 2) { float $sinORcos; if (`sin($fullCircle)` > 0.5) { $sinORcos = `cos($fullCircle)`; } if (`sin($fullCircle)` <= 0.5) { if ($fullCircle <= -0.5) { $sinORcos = `cos($fullCircle)`; } else { $sinORcos = `sin($fullCircle)`; } } move -r (`sin($fullCircle)`*(rand($minX, $maxX))) ($sinORcos*(rand($minY, $maxY))) (`cos($fullCircle)`*(rand($minZ, $maxZ))); } if ($shapeSpace == 3) { if ($cylinderAxis == 1) { move -r (rand($minX, $maxX)) (`sin($fullCircle)`*(rand($minY, $maxY))) (`cos($fullCircle)`*(rand($minZ, $maxZ))); } if ($cylinderAxis == 2) { move -r (`sin($fullCircle)`*(rand($minX, $maxX))) (rand($minY, $maxY)) (`cos($fullCircle)`*(rand($minZ, $maxZ))); } if ($cylinderAxis == 3) { move -r (`sin($fullCircle)`*(rand($minX, $maxX))) (`cos($fullCircle)`*(rand($minY, $maxY))) (rand($minZ, $maxZ)); } } } if ($shapeSpace < 1) { print "WARNING: The first two of eight arguments must be a 1, 2, or 3"; } if ($shapeSpace > 3) { print "WARNING: The first two of eight arguments must be a 1, 2, or 3"; } if ($cylinderAxis < 1) { print "WARNING: The first two of eight arguments must be a 1, 2, or 3"; } if ($cylinderAxis > 3) { print "WARNING: The first two of eight arguments must be a 1, 2, or 3"; } } global proc jgRandomMove() { if (`window -ex jgRandomMoUI`) deleteUI jgRandomMoUI; window -t "Jason Gill - Random Move - www.3dgill.com" -wh 370 265 -s false jgRandomMoUI; columnLayout -cal "center"; columnLayout -cal "center"; radioButtonGrp -nrb 3 -l "Move in what area?" -la3 "cube" "sphere" "cylinder" -sl 1 -cw4 120 80 80 80 -cl4 "right" "left" "left" "left" -on3 ("radioButtonGrp -e -en 1 cylinderAxisRbGrp") -of3 ("radioButtonGrp -e -en 0 cylinderAxisRbGrp") shapeSpaceRbGrp; radioButtonGrp -nrb 3 -l "Which Axis?" -la3 "X" "Y" "Z" -sl 2 -cw4 120 80 80 80 -cl4 "right" "left" "left" "left" -en 0 cylinderAxisRbGrp; separator -w 370 -h 10; floatSliderGrp -label "minimum X" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v -5 -cw3 110 60 190 -ct3 "right" "left" "left" minXSliderGrp; floatSliderGrp -label "maximum X" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v 5 -cw3 110 60 190 -ct3 "right" "left" "left" maxXSliderGrp; separator -w 370 -h 10; floatSliderGrp -label "minimum Y" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v -5 -cw3 110 60 190 -ct3 "right" "left" "left" minYSliderGrp; floatSliderGrp -label "maximum Y" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v 5 -cw3 110 60 190 -ct3 "right" "left" "left" maxYSliderGrp; separator -w 370 -h 10; floatSliderGrp -label "minimum Z" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v -5 -cw3 110 60 190 -ct3 "right" "left" "left" minZSliderGrp; floatSliderGrp -label "maximum Z" -field true -min -50 -max 50 -fmn -1000 -fmx 1000 -v 5 -cw3 110 60 190 -ct3 "right" "left" "left" maxZSliderGrp; separator -w 370 -h 10; setParent ..; rowLayout -nc 2 -cw2 80 200 -ct2 "both" "both"; text -l " "; button -w 150 -al "center" -l "Move Selection" -c "jgRandomMoveProc `radioButtonGrp -q -sl shapeSpaceRbGrp` `radioButtonGrp -q -sl cylinderAxisRbGrp` `floatSliderGrp -q -v minXSliderGrp` `floatSliderGrp -q -v maxXSliderGrp` `floatSliderGrp -q -v minYSliderGrp` `floatSliderGrp -q -v maxYSliderGrp` `floatSliderGrp -q -v minZSliderGrp` `floatSliderGrp -q -v maxZSliderGrp`"; setParent ..; setParent ..; showWindow; }