Various effects that use particle systems such as fire, smoke and sparkles were
implemented using different types of primitives.
The particles can change size and position with the mouse and the keyboard and they can
have different colors and textures. The user can select the effect to display
(fire, smoke or fireworks).
A particle system has to spawn particles with a certain lifetime and simulate
their evolution until their death. Therefore, it was
necessary to have a method to count the time passed while the particle system
is working and simulate each particle's life. Each particle has a "birth" time
as well as a lifetime (time to live). Everytime that a new frame is created,
a simulate function is called for each particle several times. The number of
times it will be called depends on a preset interval. If for example the
difference between the timestamps of the frames is N times the interval the simulate
function will be called N times. If the lifetime of a particle is completed, the particle
is removed by the system.
Particle System's Update and Rendering:
An update and a rendering function were used in order to evolve and render
the particles. The update function performs the
following three basic operations:
Spawn: It spawns a number of particles (given as a parameter to the
system). The particles initially have a random position inside a cone of
a certain angle (the angle is a particle system parameter).
Death: It checks which particles have exceeded the lifetime interval and
it destroys them. The lifetime is a particle system parameter, not always
5 sec because different particle systems look more realistic with different
Simulation: It calculates each particle's velocity and position according
to the time. The explicit Euler's integration scheme is used to calculate
the new position and the new velocity.
The rendering function, simply renders each particle in its new position with
its new color (if motion blur, additive blender etc are used) or its texture.
Motion Blur, Additive Blender, Mouse and Keyboard Control:
When lines are used as primitives, motion blur is applied. Also additive
blender is used for particle systems with quad primitives.The particles can
change position and move to a certain direction with the mouse when the button
CTRL is pressed. They change also in size while moving. By pressing the
right and left arrow you can see different types of particles that were
implemented (in this case smoke, fire and sparkles).
The code can be downloaded from here.
To run it on linux
untar, cd the psys directory, type make and run: