/////////////////////////////////////////////////////////////////////////////////////////////// //component jitter //author: Walter Behrnes //Date Created: June 02, 2003 //version: 1 //info: component jitter randomly moves points about on any given model. Not only does this // the script move points, it will also move geometry. Depending on how many points you // select this script could take several seconds to complete its task. // // **place in maya scripts folder and type in componentJitter in command line to run. /////////////////////////////////////////////////////////////////////////////////////////////// global string $myNoiseType; global proc componentJitter() { if(`window -exists ComponentJitter`) { deleteUI ComponentJitter; } window -widthHeight 463 290 ComponentJitter; columnLayout C1; separator -height 25 -style "none"; frameLayout -collapsable true -collapse false -borderStyle "etchedOut" Randomize_Type; columnLayout -width 400 -columnOffset "left" 10 R1; radioButtonGrp -numberOfRadioButtons 4 -labelArray4 "Gauss" "Spherical" "Noise" "Random" -on1 "typeOfNoise(0)" -on2 "typeOfNoise(1)" -on3 "typeOfNoise(2)" -on4 "typeOfNoise(3)"; setParent C1; setParent C1; columnLayout C2; separator -height 5 -style "none"; frameLayout -collapsable true -collapse false -borderStyle "etchedOut" Randomization_Settings; columnLayout -width 400 -columnOffset "left" 10 R1; floatSliderGrp -label "MinX" -field true -min -1 -max 1 -pre 4 -value -.075 MinX; floatSliderGrp -label "MaxX" -field true -min -1 -max 1 -pre 4 -value .075 MaxX; floatSliderGrp -label "MinY" -field true -min -1 -max 1 -pre 4 -value -.075 MinY; floatSliderGrp -label "MaxY" -field true -min -1 -max 1 -pre 4 -value -.075 MaxY; floatSliderGrp -label "MinZ" -field true -min -1 -max 1 -pre 4 -value -.075 MinZ; floatSliderGrp -label "MaxZ" -field true -min -1 -max 1 -pre 4 -value .075 MaxZ; setParent C2; setParent C2; separator -height 15 -style "none"; button -label "Randomize" -width 75 -command "randomizePoints();"; showWindow ComponentJitter; } global proc typeOfNoise(int $noiseType) { global string $myNoiseType; string $myNoise[] = {"gauss","sphrand","noise","rand"}; $myNoiseType = $myNoise[$noiseType]; print $myNoiseType; if (($noiseType == 0) || ($noiseType == 1) || ($noiseType == 2)) { floatSliderGrp -e -en 0 MinX; floatSliderGrp -e -en 0 MinY; floatSliderGrp -e -en 0 MinZ; } if ($noiseType == 3) { floatSliderGrp -e -en 1 MinX; floatSliderGrp -e -en 1 MinY; floatSliderGrp -e -en 1 MinZ; } } global proc randomizePoints() { global string $myNoiseType; string $mySel[] = `ls -sl -fl`; float $randMinX = `floatSliderGrp -query -value MinX`; float $randMaxX = `floatSliderGrp -query -value MaxX`; float $randMinY = `floatSliderGrp -query -value MinY`; float $randMaxY = `floatSliderGrp -query -value MaxY`; float $randMinZ = `floatSliderGrp -query -value MinZ`; float $randMaxZ = `floatSliderGrp -query -value MaxZ`; for ($i = 0; $i < size($mySel);$i++) { if (($myNoiseType == "rand")) { string $myOutJitter =("move -os -r ("+$myNoiseType+"("+$randMinX+","+$randMaxX+"))("+$myNoiseType+"("+$randMinY+","+$randMaxY+"))("+$myNoiseType+"("+$randMinY+","+$randMaxZ+")) "+$mySel[$i]); eval $myOutJitter; } if ($myNoiseType == "gauss") { string $myOutJitter =("move -os -r ("+$myNoiseType+"("+$randMaxX+"))("+$myNoiseType+"("+$randMaxY+"))("+$myNoiseType+"("+$randMaxZ+")) "+$mySel[$i]); eval $myOutJitter; } if (($myNoiseType == "sphrand")||($myNoiseType == "noise")) { vector $newVectorRand = sphrand(<<$randMaxX, $randMaxY, $randMaxZ>>); string $myOutJitter =("move -os -r ("+$newVectorRand.x+")("+$newVectorRand.y+")("+$newVectorRand.z+") "+$mySel[$i]); eval $myOutJitter; } print "Operation Complete"; } }