OpenSceneGraph
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
osgParticle::Particle Class Reference

Implementation of a particle. More...

Public Types

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

Public Member Functions

 Particle ()
 
Shape getShape () const
 Get the shape of the particle. More...
 
void setShape (Shape s)
 Set the shape of the particle. More...
 
bool isAlive () const
 Get whether the particle is still alive. More...
 
double getLifeTime () const
 Get the life time of the particle (in seconds). More...
 
double getAge () const
 Get the age of the particle (in seconds). More...
 
const rangefgetSizeRange () const
 Get the minimum and maximum values for polygon size. More...
 
const rangefgetAlphaRange () const
 Get the minimum and maximum values for alpha. More...
 
const rangev4getColorRange () const
 Get the minimum and maximum values for color. More...
 
const InterpolatorgetSizeInterpolator () const
 Get the interpolator for computing the size of polygons. More...
 
const InterpolatorgetAlphaInterpolator () const
 Get the interpolator for computing alpha values. More...
 
const InterpolatorgetColorInterpolator () const
 Get the interpolator for computing color values. More...
 
float getRadius () const
 Get the physical radius of the particle. More...
 
float getMass () const
 Get the mass of the particle. More...
 
float getMassInv () const
 Get 1 / getMass(). More...
 
const osg::Vec3getPosition () const
 Get the position vector. More...
 
const osg::Vec3getVelocity () const
 Get the velocity vector. More...
 
const osg::Vec3getPreviousPosition () const
 Get the previous position (the position before last update). More...
 
const osg::Vec3getAngle () const
 Get the angle vector. More...
 
const osg::Vec3getAngularVelocity () const
 Get the rotational velocity vector. More...
 
const osg::Vec3getPreviousAngle () const
 Get the previous angle vector. More...
 
const osg::Vec4getCurrentColor () const
 Get the current color. More...
 
float getCurrentAlpha () const
 Get the current alpha. More...
 
float getSTexCoord () const
 Get the s texture coordinate of the bottom left of the particle. More...
 
float getTTexCoord () const
 Get the t texture coordinate of the bottom left of the particle. More...
 
float getSTexTile () const
 Get the texture coordinate width of the particle. More...
 
float getTTexTile () const
 Get the texture coordinate height of the particle. More...
 
int getTileS () const
 Get width of texture tile. More...
 
int getTileT () const
 Get height of texture tile. More...
 
int getNumTiles () const
 Get number of texture tiles. More...
 
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. More...
 
void setLifeTime (double t)
 Set the life time of the particle. More...
 
void setSizeRange (const rangef &r)
 Set the minimum and maximum values for polygon size. More...
 
void setAlphaRange (const rangef &r)
 Set the minimum and maximum values for alpha. More...
 
void setColorRange (const rangev4 &r)
 Set the minimum and maximum values for color. More...
 
void setSizeInterpolator (Interpolator *ri)
 Set the interpolator for computing size values. More...
 
template<class T >
void setSizeInterpolator (const osg::ref_ptr< T > &ri)
 
void setAlphaInterpolator (Interpolator *ai)
 Set the interpolator for computing alpha values. More...
 
template<class T >
void setAlphaInterpolator (const osg::ref_ptr< T > &ri)
 
void setColorInterpolator (Interpolator *ci)
 Set the interpolator for computing color values. More...
 
template<class T >
void setColorInterpolator (const osg::ref_ptr< T > &ri)
 
void setRadius (float r)
 Set the physical radius of the particle. More...
 
void setMass (float m)
 Set the mass of the particle. More...
 
void setPosition (const osg::Vec3 &p)
 Set the position vector. More...
 
void setVelocity (const osg::Vec3 &v)
 Set the velocity vector. More...
 
void addVelocity (const osg::Vec3 &dv)
 Add a vector to the velocity vector. More...
 
void transformPositionVelocity (const osg::Matrix &xform)
 Transform position and velocity vectors by a matrix. More...
 
void transformPositionVelocity (const osg::Matrix &xform1, const osg::Matrix &xform2, float r)
 Transform position and velocity vectors by a combination of two matrices. More...
 
void setAngle (const osg::Vec3 &a)
 Set the angle vector. More...
 
void setAngularVelocity (const osg::Vec3 &v)
 Set the angular velocity vector. More...
 
void addAngularVelocity (const osg::Vec3 &dv)
 Add a vector to the angular velocity vector. More...
 
void transformAngleVelocity (const osg::Matrix &xform)
 Transform angle and angularVelocity vectors by a matrix. More...
 
