cParticle Struct Reference

#include <cParticle.h>

Inheritance diagram for cParticle:
cObject::rTraceable

List of all members.

Public Member Functions

 cParticle (cParticle *original)
void applyGravityForce (float *gravity_m_per_s)
 Apply gravity to the particle's force, eg with float g[] = {0,-9.8f,0}.
void applyFrictionForce (float dt)
 Apply fake friction based on velocity and mass.
void applyAirdragForce (float density_kg_per_m3=1.204f)
 Apply billboard airdrag based on front surface area and cw-value.
void stepEuler (float dt, float damping=0.01f)
void stepVerlet (float dt_inv, float dt2, float damping=0.01f)

Static Public Member Functions

static void stepEuler (float *pos, float *old, float *vel, float *fce, float mass_inv, float dt, float damping=0.01f)
static void stepVerlet (float *pos, float *old, float *vel, float *fce, float mass_inv, float dt_inv, float dt2, float damping=0.01f)
static float collideParticleWithSphere (float *particle3fv, float *center3fv, float radius, float *projection3fv)
static float collideParticleWithCylinder (float *particle3fv, float *base3fv, float radius, float height, float *projection3fv)
static float collideParticleWithAABB (float *particle3fv, float *min3fv, float *max3fv, float *projection3fv)

Public Attributes

std::vector< float > ori
 Particle orientation quaternion - may use as euler.
std::vector< float > pos
 Particle position vector.
std::vector< float > old
 Particle old position vector.
std::vector< float > vel
 Particle velocity vector.
std::vector< float > fce
 Particle force accumulation vector.
float mass
 Particle mass.
float mass_inv
 The inverse of the particle mass is often neccessary.
float friction
 Set when having contact according to contact-depth and material.
float cwm2
 CW coefficient times area in m2 for calculating air-drag.
float fuel
 Remaining fuel in seconds.
float timer
 Time since start.
float spawn
 Countdown til spawning next Smoke-Particle.
OID target
 Object-ID of Particle target - attraction object or evasion.
float radius
 Abstract dimension of Particle by sphere radius.
unsigned int sound
 A sound-source-id just in case this particle emits sound.
unsigned int texture
 A texture-id when a particle has an individual texture.
int type
 User-type specifier or flags, program defines behavior and shape.
void * data
 Specific user-data - eg billboard text, color curves, object, etc.
std::list< cParticle * > trail
 Recursive sub Particles - or trail of particles.

Detailed Description

A Particle can be anything from bullets over flares to smoke. It has a position and a velocity. Besides it has a lifetime countdown (fuel), a time in existence timer and a spawn countdown which is for spawning particle offspring. A particle can have a trail consisting of other particles like smoke or other recursive systems (in this context I hereby coin the term Particle-Tree ;). Note: There are ways to produces trees (plants) using particle systems but that's another story.


Member Function Documentation

static void cParticle::stepEuler ( float *  pos,
float *  old,
float *  vel,
float *  fce,
float  mass_inv,
float  dt,
float  damping = 0.01f 
) [inline, static]

Euler integration works by integrating force to velocity and then further into position which is stored in old position beforehand. It is fast and not bad but poses problems when the particle position needs to be adjusted due to collisions because current velocity needs to be adjusted, too. It may be ok for elastic particles but for non-elastic particles verlet integration is simpler.

Parameters:
pos current and then derived particle position (3fv).
old memory for the next previous particle position (3fv).
vel current particle velocity (3fv).
fce current applied force (3fv).
dt the elapsed time.
damping pseudo damping factor within [0,1], typically very small.
void cParticle::stepEuler ( float  dt,
float  damping = 0.01f 
) [inline]

Euler integration works by integrating force to velocity and then further into position which is stored in old position beforehand. It is fast and not bad but poses problems when the particle position needs to be adjusted due to collisions because current velocity needs to be adjusted, too. It may be ok for elastic particles but for non-elastic particles verlet integration is simpler.

Parameters:
dt the elapsed time.
damping pseudo damping factor within [0,1], typically very small.
static void cParticle::stepVerlet ( float *  pos,
float *  old,
float *  vel,
float *  fce,
float  mass_inv,
float  dt_inv,
float  dt2,
float  damping = 0.01f 
) [inline, static]

Verlet integration derives the new position from the old position the current position and force applied. Velocity is thus implicitly used and is derived. Non-elastic collision correction is a snap - just adjust the position.

Parameters:
pos current particle position (3fv).
old previous particle position (3fv).
vel memory for derived velocity (3fv).
fce current applied force (3fv).
dt_inv inverse of the elapsed time.
dt2 square of the elapsed time.
damping pseudo damping factor within [0,1], typically very small.
void cParticle::stepVerlet ( float  dt_inv,
float  dt2,
float  damping = 0.01f 
) [inline]

Verlet integration derives the new position from the old position the current position and force applied. Velocity is thus implicitly used and is derived. Non-elastic collision correction is a snap - just adjust the position.

Parameters:
dt_inv inverse of the elapsed time.
dt2 square of the elapsed time.
damping pseudo damping factor within [0,1], typically very small.

The documentation for this struct was generated from the following file:

Generated on Tue Feb 16 18:32:39 2010 for Linwarrior 3D by  doxygen 1.6.1