OpenSceneGraph 3.6.5
|
Implementation of a particle. More...
#include <Particle>
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. | |
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 rangef & | getSizeRange () const |
Get the minimum and maximum values for polygon size. | |
const rangef & | getAlphaRange () const |
Get the minimum and maximum values for alpha. | |
const rangev4 & | getColorRange () const |
Get the minimum and maximum values for color. | |
const Interpolator * | getSizeInterpolator () const |
Get the interpolator for computing the size of polygons. | |
const Interpolator * | getAlphaInterpolator () const |
Get the interpolator for computing alpha values. | |
const Interpolator * | getColorInterpolator () 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::Vec3 & | getPosition () const |
Get the position vector. | |
const osg::Vec3 & | getVelocity () const |
Get the velocity vector. | |
const osg::Vec3 & | getPreviousPosition () const |
Get the previous position (the position before last update). | |
const osg::Vec3 & | getAngle () const |
Get the angle vector. | |
const osg::Vec3 & | getAngularVelocity () const |
Get the rotational velocity vector. | |
const osg::Vec3 & | getPreviousAngle () const |
Get the previous angle vector. | |
const osg::Vec4 & | getCurrentColor () const |
Get the current color. | |
float | getCurrentAlpha () const |
Get the current alpha. | |
float | getSTexCoord () const |
Get the s texture coordinate of the bottom left of the particle. | |
float | getTTexCoord () const |
Get the t texture coordinate of the bottom left of the particle. | |
float | getSTexTile () const |
Get the texture coordinate width of the particle. | |
float | getTTexTile () const |
Get the texture coordinate height 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. | |
template<class T> | |
void | setSizeInterpolator (const osg::ref_ptr< T > &ri) |
void | setAlphaInterpolator (Interpolator *ai) |
Set the interpolator for computing alpha values. | |
template<class T> | |
void | setAlphaInterpolator (const osg::ref_ptr< T > &ri) |
void | setColorInterpolator (Interpolator *ci) |
Set the interpolator for computing color values. | |
template<class T> | |
void | setColorInterpolator (const osg::ref_ptr< T > &ri) |
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, bool onlyTimeStamp) |
Update the particle (don't call this method manually). | |
float | getCurrentSize () const |
Get the current (interpolated) polygon size. Valid only after the first call to update(). | |
void | setTextureTileRange (int sTile, int tTile, int startTile, int endTile) |
Specify how the particle texture is tiled. | |
void | setTextureTile (int sTile, int tTile, int end=-1) |
Same as above, range starts at 0 and ends at end. | |
int | getStartTile () const |
int | getEndTile () const |
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 | setDepth (double d) |
Set the depth of the particle. | |
double | getDepth () const |
Get the depth of the particle. | |
bool | operator< (const Particle &P) const |
Sorting operator. | |
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 | _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 |
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.
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 |
osgParticle::Particle::Particle | ( | ) |
References getAge(), getAlphaInterpolator(), getAlphaRange(), getAngle(), getAngularVelocity(), getColorInterpolator(), getColorRange(), getLifeTime(), getMass(), getMassInv(), getPosition(), getPreviousAngle(), getPreviousPosition(), getRadius(), getShape(), getSizeInterpolator(), getSizeRange(), getVelocity(), isAlive(), and setShape().
Referenced by operator<().
|
inline |
Add a vector to the angular velocity vector.
References _angul_arvel.
Referenced by osgParticle::AngularAccelOperator::operate().
|
inline |
Add a vector to the velocity vector.
References _velocity.
Referenced by osgParticle::AccelOperator::operate(), osgParticle::ExplosionOperator::operate(), osgParticle::ForceOperator::operate(), and osgParticle::OrbitOperator::operate().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the rotational velocity vector.
References _angul_arvel.
Referenced by osgParticle::SinkOperator::getValue(), osgParticle::AngularDampingOperator::operate(), and Particle().
|
inline |
|
inline |
|
inline |
Get the current alpha.
References _current_alpha.
|
inline |
Get the current color.
References _current_color.
|
inline |
Get the current (interpolated) polygon size. Valid only after the first call to update().
References _current_size.
Referenced by update().
|
inline |
Get the depth of the particle.
References _depth.
|
inline |
|
inline |
|
inline |
Get the mass of the particle.
For built-in operators to work correctly, remember that the mass is expressed in kg.
References _mass.
Referenced by Particle().
|
inline |
Get 1 / getMass()
.
References _massinv.
Referenced by osgParticle::ForceOperator::operate(), and Particle().
|
inline |
Get the const next particle.
References _nextParticle.
|
inline |
Get number of texture tiles.
References _end_tile, and _start_tile.
|
inline |
Get the position vector.
References _position.
Referenced by osgParticle::SinkOperator::getValue(), osgParticle::ExplosionOperator::operate(), osgParticle::OrbitOperator::operate(), and Particle().
|
inline |
|
inline |
Get the previous particle.
References _previousParticle.
|
inline |
Get the previous position (the position before last update).
References _prev_pos.
Referenced by Particle().
|
inline |
Get the physical radius of the particle.
For built-in operators to work correctly, lengths must be expressed in meters.
References _radius.
Referenced by Particle().
|
inline |
|
inline |
|
inline |
|
inline |
References _start_tile.
Referenced by update().
|
inline |
Get the s texture coordinate of the bottom left of the particle.
References _s_coord.
|
inline |
Get the texture coordinate width of the particle.
References _s_tile.
|
inline |
Get width of texture tile.
References _s_tile.
|
inline |
Get height of texture tile.
References _t_tile.
|
inline |
Get the t texture coordinate of the bottom left of the particle.
References _t_coord.
|
inline |
Get the texture coordinate height of the particle.
References _t_tile.
|
inline |
Get 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::SinkOperator::getValue(), osgParticle::DampingOperator::operate(), and Particle().
|
inline |
Get whether the particle is still alive.
References _alive.
Referenced by osgParticle::Operator::operateParticles(), and Particle().
|
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.
Referenced by osgParticle::SinkOperator::kill().
|
inline |
Sorting operator.
References _depth, and Particle().
|
inline |
References osg::ref_ptr< T >::get(), and setAlphaInterpolator().
Referenced by setAlphaInterpolator().
|
inline |
Set the interpolator for computing alpha values.
References _ai.
|
inline |
Set the minimum and maximum values for alpha.
References _ar.
|
inline |
Set the angle vector.
References _angle.
|
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::AngularDampingOperator::operate(), and osgParticle::RadialShooter::shoot().
|
inline |
References osg::ref_ptr< T >::get(), and setColorInterpolator().
Referenced by setColorInterpolator().
|
inline |
Set the interpolator for computing color values.
References _ci.
|
inline |
Set the minimum and maximum values for color.
References _cr.
|
inline |
Set the depth of the particle.
References _depth.
|
inline |
Set the life time of the particle.
References _lifeTime.
|
inline |
|
inline |
Set the next particle.
References _nextParticle.
|
inline |
Set the position vector.
References _position.
Referenced by osgParticle::BoxPlacer::place(), osgParticle::PointPlacer::place(), osgParticle::SectorPlacer::place(), and osgParticle::SegmentPlacer::place().
|
inline |
Set the previous particle.
References _previousParticle.
|
inline |
Set the physical radius of the particle.
For built-in operators to work correctly, lengths must be expressed in meters.
References _radius.
|
inline |
|
inline |
References osg::ref_ptr< T >::get(), and setSizeInterpolator().
Referenced by setSizeInterpolator().
|
inline |
Set the interpolator for computing size values.
References _si.
|
inline |
Set the minimum and maximum values for polygon size.
References _sr.
|
inline |
Same as above, range starts at 0 and ends at end.
References setTextureTileRange().
Referenced by update().
|
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.
References _end_tile, _s_tile, _start_tile, and _t_tile.
Referenced by setTextureTile(), and update().
void osgParticle::Particle::setUpTexCoordsAsPartOfConnectedParticleSystem | ( | ParticleSystem * | ps | ) |
Method for initializing a particles texture coords as part of a connected particle system.
References ParticleSystem.
|
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::DampingOperator::operate(), and osgParticle::RadialShooter::shoot().
|
inline |
Transform angle and angularVelocity vectors by a matrix.
References _angle, _angul_arvel, and osg::Matrixd::preMult().
|
inline |
Transform position and velocity vectors by a matrix.
References _position, _velocity, osg::Matrixd::preMult(), and osg::Matrixd::transform3x3().
|
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, |
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).
References getCurrentSize(), getEndTile(), getStartTile(), setTextureTile(), and setTextureTileRange().
|
friend |
References ParticleSystem.
Referenced by ParticleSystem, and setUpTexCoordsAsPartOfConnectedParticleSystem().
|
protected |
Referenced by getAlphaInterpolator(), and setAlphaInterpolator().
|
protected |
Referenced by isAlive().
|
protected |
Referenced by getAngle(), setAngle(), and transformAngleVelocity().
|
protected |
Referenced by addAngularVelocity(), getAngularVelocity(), setAngularVelocity(), and transformAngleVelocity().
|
protected |
Referenced by getAlphaRange(), and setAlphaRange().
|
protected |
|
protected |
Referenced by getColorInterpolator(), and setColorInterpolator().
|
protected |
Referenced by getColorRange(), and setColorRange().
|
protected |
|
protected |
Referenced by getCurrentAlpha().
|
protected |
Referenced by getCurrentColor().
|
protected |
Referenced by getCurrentSize().
|
protected |
Referenced by getDepth(), operator<(), and setDepth().
|
protected |
Referenced by getEndTile(), getNumTiles(), and setTextureTileRange().
|
protected |
Referenced by getLifeTime(), and setLifeTime().
|
protected |
Referenced by getMassInv(), and setMass().
|
protected |
Referenced by kill().
|
protected |
Referenced by getNextParticle(), and setNextParticle().
|
protected |
Referenced by getPosition(), setPosition(), transformPositionVelocity(), and transformPositionVelocity().
|
protected |
Referenced by getPreviousAngle().
|
protected |
Referenced by getPreviousPosition().
|
protected |
Referenced by getPreviousParticle(), and setPreviousParticle().
|
protected |
Referenced by getRadius(), and setRadius().
|
protected |
Referenced by getSTexCoord().
|
protected |
Referenced by getSTexTile(), getTileS(), and setTextureTileRange().
|
protected |
Referenced by getShape(), and setShape().
|
protected |
Referenced by getSizeInterpolator(), and setSizeInterpolator().
|
protected |
Referenced by getSizeRange(), and setSizeRange().
|
protected |
Referenced by getNumTiles(), getStartTile(), and setTextureTileRange().
|
protected |
Referenced by getAge().
|
protected |
Referenced by getTTexCoord().
|
protected |
Referenced by getTileT(), getTTexTile(), and setTextureTileRange().
|
protected |
Referenced by addVelocity(), getVelocity(), setVelocity(), transformPositionVelocity(), and transformPositionVelocity().
![]() | Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0. |