PDA

View Full Version : emit particle at death


RoundRobbin
05-14-2008, 08:36 AM
is there a way to emit another particleShape after the original particle dies, or reaches the end of its lifespan/age?

Aikiman
05-14-2008, 08:50 PM
Yes its called the emit function. Create an if conditional on the particles lifespan, then "emit -o particle2 -pos $pos" etc etc. If you require a bunch of particles you need to also create a for loop in conjucntion with the eval command, so that you can emit the same particle many times per frame at death position and velocity if you like. It gets a little complicated with the eval command cause you have to concatenate the emit command as strings but its doable.

RoundRobbin
05-14-2008, 08:58 PM
i'm a newb when it comes to scripting techy stuff.

Aikiman
05-14-2008, 10:40 PM
I think its the only way to do it unless you create a collision event which doesnt require any scripting but then the emission isnt based on lifespan.

How many particles do you want to emit per particle1?

RoundRobbin
05-14-2008, 10:43 PM
Thanks Jeremy, I guess its all mel command reference from here for those functions you've described.

untelon
05-16-2008, 01:11 AM
This is how I would do it:

1. Create a particle system, whatever it may be...

2. Select the particle system you created and chose "Particles/Emit from Object". An Omni type shall work just fine. (NOTE: At this point you should see that a new particle system was created, but its emitter is BENEATH the original particle system.

3. Select The original particle system again, and this time chose "Particles/Per Point Emission Rates".

At this point, if you open the original particle shape node you should see an attribute under the Per Particle Attributes named "Emitter xRate PP" (where x stands for a number).

If you do not see this, repeat 1 through 3.

4. You would then make sure that your original's particles lifespan mode is set to "lifespanPP".

5. Right click on your Emitter xRate PP attribute and create a ramp WITH OPTIONS, where on your Input V instead of Particle's Age you map "lifespan PP".

6. Try setting your ramp with some white at the top, with black everywhere else (mostly black).

So here's what should happen. As your particles die, they should emit other particles. You would change all this attributes to suit your project.


Good luck.

This is usually the firework's trick, where particles are spawn as original particles die...

charlJoubert
11-17-2008, 05:28 PM
Hi there. I've also been trying to achieve this effect. I followed your instructions to the T more than once and I get the same problem...

My main particles don't die. At all! The secondary particles are emitting where I assume the primary ones need to die... but the continue into the abbys :P

Aikiman
11-18-2008, 05:39 AM
Hi Untelon,

How do you emit more than one particle? I cant seem to adjust the emission rate for the second particle shape.

cheers

ovspianist
11-18-2008, 08:21 AM
adjusting the max value of the arraymapper should work.

charlJoubert
11-18-2008, 09:19 AM
I tried faffing with the array but it still didn't die.

Aikiman
11-18-2008, 09:41 AM
adjusting the max value of the arraymapper should work.

Ah that works, the only thing is I get the same effect if I just use 'emit from object' in which case why bother with per point emissions? I also cant seem to control the emission at the end of the lifespan, am I missing something here?

@ charlJoubert, have you set your lifespan to lifespanPP? If so you need to create a creation expression.

ovspianist
11-18-2008, 10:33 AM
Ah that works, the only thing is I get the same effect if I just use 'emit from object' in which case why bother with per point emissions? I also cant seem to control the emission at the end of the lifespan, am I missing something here?

@ charlJoubert, have you set your lifespan to lifespanPP? If so you need to create a creation expression.


the per-particles emission is really needed if you want to control the particle emission action in per-particle basis, because you emit the particles with first particle shape and using omni type, you have to switch on per point emission rate. It treats every individual particle as a point. You can control the lifespan with lifespanPP attribute, but remember to turn on "lifespanPP Only". To control the emission, tweak the ramp on the ratePP attribute.

Aikiman
11-18-2008, 07:52 PM
the per-particles emission is really needed if you want to control the particle emission action in per-particle basis, because you emit the particles with first particle shape and using omni type, you have to switch on per point emission rate. It treats every individual particle as a point. You can control the lifespan with lifespanPP attribute, but remember to turn on "lifespanPP Only". To control the emission, tweak the ramp on the ratePP attribute.

Okay.....firstly by placing the white color chip at top of ramp does not work, I am not getting any emission at time of death of particle1. By swapping the color chip to black I get full emission from birth to death which is why I mentioned that just using 'emit from object' does the same thing. So I follow the example and leave the ramp mostly black with a little white at the top, but instead set the min value on the array mapper to 50 and max to zero. As you can imagine I get the same effect as before. Still no emission at death of particle1, I assume I am STILL missing something here. :)

