15 #ifndef OSGPARTICLE_PARTICLE
16 #define OSGPARTICLE_PARTICLE 1
18 #include <osgParticle/Export>
19 #include <osgParticle/Interpolator>
20 #include <osgParticle/range>
22 #include <osg/ref_ptr>
26 #include <osg/Drawable>
28 #include <osg/GLBeginEndAdapter>
75 inline Shape getShape()
const;
78 inline void setShape(Shape s);
81 inline bool isAlive()
const;
84 inline double getLifeTime()
const;
87 inline double getAge()
const;
90 inline const rangef& getSizeRange()
const;
93 inline const rangef& getAlphaRange()
const;
96 inline const rangev4& getColorRange()
const;
102 inline const Interpolator* getAlphaInterpolator()
const;
105 inline const Interpolator* getColorInterpolator()
const;
110 inline float getRadius()
const;
115 inline float getMass()
const;
118 inline float getMassInv()
const;
121 inline const osg::Vec3& getPosition()
const;
127 inline const osg::Vec3& getVelocity()
const;
130 inline const osg::Vec3& getPreviousPosition()
const;
133 inline const osg::Vec3& getAngle()
const;
136 inline const osg::Vec3& getAngularVelocity()
const;
139 inline const osg::Vec3& getPreviousAngle()
const;
154 inline int getTileS()
const;
157 inline int getTileT()
const;
160 inline int getNumTiles()
const {
return _end_tile - _start_tile + 1; }
169 inline void setLifeTime(
double t);
172 inline void setSizeRange(
const rangef& r);
175 inline void setAlphaRange(
const rangef& r);
178 inline void setColorRange(
const rangev4& r);
192 inline void setRadius(
float r);
197 inline void setMass(
float m);
200 inline void setPosition(
const osg::Vec3& p);
206 inline void setVelocity(
const osg::Vec3& v);
209 inline void addVelocity(
const osg::Vec3& dv);
212 inline void transformPositionVelocity(
const osg::Matrix& xform);
218 inline void setAngle(
const osg::Vec3& a);
224 inline void setAngularVelocity(
const osg::Vec3& v);
227 inline void addAngularVelocity(
const osg::Vec3& dv);
230 inline void transformAngleVelocity(
const osg::Matrix& xform);
238 bool update(
double dt,
bool onlyTimeStamp);
253 inline float getCurrentSize()
const;
258 inline void setTextureTileRange(
int sTile,
int tTile,
int startTile,
int endTile);
261 inline void setTextureTile(
int sTile,
int tTile,
int end = -1);
263 inline int getStartTile()
const;
265 inline int getEndTile()
const;
295 void setUpTexCoordsAsPartOfConnectedParticleSystem(
ParticleSystem* ps);
524 float one_minus_r = 1.0f-r;
525 _position = position1*r + position2*one_minus_r;
526 _velocity = velocity1*r + velocity2*one_minus_r;
553 _angul_arvel = a1 -
_angle;
577 gl->
Begin(GL_POINTS);
615 _s_tile = (sTile>0) ? 1.0f / static_cast<float>(sTile) : 1.0f;
616 _t_tile = (tTile>0) ? 1.0f / static_cast<float>(tTile) : 1.0f;
void beginRender(osg::GLBeginEndAdapter *gl) const
Perform some pre-rendering tasks. Called automatically by particle systems.
An abstract base class for implementing interpolators.
void setColorRange(const rangev4 &r)
Set the minimum and maximum values for color.
osg::ref_ptr< osg::Drawable > _drawable
void setNextParticle(int next)
Set the next particle.
int getNumTiles() const
Get number of texture tiles.
osg::Drawable * getDrawable() const
Get the user-defined particle drawable.
void setAlphaRange(const rangef &r)
Set the minimum and maximum values for alpha.
double getLifeTime() const
Get the life time of the particle (in seconds).
const osg::Vec4 & getCurrentColor() const
Get the current color.
float getMassInv() const
Get 1 / getMass().
Shape getShape() const
Get the shape of the particle.
void transformAngleVelocity(const osg::Matrix &xform)
Transform angle and angularVelocity vectors by a matrix.
int getNextParticle() const
Get the const next particle.
osg::ref_ptr< Interpolator > _ai
float getCurrentSize() const
Get the current (interpolated) polygon size. Valid only after the first call to update().
void setLifeTime(double t)
Set the life time of the particle.
const osg::Vec3 & getAngle() const
Get the angle vector.
osg::ref_ptr< Interpolator > _si
void setPosition(const osg::Vec3 &p)
Set the position vector.
const rangef & getAlphaRange() const
Get the minimum and maximum values for alpha.
const osg::Vec3 & getPreviousAngle() const
Get the previous angle vector.
static Vec3f transform3x3(const Vec3f &v, const Matrixd &m)
const osg::Vec3 & getAngularVelocity() const
Get the rotational velocity vector.
void setDrawable(osg::Drawable *d)
Set the user-defined particle drawable.
void setAngularVelocity(const osg::Vec3 &v)
void setColorInterpolator(Interpolator *ci)
Set the interpolator for computing color values.
const osg::Vec3 & getPreviousPosition() const
Get the previous position (the position before last update).
void setPreviousParticle(int previous)
Set the previous particle.
void setVelocity(const osg::Vec3 &v)
double getAge() const
Get the age of the particle (in seconds).
bool isAlive() const
Get whether the particle is still alive.
void setShape(Shape s)
Set the shape of the particle.
#define OSGPARTICLE_EXPORT
int getTileS() const
Get width of texture tile.
const osg::Vec3 & getPosition() const
Get the position vector.
Vec3f preMult(const Vec3f &v) const
const Interpolator * getColorInterpolator() const
Get the interpolator for computing color values.
bool operator<(const Particle &P) const
Sorting operator.
float getTTexCoord() const
Get the t texture coordinate of the bottom left of the particle.
void setSizeRange(const rangef &r)
Set the minimum and maximum values for polygon size.
void setSizeInterpolator(Interpolator *ri)
Set the interpolator for computing size values.
float getCurrentAlpha() const
Get the current alpha.
const Interpolator * getSizeInterpolator() const
Get the interpolator for computing the size of polygons.
void setAlphaInterpolator(Interpolator *ai)
Set the interpolator for computing alpha values.
void setDepth(double d)
Set the depth of the particle.
double getDepth() const
Get the depth of the particle.
const Interpolator * getAlphaInterpolator() const
Get the interpolator for computing alpha values.
float getSTexCoord() const
Get the s texture coordinate of the bottom left of the particle.
int getPreviousParticle() const
Get the previous particle.
void setTextureTileRange(int sTile, int tTile, int startTile, int endTile)
const rangef & getSizeRange() const
Get the minimum and maximum values for polygon size.
osg::ref_ptr< Interpolator > _ci
void addAngularVelocity(const osg::Vec3 &dv)
Add a vector to the angular velocity vector.
const osg::Vec3 & getVelocity() const
void setTextureTile(int sTile, int tTile, int end=-1)
Same as above, range starts at 0 and ends at end.
void addVelocity(const osg::Vec3 &dv)
Add a vector to the velocity vector.
void endRender(osg::GLBeginEndAdapter *gl) const
Perform some post-rendering tasks. Called automatically by particle systems.
void transformPositionVelocity(const osg::Matrix &xform)
Transform position and velocity vectors by a matrix.
int getTileT() const
Get height of texture tile.
const rangev4 & getColorRange() const
Get the minimum and maximum values for color.
void setAngle(const osg::Vec3 &a)
Set the angle vector.