// Creation Date: Dec-05-2001 // // Author: // ------------------------- // --------------------------- // Klaus Stangl // Student@TU Graz // Demoartist/Developer // Educator@Siliconstudio Graz // www.worldofmaya.com // office@worldofmaya.com // ----------------------------- // ------------------------------- // // // Script Name: // // ownShatter (version: 0.1) // // Description: // This script allows you to instance geometry // // // Create a shelf button with this command: // source ownShatter.mel;ownShatter(); // // For more infos read the documentation on www.worldofmaya.com or mail! // // global proc ownShatter() { //Var Declare string $selectionAName[]; string $particleName[]; string $particleInstancerName ; int $runX = 0; int $sizeObjectSelection = 0; float $PostionVariable[3]; //Selection $objectSelectionName = `ls -sl`; $sizeObjectSelection = `size $objectSelectionName`; if ($sizeObjectSelection > 0) { //Empty Particle Object $particleName = `particle`; select -cl; for($runX = 0; $runX < $sizeObjectSelection; $runX++) { select $objectSelectionName[$runX]; CenterPivot; select -cl; $PostionVariable = `getAttr($objectSelectionName[$runX]+".center")`; //print($PostionVariable[0] + " " + $PostionVariable[1] + " " + $PostionVariable[2] + " " + $objectSelectionName[$runX] + "\n"); emit -o $particleName[0] -pos $PostionVariable[0] $PostionVariable[1] $PostionVariable[2]; } $particleInstancerName = `particleInstancer -cycle None -cycleStep 1 -cycleStepUnits Frames -levelOfDetail Geometry -rotationUnits Degrees -rotationOrder XYZ -position worldPosition -age age $particleName[1]`; for($runX = 0; $runX < $sizeObjectSelection; $runX++) { select $objectSelectionName[$runX]; move -rpr 0 0 0 ; FreezeTransformations; select $particleName[1]; particleInstancer -e -a -obj $objectSelectionName[$runX]; select -cl; } addAttr -ln objIndex -dt doubleArray $particleName[1]; setAttr -e -keyable true ($particleName[1]+".objIndex"); dynExpression -s "objIndex = id;" -c $particleName[1]; particleInstancer -e -name $particleInstancerName -objectIndex objIndex $particleName[1]; saveInitialState $particleName[1] ; for($runX = 0; $runX < $sizeObjectSelection; $runX++) { $PostionVariable = `xform -ws -q -t ($particleName[0]+".pt["+$runX+"]")`; select $objectSelectionName[$runX]; move -rpr $PostionVariable[0] $PostionVariable[1] $PostionVariable[2] ; // FreezeTransformations; select -cl; } } else warning("!!! Nothing selected !!!"); }