Stop particles emitters

What it says on the tin: a place to discuss proposed new features.
Post Reply
bcsanches
Kobold
Posts: 39
Joined: Tue Dec 23, 2008 9:55 pm
x 5

Stop particles emitters

Post by bcsanches »

Hi folks,

I am using Ogre for some time and now I am starting to use the particle systems. On my game here, I attached a particle system to some platforms to simulate fire, but I want to disable it.

The way that I have found was to remove the objectparticle system from the scene node. This works, but the particles simple disappears.

I did a change on Ogre to include a mEmitting boolean variable that I can use to control if the particle system should emit or not the particles. This is cool because this lets the particles disappears during their normal life time.

I am thinking about sending a patch with this change, but I would like to know what the community think about this.
User avatar
Praetor
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3335
Joined: Tue Jun 21, 2005 8:26 pm
Location: Rochester, New York, US
x 3
Contact:

Post by Praetor »

This is probably poorly documented. The question comes up a lot. Set the emitter parameter emission_rate to 0 to stop the emitter from emitting new particles. Later, just reset it to its normal value and it will start emitting again.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Would probably be a good idea to add a convenience function, then? :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Post by Kojack »

The problem with using emission rate is that a particle system could:
- have several emitters
- have different emission rates for each emitter

so to turn a system off and on you need to loop through all emitters, save their current values, set them to zero, then later loop through them all and restore the values.
It would be much easier to just have a bool in the particle system or a bool per emitter to turn them on and off without wiping the script defined emission rate.
bcsanches
Kobold
Posts: 39
Joined: Tue Dec 23, 2008 9:55 pm
x 5

Re: Stop particles emitters

Post by bcsanches »

I actually used this technique of running across all emitters and setting emission rate for each one to zero. This works, but we need to store this value somewhere and restore it back, this gets a bit complicated when we have several emitters on the same system

if my change, I just added a boolean attribute to the PartycleSystem class and on it main loop, if just checks if it should calls triggerEmitters or not.

Cheers
Bruno Sanches
SpaceKitty
Gnoblar
Posts: 1
Joined: Thu Nov 14, 2013 7:21 am
x 1

Re: Stop particles emitters

Post by SpaceKitty »

Incase anyone sees this post now, setEmitting is now a function of particle systems, this can be used to make a particle system start and stop emitting particles without hiding all particles or changing the emission_rate to 0
bcsanches
Kobold
Posts: 39
Joined: Tue Dec 23, 2008 9:55 pm
x 5

Re: Stop particles emitters

Post by bcsanches »

Thanks SpaceKitty!
Post Reply