ovspianist
11-19-2008, 06:02 AM
Okay.....firstly by placing the white color chip at top of ramp does not work, I am not getting any emission at time of death of particle1. By swapping the color chip to black I get full emission from birth to death which is why I mentioned that just using 'emit from object' does the same thing. So I follow the example and leave the ramp mostly black with a little white at the top, but instead set the min value on the array mapper to 50 and max to zero. As you can imagine I get the same effect as before. Still no emission at death of particle1, I assume I am STILL missing something here. :)

You "set the min value on the array mapper to 50 and max to zero" is not a usual way to do this, I haven't tried yet. But I suggest you that you reset all your emitter creating option before you emit from the particle1.
This leads to a basic tutorial of particles, which you may find them on the internet, the tut is basically explaining how to create fireworks.
By the way, I usually set the min value to 0 and max to 4000(maybe 50 is way too low), and the ramp is all black except white tip on the top.
Hope it helps.

frogspasm
11-19-2008, 07:15 AM
Going back to MEL commands... I had never used the emit function (that I can remember) until a few days ago, and wanted to find out how it worked. So, expanding on Aikiman's original answer, here's how I would do it:

1. Create a particle emitter. Set it's lifespan to something shorter than forever.
2. Create a second (empty) particle object by entering the "particle;" function.
3. Use the following MEL in the runtime expression of the first particle object:

if (particleShape1.age >= particleShape1.lifespanPP)
{
vector $pos = particleShape1.position;
float $randBurst = rand(10,50);
for ($i = 0; $i<$randBurst;$i++)
{
vector $randVel = 3*rand(<<-1,-1,-1>>,<<1,1,1>>);
emit -o particle2
-position ($pos.x) ($pos.y) ($pos.z)
-at velocity
-vv ($randVel.x) ($randVel.y) ($randVel.z);
};
};
This will check to see if any of the particles in the first particle object have come to the end of their lifespan, and if they have, emits a random burst of between 10-50 particles in a random direction at the location of their deaths.

charlJoubert
12-01-2008, 02:51 PM
@ Frogspasm...

Cool thanks... I got to step 3 and that's where I drew a blank...

I don't know where the Runtime Expression is. I've rightclicked in that bit where you can add PP stuff... where you can also add General, Opacity and... uh... something else I forget the button, to the per particle attributes. I've found a place where I can add a runtime expression before and after dynamics but neither works. I'm obviously looking in the wrong place aren't I?

frogspasm
12-01-2008, 05:59 PM
Nope, you're in the right spot.
You want to paste that code into the Runtime Before Dynamics expression window, then hit the "Create" button at the bottom of the expression editor.

If that doesn't work, post your scene and I'll have a look.

-heavy-
12-01-2008, 07:14 PM
And now, back again to the non-mel Method ;)

here is a scene a created a while ago with a small fireworks setup, i deleted the unnecessary
stuff - hey Aiki if your setup is already not workin take a look at the ptkl_groundburst object here:

www.zipl.de/simplesetup.mb (http://www.zipl.de/simplesetup.mb)

its based on what is described before,
create Emitter -> select the Particles -> set lifespan to 2 or smth -> emit from Obj -> than
use ppEmission rates and create a Ramp on Emitter Rate X PP -> adjust max in the Array Mapper,
cuz this is the "how many prtkl should be emitted" slider and make sure the small
black stripe is at the Point where the particles should be emitted..

its very simple if smbdy dont want to script and for me i have much more control
over the system, maybe can set a new burst of particle at the middle of the lifespan
easiliy by inserting a new black strip in the middle of the ramp. e Voila.

charlJoubert
12-03-2008, 01:52 PM
@ Heavy:

Hey that worked. I don't know why it didn't work before. But it worked now.

@ Frogspasm:

At some stage I'll try your way again and see if I can get it right. If not I'll post it up. I'd like to know both ways but Heavy's way works for now :)

Thanks guys!!

CGTalk Moderation
12-03-2008, 01:52 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.