OpenSceneGraph 2.8.4
Public Types | Public Member Functions | Protected Attributes
osgParticle::Particle Class Reference

Implementation of a particle. More...

List of all members.

Public Types

enum  { INVALID_INDEX = -1 }
enum  Shape {
  POINT, QUAD, QUAD_TRIANGLESTRIP, HEXAGON,
  LINE
}
 Shape of particles. More...

Public Member Functions

 Particle ()
Shape getShape () const
 Get the shape of the particle.
void setShape (Shape s)
 Set the shape of the particle.
bool isAlive () const
 Get whether the particle is still alive.
double getLifeTime () const
 Get the life time of the particle (in seconds).
double getAge () const
 Get the age of the particle (in seconds).
const rangefgetSizeRange () const
 Get the minimum and maximum values for polygon size.
const rangefgetAlphaRange () const
 Get the minimum and maximum values for alpha.
const rangev4getColorRange () const
 Get the minimum and maximum values for color.
const InterpolatorgetSizeInterpolator () const
 Get the interpolator for computing the size of polygons.
const InterpolatorgetAlphaInterpolator () const
 Get the interpolator for computing alpha values.
const InterpolatorgetColorInterpolator () const
 Get the interpolator for computing color values.
float getRadius () const
 Get the physical radius of the particle.
float getMass () const
 Get the mass of the particle.
float getMassInv () const
 Get 1 / getMass().
const osg::Vec3getPosition () const
 Get the position vector.
const osg::Vec3getVelocity () const
 Get the velocity vector.
const osg::Vec3getPreviousPosition () const
 Get the previous position (the position before last update).
const osg::Vec3getAngle () const
 Get the angle vector.
const osg::Vec3getAngularVelocity () const
 Get the rotational velocity vector.
const osg::Vec3getPreviousAngle () const
 Get the previous angle vector.
const osg::Vec4getCurrentColor () const
 Get the current color.
float getCurrentAlpha () const
 Get the current alpha.
const float getSTexCoord () const
 Get the s texture coordinate of the bottom left of the particle.
float getTCoord () const
 Get the t texture coordinate of the bottom left of the particle.
int getTileS () const
 Get width of texture tile.
int getTileT () const
 Get height of texture tile.
int getNumTiles () const
 Get number of texture tiles.
void kill ()
 Kill the particle on next update NOTE: after calling this function, the isAlive() method will still return true until the particle is updated again.
void setLifeTime (double t)
 Set the life time of the particle.
void setSizeRange (const rangef &r)
 Set the minimum and maximum values for polygon size.
void setAlphaRange (const rangef &r)
 Set the minimum and maximum values for alpha.
void setColorRange (const rangev4 &r)
 Set the minimum and maximum values for color.
void setSizeInterpolator (Interpolator *ri)
 Set the interpolator for computing size values.
void setAlphaInterpolator (Interpolator *ai)
 Set the interpolator for computing alpha values.
void setColorInterpolator (Interpolator *ci)
 Set the interpolator for computing color values.
void setRadius (float r)
 Set the physical radius of the particle.
void setMass (float m)
 Set the mass of the particle.
void setPosition (const osg::Vec3 &p)
 Set the position vector.
void setVelocity (const osg::Vec3 &v)
 Set the velocity vector.
void addVelocity (const osg::Vec3 &dv)
 Add a vector to the velocity vector.
void transformPositionVelocity (const osg::Matrix &xform)
 Transform position and velocity vectors by a matrix.
void transformPositionVelocity (const osg::Matrix &xform1, const osg::Matrix &xform2, float r)
 Transform position and velocity vectors by a combination of two matrices.
void setAngle (const osg::Vec3 &a)
 Set the angle vector.
void setAngularVelocity (const osg::Vec3 &v)
 Set the angular velocity vector.
void addAngularVelocity (const osg::Vec3 &dv)
 Add a vector to the angular velocity vector.
void transformAngleVelocity (const osg::Matrix &xform)
 Transform angle and angularVelocity vectors by a matrix.
