what kinds of control would you want in a particle system

Started by
5 comments, last by slayemin 12 years, 11 months ago
I'm refactoring my particle system to make it more compatible with my current project and it got me thinking what kind of controls would others want, what kinda ideas have I not thought of. Make note, this system is completely 2D except for the use of depth to sort images when rendering, here is the list of what is already implemented, and the few changes I will be making... feel free to add to the list, like a community brainstorm :blink:

Movement
starting velocity
acceleration of velocity over time
damping of velocity over time
rotation around given origin.
direction rotation over time.

Size
starting size
expansion of size over time
contracting size over time

Emitter
position and boundary particles can be emitted from
depth particles can be emitted from
how fast particles are emitted
amount of particles to emit on each emission
lifetime of particles, this can be infinite for particles that don't die.

Graphics
Starting color
list of colors to fade to over time, and in order they are loaded.
use single or multiple sprites, with multiple sprites, particle will randomly be assigned a sprite whenever they are re spawned.

new changes need for current project
use animations instead of static sprite for particles.
boundary that particles must stay within or they automatically die.
gravity, or external force like wind. and possible allow multiples of them.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Advertisement
When I wrote my particle emitter, I found it was most helpful to try to create a fire works show. Here's some suggestions you may want to consider:

-Emitters should be able to emit emitters (No limit on depth)
-You should be able to use primitives or sprites
-You'll want to specify alpha transparencies for particles
-Emitters should be able to move

Here's a simple demo of my particle system

When I wrote my particle emitter, I found it was most helpful to try to create a fire works show. Here's some suggestions you may want to consider:

-Emitters should be able to emit emitters (No limit on depth)
-You should be able to use primitives or sprites
-You'll want to specify alpha transparencies for particles
-Emitters should be able to move

Here's a simple demo of my particle system


Interesting I'm surprised I never thought of having emitters emit emitters. Do you consider all your particles as emitters, and emitters as particles... ie are they derived from the same object?

Alpha transparency is controlled through the color values. These can be anything and can shuffle through any amount of colors as long as there is enough memory to store all the values... which is pretty much infinite. The way my framework works, being able to emit primitives instead of sprites (quads), work mean a refactoring of the base framework, but does sound tempting.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.

Interesting I'm surprised I never thought of having emitters emit emitters. Do you consider all your particles as emitters, and emitters as particles... ie are they derived from the same object?

Alpha transparency is controlled through the color values. These can be anything and can shuffle through any amount of colors as long as there is enough memory to store all the values... which is pretty much infinite. The way my framework works, being able to emit primitives instead of sprites (quads), work mean a refactoring of the base framework, but does sound tempting.


Here is a rough sketch of my class inheritance hierarchy. The names are probably not the best, but it's good enough for me.

TempImg.gif

I use a lot bit of polymorphism and the classes I left out are just manager classes which maintain memory pools for particles and emitters.

The "Emitter Object" has a ParticleBase object which can be cast into either a particle or an emitter. Emitters are just manager classes which create "Emitter Objects"


class EmitterObject
{
Vector2 m_emissionVelocity; //this is the velocity applied to all emitted objects
Range m_emissionSpeed;
Range m_emissionDirection; //the direction objects are being emitted (Radians)
Range m_emissionSpread; //how much variance you have in the emission direction (Radians)

int m_emissionCount; //how many objects will be emitted during the emission cycle
ParticleBase m_emissionObject; //this is the generic object our emitter will emit

int m_emissionDelay; //how long to wait before emitting objects
int m_emissionPeriod; //how much time must elapse before next particle is sent out
int m_nextEmissionTime; //the next point in time in which we emit our objects
Color m_color; //the color applied to the objects being emitted
....
}


My base particle class also has a function pointer which lets the user specify the mathematical function to use for alpha transparency (constant, linear decay, exponential decay, gaussian, etc).

My reasoning for including primitive particles with sprite particles is because I've seen some interesting effects being done with primitives as particles... Pixels are very versatile and very fast to draw. Lots of small triangles can make some convincing fire effects. Connected line segments can be used for simulating streaks of shrapnel in an explosion (and the alpha decay ties in nicely here).
Would it be possible to see the source to your particle system? Just that little snippet already gave me a few ideas on how i could improve mine... some embarrassingly better.
[ dev journal ]
[ current projects' videos ]
[ Zolo Project ]
I'm not mean, I just like to get to the point.
Prototype system works wonders. My Example. (Right click to view the javascript). Needless to say the best way to create a particle system is to create a list of scenarios that you can use as requirements. Fireworks is probably one of the best examples of that as mentioned. Defining splines is probably a good idea along with random splines where the random variables are defined in the prototype. Including scripting into the system is ideal.

Include cases that can simulate an emitter with a delay being launched into the air that leaves a trail of both smoke and sparks.
Sure. Here's my code. It could stand to use a bit of improvement and streamlining, but I got lazy :P

--Particle System Classes--
Emitter.cs
EmitterObject.cs
Particle.cs
ParticleBase.cs
ParticleSystem.cs
PrimitiveParticle.cs
SpriteParticle.cs

--Helper Class from my library--
Range.cs

To instantiate this, I have to create emitters and assign emitter objects to them, and then create the particle which gets emitted. It's kind of a pain in the ass at the moment and a bit cumbersome to use. Ideally, I'd like to just define my particle and emitter structures in nested XML tags stored on an external file so that I don't have to hard code any of it. Maybe when I get less lazy I'll do that and do it in a generic way such that it can be dropped into a library and used in any game :P

Anyways, this should give you plenty of fuel to inspire your own implementation. Since I made this public, feel free to copy as much as you want. You don't have to credit me.

This topic is closed to new replies.

Advertisement