# 3D Theory - Programming Particle Systems

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.

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

If you are interested in 3D games, this looks like a good book to have on the shelf. If, like me, you want to have know the theory and how it is derived then there is a lot for you here. Including - Graphics pipeline, scenegraph, picking, collision detection, bezier curves, surfaces, key frame animation, level of detail, terrain, quadtrees & octtrees, special effects, numerical methods. Includes CDROM with code.

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to this site, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 Dark Basic Professional Edition - It is better to get this professional edition This is a version of basic designed for building games, for example to rotate a cube you might do the following: make object cube 1,100 for x=1 to 360 rotate object 1,x,x,0 next x Game Programming with Darkbasic - book for above software

This site may have errors. Don't use for critical systems.