bool update (double dt, bool onlyTimeStamp)
 Update the particle (don't call this method manually). More...
 
float getCurrentSize () const
 Get the current (interpolated) polygon size. Valid only after the first call to update(). More...
 
void setTextureTileRange (int sTile, int tTile, int startTile, int endTile)
 Specify how the particle texture is tiled. More...
 
void setTextureTile (int sTile, int tTile, int end=-1)
 Same as above, range starts at 0 and ends at end. More...
 
int getStartTile () const
 
int getEndTile () const
 
void setPreviousParticle (int previous)
 Set the previous particle. More...
 
int getPreviousParticle () const
 Get the previous particle. More...
 
void setNextParticle (int next)
 Set the next particle. More...
 
int getNextParticle () const
 Get the const next particle. More...
 
void setDepth (double d)
 Set the depth of the particle. More...
 
double getDepth () const
 Get the depth of the particle. More...
 
bool operator< (const Particle &P) const
 Sorting operator. More...
 
void setUpTexCoordsAsPartOfConnectedParticleSystem (ParticleSystem *ps)
 Method for initializing a particles texture coords as part of a connected particle system. More...
 

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 _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 _alive
 
float _current_size
 
float _current_alpha
 
osg::Vec3 _base_prop
 
osg::Vec4 _current_color
 
float _s_tile
 
float _t_tile
 
int _start_tile
 
int _end_tile
 
int _cur_tile
 
float _s_coord
 
float _t_coord
 
int _previousParticle
 
int _nextParticle
 
double _depth
 

Friends

class ParticleSystem
 

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

anonymous enum
Enumerator
INVALID_INDEX 

◆ Shape

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 
USER 

Constructor & Destructor Documentation

◆ Particle()

osgParticle::Particle::Particle ( )

Member Function Documentation

◆ addAngularVelocity()

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

Add a vector to the angular velocity vector.

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

◆ addVelocity()

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

◆ getAge()

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

Get the age of the particle (in seconds).

◆ getAlphaInterpolator()

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

Get the interpolator for computing alpha values.

◆ getAlphaRange()

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

Get the minimum and maximum values for alpha.

◆ getAngle()

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

Get the angle vector.

◆ getAngularVelocity()

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

Get the rotational velocity vector.

Referenced by osgParticle::SinkOperator::getValue(), and osgParticle::AngularDampingOperator::operate().

◆ getColorInterpolator()

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

Get the interpolator for computing color values.

◆ getColorRange()

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

Get the minimum and maximum values for color.

◆ getCurrentAlpha()

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

Get the current alpha.

◆ getCurrentColor()

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

Get the current color.

◆ getCurrentSize()

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

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

◆ getDepth()

double osgParticle::Particle::getDepth ( ) const
inline

Get the depth of the particle.

◆ getEndTile()

int osgParticle::Particle::getEndTile ( ) const
inline

◆ getLifeTime()

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

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

◆ getMass()

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.

◆ getMassInv()

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

◆ getNextParticle()

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

Get the const next particle.

◆ getNumTiles()

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

Get number of texture tiles.

◆ getPosition()

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

◆ getPreviousAngle()

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

Get the previous angle vector.

◆ getPreviousParticle()

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

Get the previous particle.

◆ getPreviousPosition()

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

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

◆ getRadius()

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.

◆ getShape()

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

Get the shape of the particle.

◆ getSizeInterpolator()

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

Get the interpolator for computing the size of polygons.

◆ getSizeRange()

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

Get the minimum and maximum values for polygon size.

◆ getStartTile()

int osgParticle::Particle::getStartTile ( ) const
inline

◆ getSTexCoord()

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

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

◆ getSTexTile()

float osgParticle::Particle::getSTexTile ( ) const
inline

Get the texture coordinate width of the particle.

◆ getTileS()

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

Get width of texture tile.

◆ getTileT()

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

Get height of texture tile.

◆ getTTexCoord()

float osgParticle::Particle::getTTexCoord ( ) const
inline

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

◆ getTTexTile()

float osgParticle::Particle::getTTexTile ( ) const
inline

Get the texture coordinate height of the particle.

◆ getVelocity()

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.

Referenced by osgParticle::SinkOperator::getValue(), and osgParticle::DampingOperator::operate().

◆ isAlive()

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

Get whether the particle is still alive.

Referenced by osgParticle::Operator::operateParticles().

◆ kill()

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.

Referenced by osgParticle::SinkOperator::kill().

◆ operator<()

bool osgParticle::Particle::operator< ( const Particle P) const
inline

Sorting operator.

References _depth.

◆ setAlphaInterpolator() [1/2]

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

Set the interpolator for computing alpha values.

◆ setAlphaInterpolator() [2/2]

template<class T >
void osgParticle::Particle::setAlphaInterpolator ( const osg::ref_ptr< T > &  ri)
inline

◆ setAlphaRange()

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

Set the minimum and maximum values for alpha.

◆ setAngle()

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

Set the angle vector.

◆ setAngularVelocity()

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).

Referenced by osgParticle::AngularDampingOperator::operate(), and osgParticle::RadialShooter::shoot().

◆ setColorInterpolator() [1/2]

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

Set the interpolator for computing color values.

◆ setColorInterpolator() [2/2]

template<class T >
void osgParticle::Particle::setColorInterpolator ( const osg::ref_ptr< T > &  ri)
inline

