shatter help, attach particles to objects script question

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 12 December 2009   #1
shatter help, attach particles to objects script question

I got this script from the shatter help forum. Take all the shattered pieces and puts a particle in the centre of each object attaching it's translation to the respective object. Works brilliant!

//Bind objects to nParticles

string $selection[] = `ls -sl`;
int $n = 0;
float $partPos[];
string $particleList = "nParticle";

for ($sel in $selection){
float $p[] = `xform -ws -q -rp $sel`;
xform -a -ws -t (-1*$p[0]) (-1*$p[1]) (-1*$p[2]) $sel;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $sel;
xform -t $p[0] $p[1] $p[2] $sel;
$particleList = $particleList + " -p " + $p[0] + " " + $p[1] + " " + $p[2];
if(`attributeQuery -node $sel -ex "particleIndex"` != 1){
addAttr -longName "particleIndex" -at "short" $sel;
}
setAttr ($sel + ".particleIndex") $n;
$n++;
}

string $nParticleShape[] = eval($particleList);

for($sel in $selection){
float $w = `getAttr ($sel + ".boundingBoxSizeX")`;
float $h = `getAttr ($sel + ".boundingBoxSizeY")`;
float $d = `getAttr ($sel + ".boundingBoxSizeZ")`;
float $bbox[] = {$w, $h, $d};
float $dim = 0;
if($w>$dim){ $dim = $w;};
if($h>$dim){ $dim = $h;};
if($d>$dim){ $dim = $d;};
$dim = $dim * 0.25;

int $particleIndex = `getAttr ($sel + ".particleIndex")`;

//nParticle -e -attribute radiusPP -order $particleIndex -fv $dim $nParticleShape[1];

string $expr = "float $pos[] = `nParticle -attribute position -order " +
$particleIndex +
"-q nParticleShape1`;\n" +
"translateX = $pos[0];\n" +
"translateY = $pos[1];\n" +
"translateZ = $pos[2];\n" +
"float $vel[] = " +
"`nParticle -attribute velocity -order " +
$particleIndex + " -q nParticleShape1`;\n" +
"if(`currentTime -q` > 1){\n" +
"rotateX = rotateX + ($vel[0]*0.5);\n" +
"rotateY = rotateY + ($vel[1]*0.5);\n" +
"rotateZ = rotateZ + ($vel[2]*0.5);\n" +
"}else{\n" +
"rotateX = 0;\n" +
"rotateY = 0;\n" +
"rotateZ = 0;\n" +
"}\n";


expression -s $expr -o $sel -ae 1 -uc all;
}

The problem is it creates a particle shape nParticleShape1 which is a problem if i want to do more than one of these systems within a scene, being not much of a scripter i want to know if anyone can figure out how to specify the name of the particle shape created?
 
Old 12 December 2009   #2
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 11:31 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.