Particle System - Rigid Bodies
Particle system algorithm:
This example shows a simple particle system where each particle is represented by a rigid body with a rotation and an angular velocity:- remove rigid bodies with age > max. life time
- generate new rigid bodies by emitters
- compute forces for all rigid bodies
- time integration to get new rigid body positions, rotations and velocities
1. Remove rigid bodies with age > max. life time
The life time of each rigid body is set to 0 when a rigid body is generated. In each simulation step the life time is increased by the time step size $\Delta t$. When a rigid body's life time is greater than a predefined maximum life time, the rigid body is removed from the simulation.
Note that the life time can be used for rendering effects. In our case the transparency is increased depending on the life time to fade out the rigid bodies.
2. Generate new rigid bodies by emitters
In each simulation step new rigid bodies are generated at the position of the emitter. Typically they are initialized with some predefined values and sometimes some random values are added to obtain more natural results.
In our simulation the rigid bodies are generated with a velocity pointing upwards. Moreover, the velocity in x- and y-direction is modified by some random values. The starting position of the body is at the emitter and it has a random rotation and angular velocity.
3. Compute forces for all rigid bodies
In each step forces are determined for the rigid bodies, e.g. gravity, wind etc. In our simple example only gravity is applied.