global proc mossGroup(int $minnum, int $maxnum, float $mindrop, float $maxdrop, int $times) { int $count = $times; while ($count < 50) { float $minX = rand(-3, 3); float $minZ = rand(-3, 3); string $dups[]; $original = `ls -sl`; $master = `duplicate $original`; xform -rp 0 0 0; select $master; move $minX 0 $minZ; // Randomize the number of drops int $num = rand($minnum, $maxnum); string $parentName = $original[0]; if (`objExists moss_locator` != 1) { // Creates the main top level locator to have the rotation controls spaceLocator -n ("moss_locator"); move -y 2; select -cl; select $master ("moss_locator"); parent; // Adds the attributes to the locator select ("moss_locator"); addAttr -ln "turnX" -at "double" -min -25 -max 25 -dv 0; setAttr -e-keyable true ("moss_locator.turnX"); addAttr -ln "turnZ" -at "double" -min -25 -max 25 -dv 0; setAttr -e-keyable true ("moss_locator.turnZ"); } else { select $master ("moss_locator"); parent; } select $master; for($n = 0; $n < $num; $n++) { $dup = `duplicate`; $dups[$n] = $dup[0]; $transformNode = $dup[0]; // Randomize the drop float $drop = rand($mindrop, $maxdrop); //print($drop + "\n"); move -os 0 $drop 0; parent -r $dup $master; // rotation expression based on locator string $rotationExpression = $dup[0] + ".rotateX = moss_locator.turnX;\n" + $dup[0] + ".rotateZ = moss_locator.turnZ;\n"; expression -string $rotationExpression; $master = $dup; } select $original; //select $dups; $count++; } }