◆ setColorRange()

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

Set the minimum and maximum values for color.

◆ setDepth()

void osgParticle::Particle::setDepth ( double  d)
inline

Set the depth of the particle.

◆ setLifeTime()

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

Set the life time of the particle.

◆ setMass()

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.

◆ setNextParticle()

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

Set the next particle.

◆ setPosition()

void osgParticle::Particle::setPosition ( const osg::Vec3 p)
inline

◆ setPreviousParticle()

void osgParticle::Particle::setPreviousParticle ( int  previous)
inline

Set the previous particle.

◆ setRadius()

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.

◆ setShape()

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

Set the shape of the particle.

◆ setSizeInterpolator() [1/2]

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

Set the interpolator for computing size values.

◆ setSizeInterpolator() [2/2]

template<class T >
void osgParticle::Particle::setSizeInterpolator ( const osg::ref_ptr< T > &  ri)
inline

◆ setSizeRange()

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

Set the minimum and maximum values for polygon size.

◆ setTextureTile()

void osgParticle::Particle::setTextureTile ( int  sTile,
int  tTile,
int  end = -1 
)
inline

Same as above, range starts at 0 and ends at end.

◆ setTextureTileRange()

void osgParticle::Particle::setTextureTileRange ( int  sTile,
int  tTile,
int  startTile,
int  endTile 
)
inline

Specify how the particle texture is tiled.

All tiles in the given range are sequentially displayed during the lifetime of the particle. When no range is given, all tiles are displayed during the lifetime.

◆ setUpTexCoordsAsPartOfConnectedParticleSystem()

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

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

◆ setVelocity()

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.

Referenced by osgParticle::DampingOperator::operate(), and osgParticle::RadialShooter::shoot().

◆ transformAngleVelocity()

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

Transform angle and angularVelocity vectors by a matrix.

References osg::Matrixd::preMult().

◆ transformPositionVelocity() [1/2]

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

Transform position and velocity vectors by a matrix.

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

◆ transformPositionVelocity() [2/2]

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 osg::Matrixd::preMult(), and osg::Matrixd::transform3x3().

◆ update()

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

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).

Friends And Related Function Documentation

◆ ParticleSystem

friend class ParticleSystem
friend

Member Data Documentation

◆ _ai

osg::ref_ptr<Interpolator> osgParticle::Particle::_ai
protected

◆ _alive

float osgParticle::Particle::_alive
protected

◆ _angle

osg::Vec3 osgParticle::Particle::_angle
protected

◆ _angul_arvel

osg::Vec3 osgParticle::Particle::_angul_arvel
protected

◆ _ar

rangef osgParticle::Particle::_ar
protected

◆ _base_prop

osg::Vec3 osgParticle::Particle::_base_prop
protected

◆ _ci

osg::ref_ptr<Interpolator> osgParticle::Particle::_ci
protected

◆ _cr

rangev4 osgParticle::Particle::_cr
protected

◆ _cur_tile

int osgParticle::Particle::_cur_tile
protected

◆ _current_alpha

float osgParticle::Particle::_current_alpha
protected

◆ _current_color

osg::Vec4 osgParticle::Particle::_current_color
protected

◆ _current_size

float osgParticle::Particle::_current_size
protected

◆ _depth

double osgParticle::Particle::_depth
protected

Referenced by operator<().

◆ _end_tile

int osgParticle::Particle::_end_tile
protected

◆ _lifeTime

double osgParticle::Particle::_lifeTime
protected

◆ _mass

float osgParticle::Particle::_mass
protected

◆ _massinv

float osgParticle::Particle::_massinv
protected

◆ _mustdie

bool osgParticle::Particle::_mustdie
protected

◆ _nextParticle

int osgParticle::Particle::_nextParticle
protected

◆ _position

osg::Vec3 osgParticle::Particle::_position
protected

◆ _prev_angle

osg::Vec3 osgParticle::Particle::_prev_angle
protected

◆ _prev_pos

osg::Vec3 osgParticle::Particle::_prev_pos
protected

◆ _previousParticle

int osgParticle::Particle::_previousParticle
protected

◆ _radius

float osgParticle::Particle::_radius
protected

◆ _s_coord

float osgParticle::Particle::_s_coord
protected

◆ _s_tile

float osgParticle::Particle::_s_tile
protected

◆ _shape

Shape osgParticle::Particle::_shape
protected

◆ _si

osg::ref_ptr<Interpolator> osgParticle::Particle::_si
protected

◆ _sr

rangef osgParticle::Particle::_sr
protected

◆ _start_tile

int osgParticle::Particle::_start_tile
protected

◆ _t0

double osgParticle::Particle::_t0
protected

◆ _t_coord

float osgParticle::Particle::_t_coord
protected

◆ _t_tile

float osgParticle::Particle::_t_tile
protected

◆ _velocity

osg::Vec3 osgParticle::Particle::_velocity
protected

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