bool update (double dt)
 Update the particle (don't call this method manually).
void beginRender () const
 Perform some pre-rendering tasks. Called automatically by particle systems.
void render (const osg::Vec3 &xpos, const osg::Vec3 &px, const osg::Vec3 &py, float scale=1.0f) const
 Render the particle. Called automatically by particle systems.
void endRender () const
 Perform some post-rendering tasks. Called automatically by particle systems.
float getCurrentSize () const
 Get the current (interpolated) polygon size. Valid only after the first call to update().
void setTextureTile (int sTile, int tTile, int numTiles=0)
 Specify how the particle texture is tiled.
void setPreviousParticle (int previous)
 Set the previous particle.
int getPreviousParticle () const
 Get the previous particle.
void setNextParticle (int next)
 Set the next particle.
int getNextParticle () const
 Get the const next particle.
void setUpTexCoordsAsPartOfConnectedParticleSystem (ParticleSystem *ps)
 Method for initializing a particles texture coords as part of a connected particle system.

Protected Attributes

Shape _shape
rangef _sr
rangef _ar
rangev4 _cr
osg::ref_ptr< Interpolator_si
osg::ref_ptr< Interpolator_ai
osg::ref_ptr< Interpolator_ci
bool _alive
bool _mustdie
double _lifeTime
float _radius
float _mass
float _massinv
osg::Vec3 _prev_pos
osg::Vec3 _position
osg::Vec3 _velocity
osg::Vec3 _prev_angle
osg::Vec3 _angle
osg::Vec3 _angul_arvel
double _t0
float _current_size
float _current_alpha
osg::Vec4 _current_color
float _s_tile
float _t_tile
int _num_tile
int _cur_tile
float _s_coord
float _t_coord
int _previousParticle
int _nextParticle

Detailed Description

Implementation of a particle.

Objects of this class are particles, they have some graphical properties and some physical properties. Particles are created by emitters and then placed into Particle Systems, where they live and get updated at each frame. Particles can either live forever (lifeTime < 0), or die after a specified time (lifeTime >= 0). For each property which is defined as a range of values, a "current" value will be evaluated at each frame by interpolating the min and max values so that curr_value = min when t == 0, and curr_value = max when t == lifeTime. You may customize the interpolator objects to achieve any kind of transition. If you want the particle to live forever, set its lifetime to any value <= 0; in that case, no interpolation is done to compute real-time properties, and only minimum values are used.


Member Enumeration Documentation

anonymous enum
Enumerator:
INVALID_INDEX 

Shape of particles.

NOTE: the LINE shape should be used in conjunction with FIXED alignment mode (see ParticleSystem).

Enumerator:
POINT 
QUAD 
QUAD_TRIANGLESTRIP 
HEXAGON 
LINE 

Constructor & Destructor Documentation

osgParticle::Particle::Particle ( )

Member Function Documentation

void osgParticle::Particle::addAngularVelocity ( const osg::Vec3 dv) [inline]

Add a vector to the angular velocity vector.

References _angul_arvel.

Referenced by osgParticle::AngularAccelOperator::operate().

void osgParticle::Particle::addVelocity ( const osg::Vec3 dv) [inline]

Add a vector to the velocity vector.

References _velocity.

Referenced by osgParticle::ForceOperator::operate(), and osgParticle::AccelOperator::operate().

void osgParticle::Particle::beginRender ( ) const [inline]

Perform some pre-rendering tasks. Called automatically by particle systems.

References _shape, LINE, POINT, and QUAD.

void osgParticle::Particle::endRender ( ) const [inline]

Perform some post-rendering tasks. Called automatically by particle systems.

References _shape, LINE, POINT, and QUAD.

double osgParticle::Particle::getAge ( ) const [inline]

Get the age of the particle (in seconds).

References _t0.

const Interpolator * osgParticle::Particle::getAlphaInterpolator ( ) const [inline]

Get the interpolator for computing alpha values.

References _ai, and osg::ref_ptr< T >::get().

const rangef & osgParticle::Particle::getAlphaRange ( ) const [inline]

Get the minimum and maximum values for alpha.

References _ar.

const osg::Vec3 & osgParticle::Particle::getAngle ( ) const [inline]

Get the angle vector.

References _angle.

const osg::Vec3 & osgParticle::Particle::getAngularVelocity ( ) const [inline]

Get the rotational velocity vector.

References _angul_arvel.

const Interpolator * osgParticle::Particle::getColorInterpolator ( ) const [inline]

Get the interpolator for computing color values.

References _ci, and osg::ref_ptr< T >::get().

const rangev4 & osgParticle::Particle::getColorRange ( ) const [inline]

Get the minimum and maximum values for color.

References _cr.

float osgParticle::Particle::getCurrentAlpha ( ) const [inline]

Get the current alpha.

const osg::Vec4& osgParticle::Particle::getCurrentColor ( ) const [inline]

Get the current color.

float osgParticle::Particle::getCurrentSize ( ) const [inline]

Get the current (interpolated) polygon size. Valid only after the first call to update().

References _current_size.

double osgParticle::Particle::getLifeTime ( ) const [inline]

Get the life time of the particle (in seconds).

References _lifeTime.

float osgParticle::Particle::getMass ( ) const [inline]

Get the mass of the particle.

For built-in operators to work correctly, remember that the mass is expressed in kg.

References _mass.

float osgParticle::Particle::getMassInv ( ) const [inline]

Get 1 / getMass().

References _massinv.

Referenced by osgParticle::ForceOperator::operate().

int osgParticle::Particle::getNextParticle ( ) const [inline]

Get the const next particle.

int osgParticle::Particle::getNumTiles ( ) const [inline]

Get number of texture tiles.

const osg::Vec3 & osgParticle::Particle::getPosition ( ) const [inline]

Get the position vector.

References _position.

const osg::Vec3 & osgParticle::Particle::getPreviousAngle ( ) const [inline]

Get the previous angle vector.

References _prev_angle.

int osgParticle::Particle::getPreviousParticle ( ) const [inline]

Get the previous particle.

const osg::Vec3 & osgParticle::Particle::getPreviousPosition ( ) const [inline]

Get the previous position (the position before last update).

References _prev_pos.

float osgParticle::Particle::getRadius ( ) const [inline]

Get the physical radius of the particle.

For built-in operators to work correctly, lengths must be expressed in meters.

References _radius.

Particle::Shape osgParticle::Particle::getShape ( ) const [inline]

Get the shape of the particle.

References _shape.

const Interpolator * osgParticle::Particle::getSizeInterpolator ( ) const [inline]

Get the interpolator for computing the size of polygons.

References _si, and osg::ref_ptr< T >::get().

const rangef & osgParticle::Particle::getSizeRange ( ) const [inline]

Get the minimum and maximum values for polygon size.

References _sr.

const float osgParticle::Particle::getSTexCoord ( ) const [inline]

Get the s texture coordinate of the bottom left of the particle.

float osgParticle::Particle::getTCoord ( ) const [inline]

Get the t texture coordinate of the bottom left of the particle.

int osgParticle::Particle::getTileS ( ) const [inline]

Get width of texture tile.

References _s_tile.

int osgParticle::Particle::getTileT ( ) const [inline]

Get height of texture tile.

References _t_tile.

const osg::Vec3 & osgParticle::Particle::getVelocity ( ) const [inline]

Get the velocity vector.

For built-in operators to work correctly, remember that velocity components are expressed in meters per second.

References _velocity.

bool osgParticle::Particle::isAlive ( ) const [inline]

Get whether the particle is still alive.

References _alive.

void osgParticle::Particle::kill ( ) [inline]

Kill the particle on next update NOTE: after calling this function, the isAlive() method will still return true until the particle is updated again.

References _mustdie.

void osgParticle::Particle::render ( const osg::Vec3 xpos,
const osg::Vec3 px,
const osg::Vec3 py,
float  scale = 1.0f 
) const

Render the particle. Called automatically by particle systems.

void osgParticle::Particle::setAlphaInterpolator ( Interpolator ai) [inline]

Set the interpolator for computing alpha values.

References _ai.

void osgParticle::Particle::setAlphaRange ( const rangef r) [inline]

Set the minimum and maximum values for alpha.

References _ar.

void osgParticle::Particle::setAngle ( const osg::Vec3 a) [inline]

Set the angle vector.

References _angle.

void osgParticle::Particle::setAngularVelocity ( const osg::Vec3 v) [inline]

Set the angular velocity vector.

Components x, y and z are angles of rotation around the respective axis (in radians).

References _angul_arvel.

Referenced by osgParticle::RadialShooter::shoot().

void osgParticle::Particle::setColorInterpolator ( Interpolator ci) [inline]

Set the interpolator for computing color values.

References _ci.

void osgParticle::Particle::setColorRange ( const rangev4 r) [inline]

Set the minimum and maximum values for color.

References _cr.

void osgParticle::Particle::setLifeTime ( double  t) [inline]

Set the life time of the particle.

References _lifeTime.

void osgParticle::Particle::setMass ( float  m) [inline]

Set the mass of the particle.

For built-in operators to work correctly, remember that the mass is expressed in kg.

References _mass, and _massinv.

void osgParticle::Particle::setNextParticle ( int  next) [inline]

Set the next particle.

void osgParticle::Particle::setPosition ( const osg::Vec3 p) [inline]
void osgParticle::Particle::setPreviousParticle ( int  previous) [inline]

Set the previous particle.

void osgParticle::Particle::setRadius ( float  r) [inline]

Set the physical radius of the particle.

For built-in operators to work correctly, lengths must be expressed in meters.

References _radius.

void osgParticle::Particle::setShape ( Shape  s) [inline]

Set the shape of the particle.

References _shape.

void osgParticle::Particle::setSizeInterpolator ( Interpolator ri) [inline]

Set the interpolator for computing size values.

References _si.

void osgParticle::Particle::setSizeRange ( const rangef r) [inline]

Set the minimum and maximum values for polygon size.

References _sr.

void osgParticle::Particle::setTextureTile ( int  sTile,
int  tTile,
int  numTiles = 0 
) [inline]

Specify how the particle texture is tiled.

References _num_tile, _s_tile, and _t_tile.

void osgParticle::Particle::setUpTexCoordsAsPartOfConnectedParticleSystem ( ParticleSystem ps)

Method for initializing a particles texture coords as part of a connected particle system.

void osgParticle::Particle::setVelocity ( const osg::Vec3 v) [inline]

Set the velocity vector.

For built-in operators to work correctly, remember that velocity components are expressed in meters per second.

References _velocity.

Referenced by osgParticle::RadialShooter::shoot().

void osgParticle::Particle::transformAngleVelocity ( const osg::Matrix xform) [inline]

Transform angle and angularVelocity vectors by a matrix.

References _angle, _angul_arvel, and osg::Matrixd::preMult().

void osgParticle::Particle::transformPositionVelocity ( const osg::Matrix xform) [inline]

Transform position and velocity vectors by a matrix.

References _position, _velocity, osg::Matrixd::preMult(), and osg::Matrixd::transform3x3().

void osgParticle::Particle::transformPositionVelocity ( const osg::Matrix xform1,
const osg::Matrix xform2,
float  r 
) [inline]

Transform position and velocity vectors by a combination of two matrices.

References _position, _velocity, osg::Matrixd::preMult(), and osg::Matrixd::transform3x3().

bool osgParticle::Particle::update ( double  dt)

Update the particle (don't call this method manually).

This method is called automatically by ParticleSystem::update(); it updates the graphical properties of the particle for the current time, checks whether the particle is still alive, and then updates its position by computing P = P + V * dt (where P is the position and V is the velocity).


Member Data Documentation

Referenced by isAlive().

Referenced by getAlphaRange(), and setAlphaRange().

Referenced by getColorRange(), and setColorRange().

Referenced by getCurrentSize().

Referenced by getLifeTime(), and setLifeTime().

float osgParticle::Particle::_mass [protected]

Referenced by getMass(), and setMass().

Referenced by getMassInv(), and setMass().

Referenced by kill().

Referenced by setTextureTile().

Referenced by getPreviousAngle().

Referenced by getPreviousPosition().

float osgParticle::Particle::_radius [protected]

Referenced by getRadius(), and setRadius().

float osgParticle::Particle::_s_tile [protected]

Referenced by getTileS(), and setTextureTile().

Referenced by getSizeRange(), and setSizeRange().

double osgParticle::Particle::_t0 [protected]

Referenced by getAge().

float osgParticle::Particle::_t_tile [protected]

Referenced by getTileT(), and setTextureTile().


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

osg logo
Generated at Sun Jan 8 2012 13:16:48 for the OpenSceneGraph by doxygen 1.7.4.