Enhancement: Particles

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5433
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1341

Enhancement: Particles

Post by dark_sylinc »

This time is a small enhancement. But again, it's a very powerful one. ParticleUniverse had something similar but I found it very unflexible. Plus, in this project I'm working on, I don't have PU.
Particle emitters now have the "direction_position_reference" parameter.

From the manual:

Code: Select all

format: direction_position_reference <x> <y> <z> <enable>
example: direction_position_reference 0 -10 0 1
default: direction_position_reference 0 0 0 0
Use 1 to enable, 0 to disable.

When enabled, the direction of particles is calculated as (positionReference - positionOfParticleAtEmission).
This image ilustrates the case in 2D:
ParticleExample.png
This is excellent for simulating explosions (velocity > 0) or implosions (velocity < 0) when the position reference is in the center. Without this enhancements, one could do this with point emitters setting angle to 180; however when using other types of emitters (Ellipsoid, box, ring, etc) this was a seemingly impossible task because the direction was completely random at angle 180, rather than being consistent to a single point of origin, or "source".

When the position ref. is below the emitters, it can be used to simulate dust stomps in the ground. I've made one in my own game that looks amazing (can't share the picture yet, sorry guys; demo was submitted to Intel Level Up contest).
When position ref. is on the side of the emitters, it can be used for simulating wind coming from a fan.

I hope you enjoy it.
Cheers
Dark Sylinc

PS: I thoroughly tested this enhancement as I wrote it a month ago, but just submitted right now.

@Spookyboo:
Your PU system will probably need a few small changes in order to compile again. Changes are really small so it shouldn't be much of a problem. Basically "genEmissionDirection" now requires a second additional parameter, containing the particle's position.
You do not have the required permissions to view the files attached to this post.
User avatar
fractile
Gremlin
Posts: 199
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
x 15

Re: Enhancement: Particles

Post by fractile »

Where is this documented? At least not here: http://www.ogre3d.org/docs/manual/manua ... Attributes

I have been struggling with particle effects for years not knowing something like this exists. This makes everything so much easier!