This is a good way to render physical effects like smoke, fire, explosions, fluids, etc. See:
A particle system is a collection of independent points, which are animated
using a set of rules, with the intention of
modeling some effect..
These points are assigned attributes, and animated over time. Common characteristics for a particle are:
- Position
- Velocity
- Energy
- Colour - could also add transparency
- Lifetime - how long before it self distructs
As the animation progresses, these characteristics change. For example, at time = 0, a particle may have a very high velocity, and a lot of energy. As time progresses, this velocity and energy will decrease, and its path will change.
Defining Dynamic Rules For Particles
Set up particle
While Animation In Progress
If Particle Not Dead Then
Add Particle Direction * Speed To Particle Position
Add Particle Acceleration To Particle Speed
Modify Particles Speed
Modify Particles Energy
If Particles Energy < Threshold Then
Mark Particle As Dead
End If
If Particle Hits Object Then
Modify Particles Position, Direction, Speed and Energy
End If
Display Particle
End If
End While
Particle life cycle
Particles are born, move somewhere and then die
Particle Emitter
This is where the particles are created, the emitter controls the initial values for the particle, also the rate at which the particles are created.
Particle Collector
In most cases particles spreadout, for instance, explosions. But in some cases we may want the particles to be killed off, when they reach a certain area of space.
Particle attractor
This could be a way to define the behavior graphically, instead of having to define an algorithm to specify the path, you could place attractors and repellers around to give the desired motion.
Particle repeller
As for 'particle attractor' but repellers instead of attracts
Particle force field
Fountains etc.need to have particles accelerated under the influence of gravity.
Effects to customise particles for different applications
- Make a particle illuminate its environment - fire effect, spark shower, etc.
- make each particle a deferent colour
- transparency - for fog etc.
- change colour over time - explosion/fire gets colder on outside.
- make a trail from each particle - motion effect
- blur the particle - makes the effect look more organic
- add a random element to the path - also makes the effect look more organic
Explosions
Explosions are one of the easier, and most impressive things to model using particle systems. To do an explosion, we generally set all particles to have some common point of origin, either a single, finite point, or randomly
Implementing in Java3D
To render "fuzzy" points using Java3D antialiased large points make good primitive's.
Billboards are one way to render "fuzzy particles" but there are
two
alternatives which should be faster:
1) Large, anti-aliased points. These should be the fastest, but
there may be problems with inconsistent rendering on different
OpenGL implementations
2) OrientedShape3Ds. These are new in J3D 1.2 beta1 and should be
faster than using Billboards since the orientation is managed by
J3D "directly" rather than through a Behavior.
Performance:
Since there is an overhead in the creation/garbage-collect cycle, it may be better for the program to maintain a pool of particles so that they can be continually recycled without this overhead.