PDA

View Full Version : Emit a few lights (Point Light)


charlJoubert
04-01-2009, 11:34 AM
I'm trying to figure out how to get an emitter to emit lights. Obviously it can't do that so I want to figure out a work around.

My plan is to emit about 4 or 5 particles and then have my four or five point lights waiting for them, as soon as a particle is emitted, say with a ParticleID of 2 then one of my point lights with an expression takes on the XYZ translation of that particle.

Any clue where I'd find the syntax for that. I was thinking something along the lines of (Obviously wrong I'm sure):

pointLight.TranslateX = nParticleShape1.ParticleID1.TranslateX
pointLight.TranslateY = nParticleShape1.ParticleID1.TranslateY
pointLight.TranslateZ = nParticleShape1.ParticleID1.TranslateZ

Unless there is a way to constrain a certain light to a certain particle.

Any help would be greatly appreciated :beer:

charlJoubert
04-01-2009, 12:17 PM
I might be getting closer. This now complains about syntax error:

pointLight1.translateX = nParticle1.pt(1).tx

Baalz
04-01-2009, 12:21 PM
Let's say you emit 5 particle then I would go for something like this :

for ($i=0;$i<5;$i++){
float $pos[] = `getParticleAttr -at position -a true particleShape1.pt[$i];
setAttr ("pointLight"+$i+".translate") -type "double3" $pos[0] $pos[1] $pos[2];
}

it should work fine :)

Baalz

rxgeez
04-01-2009, 04:22 PM
If you're only doing it for about for small number of lights you could set up a runtime expression on the particle to do sometyhing like this:

vector $position = particleShape1.position;

if (particleShape1.particleId == 2) {
setAttr pointLight1.tx ($position.x);
setAttr pointLight1.ty ($position.y);
setAttr pointLight1.tz ($position.z);
}


-k

charlJoubert
04-02-2009, 08:12 AM
Thanks RXGeez! Yours worked :) Baalz you'res complained about a syntax error on line 2. I'm not sure what it should be or how it's gone wrong so I'll stick with Geez's one. It's only about 5 or so lights anyway, although I'm sure yours would've been a little more efficient, I can see what you're trying to get with it.

Thanks to the both of you :)

Cheesestraws
04-02-2009, 08:22 AM
I think Baalz should read, seems like it was missing the second `, but I have not tested this so it might be wrong.

for ($i=0;$i<5;$i++){
float $pos[] = `getParticleAttr -at position -a true particleShape1.pt[$i]`;
setAttr ("pointLight"+$i+".translate") -type "double3" $pos[0] $pos[1] $pos[2];
}

Baalz
04-02-2009, 09:31 AM
Yeah you're right Cheesestraws, i forgot the second `.I should have re-read the script before posting it, shame on me :sad:...

Anyway the code from rxgeez works so that's cool.

Always happy to help,

Baalz

charlJoubert
04-03-2009, 03:14 PM
Just out of curiosity where would I place Baalz's... zz..s..s...s.s *caugh*... Baalz's expression? On the position of the particle shape as an "after dynamics"?

Baalz
04-03-2009, 03:54 PM
You've got to create it in the expression editor in a new expression.
Make sure that the Evalution thing is on Always.

Baalz

charlJoubert
04-06-2009, 07:52 AM
Ah geez *facepalm* :P

I've never thought to actually look under window, animation, expression editor. I've always gone through a particle or an attribute to get there.

Silly me

Thanks :)

CGTalk Moderation
04-06-2009, 07:52 AM
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.