15 #ifndef OSGPARTICLE_PARTICLEPROCESSOR
16 #define OSGPARTICLE_PARTICLEPROCESSOR 1
18 #include <osgParticle/Export>
19 #include <osgParticle/ParticleSystem>
21 #include <osg/ref_ptr>
23 #include <osg/Transform>
24 #include <osg/NodeVisitor>
49 virtual const char*
libraryName()
const {
return "osgParticle"; }
50 virtual const char*
className()
const {
return "ParticleProcessor"; }
55 inline ReferenceFrame getReferenceFrame()
const;
58 inline void setReferenceFrame(ReferenceFrame rf);
62 inline bool isEnabled()
const;
65 inline void setEnabled(
bool v);
77 inline void setEndless(
bool type);
81 inline bool isEndless()
const;
84 inline void setLifeTime(
double t);
87 inline double getLifeTime()
const;
90 inline void setStartTime(
double t);
93 inline double getStartTime()
const;
96 inline void setCurrentTime(
double t);
99 inline double getCurrentTime()
const;
102 inline void setResetTime(
double t);
105 inline double getResetTime()
const;
114 inline bool isAlive()
const;
125 inline const osg::Matrix& getPreviousLocalToWorldMatrix();
128 inline const osg::Matrix& getPreviousWorldToLocalMatrix();
149 virtual void process(
double dt) = 0;
156 bool _first_ltw_compute;
157 bool _need_ltw_matrix;
158 bool _first_wtl_compute;
159 bool _need_wtl_matrix;
175 unsigned int _frameNumber;
270 if (_need_ltw_matrix) {
271 _previous_ltw_matrix = _ltw_matrix;
273 if (_first_ltw_compute)
275 _previous_ltw_matrix = _ltw_matrix;
276 _first_ltw_compute =
false;
278 _need_ltw_matrix =
false;
285 if (_need_wtl_matrix) {
286 _previous_wtl_matrix = _wtl_matrix;
288 if (_first_wtl_compute)
290 _previous_wtl_matrix = _wtl_matrix;
291 _first_wtl_compute =
false;
293 _need_wtl_matrix =
false;
301 return _previous_ltw_matrix;
307 return _previous_wtl_matrix;
334 return _currentTime < (_lifeTime + _startTime);
void setResetTime(double t)
Set the reset time of this processor. A value of 0 disables reset.
virtual void accept(osg::NodeVisitor &nv)
const osg::Matrix & getPreviousWorldToLocalMatrix()
Get the previous world-to-local transformation matrix (valid only during cull traversal).
ParticleProcessor & operator=(const ParticleProcessor &)
OSG_EXPORT Matrix computeWorldToLocal(const NodePath &nodePath, bool ignoreCameras=true)
void setLifeTime(double t)
Set the lifetime of this processor.
bool validNodeMask(const osg::Node &node) const
ParticleSystem * getParticleSystem()
Get a pointer to the destination particle system.
const osg::Matrix & getWorldToLocalMatrix()
Get the current world-to-local transformation matrix (valid only during cull traversal).
const osg::Matrix & getPreviousLocalToWorldMatrix()
Get the previous local-to-world transformation matrix (valid only during cull traversal).
osg::Vec3 transformWorldToLocal(const osg::Vec3 &P)
Transform a point from world to local coordinates (valid only during cull traversal).
void setReferenceFrame(ReferenceFrame rf)
Set the reference frame.
virtual bool isSameKindAs(const osg::Object *obj) const
void setStartTime(double t)
Set the start time of this processor.
osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P)
Transform a vector from local to world coordinates, discarding translation (valid only during cull tr...
virtual const char * className() const
virtual ~ParticleProcessor()
osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P)
Transform a vector from world to local coordinates, discarding translation (valid only during cull tr...
#define OSGPARTICLE_EXPORT
ReferenceFrame getReferenceFrame() const
Get the reference frame.
virtual void apply(Drawable &drawable)
void setEnabled(bool v)
Set whether this processor is enabled or not.
double getLifeTime() const
Get the lifetime of this processor.
double getCurrentTime() const
Get the current time of this processor.
const osg::Matrix & getLocalToWorldMatrix()
Get the current local-to-world transformation matrix (valid only during cull traversal).
OSG_EXPORT Matrix computeLocalToWorld(const NodePath &nodePath, bool ignoreCameras=true)
Vec3f preMult(const Vec3f &v) const
bool getEnabled() const
Get whether this processor is enabled or not.
void pushOntoNodePath(Node *node)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
void setEndless(bool type)
Set the endless flag of this processor.
bool getEndless() const
Check whether this processor is endless.
double getResetTime() const
Get the reset time of this processor.
virtual const char * libraryName() const
osg::Vec3 transformLocalToWorld(const osg::Vec3 &P)
Transform a point from local to world coordinates (valid only during cull traversal).
double getStartTime() const
Get the start time of this processor.
void setCurrentTime(double t)
Set the current time of this processor.
void setParticleSystem(ParticleSystem *ps)
Set the destination particle system.