{ global string $lb_bottomMesh[]; global string $lbjunk[]; global int $lbJunkCurrent; //Creates window called litter bug and buttons global proc litterBug_UI () { //Check if window is open if so repalce if ( `window -exists litterBug` ) { deleteUI litterBug; } window -t "Litter Bug" -rtf true 1litterBug; //Buttons and such columnLayout; //--------------> text -label "Check to see if normals are facing up \n If not press Flip Normals"; button -label "Check Normals" -c "checkNorm" lbCheckN; button -label "Flip Normals" -c "flipNorm" lbFlipN; //--------------> text -label "________________________________________________________________"; //--------------> text -label "Select ground plane before pressing Map"; //--------------> intSliderGrp -label "Spacing" -value 50 -field true -minValue 10 -maxValue 100 -fieldMinValue 10 -fieldMaxValue 100 lbSpacing; //--------------> button -label "Map" -c "partCreate" lbCreate; //--------------> text -label "________________________________________________________________"; //--------------> button -label "Get Junk" -c "lbgetjunk" lbget; //--------------> text -label "________________________________________________________________"; //--------------> intSliderGrp -label "Dynamic Run Time" -value 5 -field true -minValue 1 -maxValue 10 -fieldMinValue 1 -fieldMaxValue 10 lbFrames; //--------------> checkBox -label "Dynamic Solver" -value 1 dynamicCheckBox; //--------------> checkBox -label "Basic Solver" -value 1 basicCheckBox; //--------------> floatSliderGrp -label "Rotate Amount" -value 360 -field true -minValue 1 -maxValue 360 -fieldMinValue 1 -fieldMaxValue 360 lbRotAmount; checkBox -label "Rotate X" -value 1 rotXCheckBox; checkBox -label "Rotate Y" -value 1 rotYCheckBox; checkBox -label "Rotate Z" -value 1 rotZCheckBox; //--------------> floatSliderGrp -label "Scale Min" -value 1 -field true -minValue .001 -maxValue 5 -fieldMinValue .001 -fieldMaxValue 5 lbScaleAmountMin; floatSliderGrp -label "Scale Max" -value 1 -field true -minValue .001 -maxValue 5 -fieldMinValue .001 -fieldMaxValue 5 lbScaleAmountMax; checkBox -label "Scale X" -value 1 scaleXCheckBox; checkBox -label "Scale Y" -value 1 scaleYCheckBox; checkBox -label "Scale Z" -value 1 scaleZCheckBox; //--------------> button -label "Create" -c "instObject" lbcreate; //--------------> text -label "________________________________________________________________"; //--------------> text -label "Use only if Dynamics Solver was used"; //--------------> intSliderGrp -label "Fine Tune" -value 5 -field true -minValue 1 -maxValue 10 -fieldMinValue 1 -fieldMaxValue 10 lbTune; //--------------> intSliderGrp -label "Strength" -value 50 -field true -minValue 1 -maxValue 100 -fieldMinValue 1 -fieldMaxValue 100 lbStrength; //--------------> checkBox -label "Revert Center Point" -value 1 cpCheckBox; //--------------> button -label "Fine Tune" -c "fineTune" lbfinetune; //--------------> button -label "Undo Fine Tune" -c "fineTuneUndo" lbUndofinetune; showWindow litterBug; } //Call for Window litterBug_UI; //----------------------------------------------------------- //Proc for creatin Particle tool proc partCreate (){ global string $lb_bottomMesh[]; global int $lbJunkCurrent; //Make ground global array $lb_bottomMesh = `ls -sl`; //Test if particles are still there and delete if (`particleExists lb_Particles`){ select -r lb_Particles; Delete; } //Test how many groups named junk there are string $lbJunkSize[] = `ls ("junk_*")`; int $lbJunkCurrent = size($lbJunkSize); //Delete any rigidBodies on ground select $lb_bottomMesh[0]; DeleteRigidBodies; //Set ground to rigidbody and make live select $lb_bottomMesh[0]; rigidBody -passive -n lbPassRigidBody -m 1 -dp 2 -sf 1 -df 1 -b 0 -l 0 -tf 200 -iv 0 0 0 -iav 0 0 0 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si 0 0 0 -sio none ; MakeLive; //Call for value of spacing int $lb_Spacing = `intSliderGrp -q -v lbSpacing`; //Create Particle Tool pro and sets jitter size radius to 0 ParticleTool; setToolTo dynParticleContext; dynParticleCtx -e -nc 0 -jr 0 -nj 1 dynParticleContext; //Set to Sketch particles dynParticleCtx -e -pn "lb_Particles" -sk 1 -ski $lb_Spacing dynParticleContext; //Get rid of particle tool attr window setNamedPanelLayout "Single Perspective View"; updateToolbox(); } //------------------------------------------------------------ proc lbgetjunk () { global string $lbjunk[]; global int $lbJunkCurrent; //Set your selected to what the junk will be string $lbjunk[] = `ls -sl`; select -cl; } //------------------------------------------------------------ proc instObject () { global string $lb_bottomMesh[]; global string $lbjunk[]; //undo the makelive; makeLive; //create the junk group group -em -n ("junk_" + $lbJunkCurrent); //This selectes the particles select -r lb_Particles; string $lbselection[] = `ls -sl`; //Find out how many particles there are float $lbcounter = `particle -q -count $lbselection[0]`; //For loop to create an object for each particle for ($x=0; $x<$lbcounter; $x++){ //String for the current particle string $part = $lbselection[0]+".pt["+$x+"]"; //Position of each particle float $partPos[2] = `getParticleAttr -at worldPosition $part`; //Create random number based on how many objects within the size of the junk array int $randarray = rand (size($lbjunk)); //Now use that random number to select a random object within the array and duplicate it select -r $lbjunk[$randarray]; duplicate; //Take the current object set it to an array and then move it to the particle's position move -a $partPos[0] $partPos[1] $partPos[2]; string $lbcurrent[] = `ls -sl`; //Check if object needs to be rotated/scaled then rotate/scale object and save positon //Scale needs to be first because of rotation and clipping the ground (shouldn't matter but makes a difference) xform -cp; int $lbScaleX = `checkBox -q -v scaleXCheckBox`; int $lbScaleY = `checkBox -q -v scaleYCheckBox`; int $lbScaleZ = `checkBox -q -v scaleZCheckBox`; float $lbScalerandMin = `floatSliderGrp -q -v lbScaleAmountMin`; float $lbScalerandMax = `floatSliderGrp -q -v lbScaleAmountMax`; float $lbScaleAmount = `rand $lbScalerandMin $lbScalerandMax`; if ($lbScaleX == 1) { scale -r $lbScaleAmount 1 1; } if ($lbScaleY == 1) { scale -r 1 $lbScaleAmount 1; } if ($lbScaleZ == 1) { scale -r 1 1 $lbScaleAmount; } int $lbRotX = `checkBox -q -v rotXCheckBox`; int $lbRotY = `checkBox -q -v rotYCheckBox`; int $lbRotZ = `checkBox -q -v rotZCheckBox`; float $lbRotAmount = `floatSliderGrp -q -v lbRotAmount`; if ($lbRotX == 1) { rotate -r `rand $lbRotAmount` 0 0; } if ($lbRotY == 1) { rotate -r 0 `rand $lbRotAmount` 0; } if ($lbRotZ == 1) { rotate -r 0 0 `rand $lbRotAmount`; } FreezeTransformations; xform -cp; //This is the dynamic solver------------------------------------------<<<<<<<<< int $lbDynamic = `checkBox -q -v dynamicCheckBox`; if($lbDynamic == 1){ //Make the current object an active rigid body select $lbcurrent[0]; rigidBody -active -m 1 -dp 2 -sf 1 -df 1 -b 0 -l 0 -tf 200 -iv 0 0 0 -iav 0 0 0 -c 0 -pc 0 -i 0 0 0 -imp 0 0 0 -si 0 0 0 -sio none ; //Create gravity and connect it gravity -pos 0 0 0 -name "lbGravity1" -m 100 -att 0 -dx 0 -dy -1 -dz 0 -mxd -1 -vsh none -vex 0 -vof 0 0 0 -vsw 360 -tsr 0.5 ; connectDynamic -f lbGravity1 $lbcurrent[0]; cycleCheck -e off; //Run through the animation for dynamics int $lbTotal = `intSliderGrp -q -v lbFrames`; for ($lbTime = 1; $lbTime <= $lbTotal; $lbTime++){ currentTime $lbTime ; } select -r lbGravity1 ; Delete; } //This is the basic solver--------------------------------------------<<<<<<<<< int $lbBasic = `checkBox -query -value basicCheckBox`; if ($lbBasic == 1) { //Find objects bounding box min and move pivot point to it float $lbMinX = `getAttr (($lbcurrent[0])+".boundingBoxMinX")`; float $lbMaxX = `getAttr (($lbcurrent[0])+".boundingBoxMaxX")`; float $lbrealX = ($lbMinX + $lbMaxX) / 2; float $lbMinZ = `getAttr (($lbcurrent[0])+".boundingBoxMinZ")`; float $lbMaxZ = `getAttr (($lbcurrent[0])+".boundingBoxMaxZ")`; float $lbrealZ = ($lbMinZ + $lbMaxZ) / 2; float $lbMinY= `getAttr (($lbcurrent[0])+".boundingBoxMinY")`; EnterEditMode; move -ws $lbrealX $lbMinY $lbrealZ (($lbcurrent[0])+".scalePivot") (($lbcurrent[0])+".rotatePivot") ; EnterEditMode; //Sets constraints - Taken out!!! // geometryConstraint $lb_bottomMesh[0] $lbcurrent[0]; // normalConstraint -aim 0 1 0 -wut "object" $lb_bottomMesh[0] $lbcurrent[0]; } //Parent the object to the junk group parent $lbcurrent[0] ("junk_" + $lbJunkCurrent); } } //------------------------------------------------------------ //This is Fine tune solver------------------------------------------<<<<<<<<< //Recreate a current selection for fine tuning proc fineTune (){ string $lbcurrentTune[] = `ls -sl`; select $lbcurrentTune[0]; delete -constraints; //Turns on centerpoint or not int $lbCP = `checkBox -query -value cpCheckBox`; if ($lbCP == 1) { xform -cp; } move 0 0.5 0; //Find out the strength of the gravity int $lbStrength = `intSliderGrp -q -v lbStrength`; //Create gravity and connect it gravity -pos 0 0 0 -name "lbGravity2" -m $lbStrength -att 0 -dx .002 -dy -1 -dz 0 -mxd -1 -vsh none -vex 0 -vof 0 0 0 -vsw 360 -tsr 0.5 ; connectDynamic -f lbGravity2 $lbcurrentTune[0]; //Run through the animation for dynamics int $lbTotal = `intSliderGrp -q -v lbTune`; for ($lbTime = 1; $lbTime <= $lbTotal; $lbTime++){ currentTime $lbTime ; } select -r lbGravity2 ; doDelete; select -r $lbcurrentTune[0]; DeleteRigidBodies; deleteSelectRigidBodies; delete -icn; } //------------------------------------------------------------ proc fineTuneUndo() { Undo; } proc checkNorm() { ToggleFaceNormalDisplay; } proc flipNorm() { ReversePolygonNormals; } }