This project is read-only.

The way of calculating physical parameters (position, velocity, ...) of the particles is described here.

Particle properties

A particle has these "physical" properties:

  • position: Position of the particle.
  • velocity: Velocity (speed) of the particle.
  • angle: A rotation value for the particle. This is (currently) stored as three angles to rotate around the X, Y and Z axes consecutively. (The osgParticle class which is the base of this code uses these too.) The "angle" means here three values together.
  • angular_velocity: Change of the angle over time.
  • mass: Mass of the particle.
  • radius: Radius of the particle.

The particles are treated as if they were spheres with the specific radius and with the specific mass. The sphere is placed at position and rotated by angle. It is moving with the speed of velocity and rotating by angular_velocity. The mass is calculated from the density parameter of ParticleTemplate and from the current radius by taking the mass of a sphere with that radius and of that density. The mass is used to calculate gravitation. The mass and radius values are used to calculate a "fluid friction" too. The code to do this is taken from OpenSceneGraph class osgParticle::FluidFrictionOperator, with parameters set to values for "air". A wind value is used too which is set globally for the animation (this can be changed over time but the same value is used regardless of position).


When an emitter is triggered to create new particles it gets the "inherited" values from its parent object (a particle or some other). The emitter parameters position, angle, angluar_velocity and scale are used. At triggering the set of particle parameters is generated. These are passed to a new particle or towards another emitter.

The new position is the same as the inherited position. (The position parameter is used in other way.) The new velocity is got by taking the inherited angle value, transforming (rotating) the position parameter by this angle, then multiplying it with the scale parameter. This is added to the inherited velocity. This calculation is possibly not totally accurate because the inherited angular velocity is not taken into account but should be OK for now. The new angle is the inherited angle and the angle values added. New angular velocity is the angular_velocity parameter.

The model for this is that an emitter defines a "shell" or "bomb" object. This means a sphere that is positioned in exactly the same way as the parent particle. The new parameters are coming from by exploding this sphere. The position means where the point inside the sphere lies. This is used to create new particles, so it can be modeled as if at that position another sphere would exist, the new particle. This other sphere is placed at that position and with given angle, and will get the initial angular velocity. The scale parameter can be used to define the strength of the explosion (actually specifying a lengthly position vector has the same value as using a large scale value). It is an abstraction that if a particle uses multiple emitters all of these are placed at the same position as the particle itself.

Last edited Dec 23, 2010 at 7:07 PM by fruitfruit, version 3


No comments yet.