My vsge game engine uses a node based graphics engine. This makes parenting really easy for example. Entities of the game engine own a graphics node and update it’s transform, so they can be displayed to the screen easily.
Calling the nodes drawing procedures is handled by the graphics engine and Nodes draw their children.
- Node based Particle System -
Now how would a particle system fit into the node based graphics? I found a solution that uses the advantages of nodes and works pretty fine up till now. I divided the particle area in the following classes:
- ParticleNode: An graphics node which isn’t actually visible, but handles lifetime of an particle and so on. For actually drawing a bitmap or similar to the screen, I would add a SpriteNode or something like that to the ParticleNodes children.
- ParticleEmitterNode: This graphics node can spawn particles, setting their initial transform. This makes it possible to create them at a certain position for example.
- ParticleSystemNode: the graphics node that handles all the particles as own children. This makes them independent from the emitters position, so if the emitter moves, the particles wont all move with it. ParticleSystemNode also applies the ParticleAffectors before the particles are drawn.
- ParticleAffector: this is not a graphics node like the other parts of the particle system. This class can change a particles attributes as wished. You could add a GravityParticleAffector for instance, which changes the transform for example.
- My Progress -
I almost got this system implemented and it works great so far. What I am at right now is getting the time stuff to work. I will probably put a time variable in the Kernel or so, if Allegro 5 doesn’t have one already. :)
This post was imported from tumblr