View Full Version : Constraining objects to particles

06 June 2005, 08:12 PM
Does anybody know of a way to more or less parent an object to a particle, I'm thinking of lights as such in particular. I know about instancing geometry to particals but I'd really like to attach real objects not instances

Thanks much.

06 June 2005, 10:14 PM
You'll have to script.

For normal objects you use particle instancer but instanced lights don't affect the scene.

I can't create a script here because I don't have access to Maya at the moment. But I'll do my best helping you.

The script should place a light in the position for every particle. But the number of particles can vary so you have to turn off every light that doesn't "have" a particle.

The scriptnode could look basicly like this:
string $lights[] = (retrieve you're lamps by using the ls command);
int $maxLights = (max number of particles used (NEVER SMALLER THEN THE ACTUAL NUMBER OF PARICLES!));
int $pCount = `getAttr ($particle + ".count")`; //gets you're number of particles

for ($i in $pCount){
(turnLight "$light[$i]" on) //you figure this one out
$pos = `getParticleAttr -at position ($particle + ".pt[" + $i + "]")`; //get the particle position
setAttr $light[$i].translateX $pos[0]; //this section has wrong syntax, but you'll have to
setAttr $light[$i].translateY $pos[1]; //figure out how you gonna transfer the values
setAttr $light[$i].translateZ $pos[2]; //or maby someone could fill me in?
turn light "$light[$i]" off

I guess you'll have to comment before I continue.
Whats the aprox number of particles?

06 June 2005, 11:33 PM
Thanks for the help! That's a bit 'o work. I didn't have any particular plans to use this at the moment, I was just wondering if it was possible. But think how cool it'd be to have some sort of cascading light effect.

06 June 2005, 11:57 PM
yea, absolutely. I think you'll have to do this sometimes. Glow can only take you so far...

06 June 2005, 12:20 AM
While we are on the subject, I always thought it would be cool to have the location of cv’s in a nurbs curve dictated by the last “x” number of particles coming out of an emitter.

Never sat down to work it out so I’m curious: how hard this would be to implement?

06 June 2005, 08:46 AM
it's a pretty easy thing. Basicly it's like the script I put here before but you'll give the position values to a cluster that you have bounded the cv to.

06 June 2005, 04:58 PM
Curiosity just spiked. I am going to try and follow this through to some type of result. If I get anything interesting or relevant I’ll post the script. Thanks for the starting point.

06 June 2005, 11:38 PM
good idea, please write a link here to a new thread with you're result (it's worth a thread of it's own:)

I'll be back in two weeks and listen to you're progress.

06 June 2005, 09:52 PM
So, I put a few minutes into the “cv on particle” script the other day. I used a simple expression. It turns out there is not much to it. Is there any interest in that?

I would probably have to post the scene file as well for it to make any sense, as it is rather specific. Let me know and I’ll put it up.


04 April 2006, 05:25 PM
the problem with that script as far as i can tell is that the setAttr command will set the object's translation on the current frame, but will not actually attach it to the particle, so it wont move in sync. I am trying to do something similar and i am having trouble with the connectAttr syntax when used with individual particles... can anyone help?

04 April 2006, 05:31 PM
I think the most common solution is to create motion paths from the particles (there are scripts for this available on Highend I think). I guess the existens of these script sort of shows that there are no simple solution ;-)

04 April 2006, 06:53 PM
There are some scripts on to do that , can t remember the name for now...just search in the dynamic section

CGTalk Moderation
04 April 2006, 06:53 PM
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.