OpenSceneGraph 3.6.5
ParticleProcessor
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13//osgParticle - Copyright (C) 2002 Marco Jez
14
15#ifndef OSGPARTICLE_PARTICLEPROCESSOR
16#define OSGPARTICLE_PARTICLEPROCESSOR 1
17
18#include <osgParticle/Export>
20
21#include <osg/ref_ptr>
22#include <osg/Object>
23#include <osg/Transform>
24#include <osg/NodeVisitor>
25#include <osg/CopyOp>
26#include <osg/Vec3>
27#include <osg/Matrix>
28
29namespace osgParticle
30{
31
39 public:
40
45
48
49 virtual const char* libraryName() const { return "osgParticle"; }
50 virtual const char* className() const { return "ParticleProcessor"; }
51 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ParticleProcessor*>(obj) != 0; }
52 virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
53
55 inline ReferenceFrame getReferenceFrame() const;
56
58 inline void setReferenceFrame(ReferenceFrame rf);
59
61 bool getEnabled() const { return _enabled; }
62 inline bool isEnabled() const;
63
65 inline void setEnabled(bool v);
66
68 inline ParticleSystem* getParticleSystem();
69
71 inline const ParticleSystem* getParticleSystem() const;
72
75
77 inline void setEndless(bool type);
78
80 bool getEndless() const { return _endless; }
81 inline bool isEndless() const;
82
84 inline void setLifeTime(double t);
85
87 inline double getLifeTime() const;
88
90 inline void setStartTime(double t);
91
93 inline double getStartTime() const;
94
96 inline void setCurrentTime(double t);
97
99 inline double getCurrentTime() const;
100
102 inline void setResetTime(double t);
103
105 inline double getResetTime() const;
106
114 inline bool isAlive() const;
115
117
119 inline const osg::Matrix& getLocalToWorldMatrix();
120
122 inline const osg::Matrix& getWorldToLocalMatrix();
123
126
129
130
133
135 inline osg::Vec3 rotateLocalToWorld(const osg::Vec3& P);
136
139
141 inline osg::Vec3 rotateWorldToLocal(const osg::Vec3& P);
142
144
145 protected:
148
149 virtual void process(double dt) = 0;
150
153 double _t0;
164
166
167 double _lifeTime;
171
172 //added- 1/17/06- bgandere@nps.edu
173 //a var to keep from doing multiple updates
174 unsigned int _frameNumber;
175 };
176
177 // INLINE FUNCTIONS
178
183
185 {
186 _rf = rf;
187 }
188
190 {
191 return _enabled;
192 }
193
195 {
196 _enabled = v;
197 if (_enabled)
198 {
199 _currentTime = 0;
200 }
201 }
202
204 {
205 return _ps.get();
206 }
207
209 {
210 return _ps.get();
211 }
212
213
214 inline void ParticleProcessor::setEndless(bool type)
215 {
216 _endless = type;
217 }
218
220 {
221 return _endless;
222 }
223
224 inline void ParticleProcessor::setLifeTime(double t)
225 {
226 _lifeTime = t;
227 }
228
229 inline double ParticleProcessor::getLifeTime() const
230 {
231 return _lifeTime;
232 }
233
235 {
236 _startTime = t;
237 }
238
240 {
241 return _startTime;
242 }
244 {
245 _currentTime = t;
246 }
247
249 {
250 return _currentTime;
251 }
252
254 {
255 _resetTime = t;
256 }
257
259 {
260 return _resetTime;
261 }
262
277
292
298
304
309
314
320
326
327 inline bool ParticleProcessor::isAlive() const
328 {
329 return _currentTime < (_lifeTime + _startTime);
330 }
331
332}
333
334
335#endif
Vec3f Vec3
Definition Vec3:21
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Matrixd Matrix
Definition Matrix:27
OSG_EXPORT Matrix computeLocalToWorld(const NodePath &nodePath, bool ignoreCameras=true)
Compute the matrix which transforms objects in local coords to world coords, by accumulating the Tran...
OSG_EXPORT Matrix computeWorldToLocal(const NodePath &nodePath, bool ignoreCameras=true)
Compute the matrix which transforms objects in world coords to local coords, by accumulating the Tran...
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Vec3f preMult(const Vec3f &v) const
Definition Matrixd:618
Base class for all internal nodes in the scene graph.
Definition Node:72
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
virtual void apply(Drawable &drawable)
void pushOntoNodePath(Node *node)
Method called by osg::Node::accept() method before a call to the NodeVisitor::apply(....
Definition NodeVisitor:287
bool validNodeMask(const osg::Node &node) const
Method to called by Node and its subclass' Node::accept() method, if the result is true it is used to...
Definition NodeVisitor:221
void popFromNodePath()
Method called by osg::Node::accept() method after a call to NodeVisitor::apply(..).
Definition NodeVisitor:293
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
osg::Vec3 rotateWorldToLocal(const osg::Vec3 &P)
Transform a vector from world to local coordinates, discarding translation (valid only during cull tr...
Definition ParticleProcessor:321
double getLifeTime() const
Get the lifetime of this processor.
Definition ParticleProcessor:229
ReferenceFrame
Definition ParticleProcessor:41
@ RELATIVE_RF
Definition ParticleProcessor:42
@ ABSOLUTE_RF
Definition ParticleProcessor:43
void setStartTime(double t)
Set the start time of this processor.
Definition ParticleProcessor:234
virtual const char * className() const
return the name of the node's class type.
Definition ParticleProcessor:50
ParticleProcessor(const ParticleProcessor &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
bool isEndless() const
Definition ParticleProcessor:219
const osg::Matrix & getWorldToLocalMatrix()
Get the current world-to-local transformation matrix (valid only during cull traversal).
Definition ParticleProcessor:278
const osg::Matrix & getLocalToWorldMatrix()
Get the current local-to-world transformation matrix (valid only during cull traversal).
Definition ParticleProcessor:263
virtual void setParticleSystem(ParticleSystem *ps)
Set the destination particle system.
ReferenceFrame getReferenceFrame() const
Get the reference frame.
Definition ParticleProcessor:179
double getStartTime() const
Get the start time of this processor.
Definition ParticleProcessor:239
bool getEndless() const
Check whether this processor is endless.
Definition ParticleProcessor:80
double _resetTime
Definition ParticleProcessor:170
osg::Matrix _wtl_matrix
Definition ParticleProcessor:160
void setEndless(bool type)
Set the endless flag of this processor.
Definition ParticleProcessor:214
void setResetTime(double t)
Set the reset time of this processor. A value of 0 disables reset.
Definition ParticleProcessor:253
const osg::Matrix & getPreviousLocalToWorldMatrix()
Get the previous local-to-world transformation matrix (valid only during cull traversal).
Definition ParticleProcessor:293
virtual void accept(osg::NodeVisitor &nv)
Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.
Definition ParticleProcessor:52
double _lifeTime
Definition ParticleProcessor:167
osg::Vec3 transformWorldToLocal(const osg::Vec3 &P)
Transform a point from world to local coordinates (valid only during cull traversal).
Definition ParticleProcessor:310
bool _endless
Definition ParticleProcessor:165
ParticleProcessor & operator=(const ParticleProcessor &)
Definition ParticleProcessor:147
bool _first_wtl_compute
Definition ParticleProcessor:157
ParticleSystem * getParticleSystem()
Get a pointer to the destination particle system.
Definition ParticleProcessor:203
bool isAlive() const
Check whether the processor is alive with respect to start time and life duration.
Definition ParticleProcessor:327
void setEnabled(bool v)
Set whether this processor is enabled or not.
Definition ParticleProcessor:194
void setReferenceFrame(ReferenceFrame rf)
Set the reference frame.
Definition ParticleProcessor:184
double getCurrentTime() const
Get the current time of this processor.
Definition ParticleProcessor:248
virtual void process(double dt)=0
virtual const char * libraryName() const
return the name of the node's library.
Definition ParticleProcessor:49
double _t0
Definition ParticleProcessor:153
double _startTime
Definition ParticleProcessor:168
bool getEnabled() const
Get whether this processor is enabled or not.
Definition ParticleProcessor:61
osg::Vec3 rotateLocalToWorld(const osg::Vec3 &P)
Transform a vector from local to world coordinates, discarding translation (valid only during cull tr...
Definition ParticleProcessor:315
ReferenceFrame _rf
Definition ParticleProcessor:151
void setLifeTime(double t)
Set the lifetime of this processor.
Definition ParticleProcessor:224
osg::ref_ptr< ParticleSystem > _ps
Definition ParticleProcessor:154
double getResetTime() const
Get the reset time of this processor.
Definition ParticleProcessor:258
virtual osg::BoundingSphere computeBound() const
Compute the bounding sphere around Node's geometry or children.
bool _first_ltw_compute
Definition ParticleProcessor:155
osg::Matrix _previous_wtl_matrix
Definition ParticleProcessor:162
virtual ~ParticleProcessor()
Definition ParticleProcessor:146
unsigned int _frameNumber
Definition ParticleProcessor:174
osg::Matrix _previous_ltw_matrix
Definition ParticleProcessor:161
void setCurrentTime(double t)
Set the current time of this processor.
Definition ParticleProcessor:243
osg::NodeVisitor * _current_nodevisitor
Definition ParticleProcessor:163
bool _need_wtl_matrix
Definition ParticleProcessor:158
bool _enabled
Definition ParticleProcessor:152
virtual bool isSameKindAs(const osg::Object *obj) const
return true if this and obj are of the same kind of object.
Definition ParticleProcessor:51
void traverse(osg::NodeVisitor &nv)
Traverse downwards : calls children's accept method with NodeVisitor.
const osg::Matrix & getPreviousWorldToLocalMatrix()
Get the previous world-to-local transformation matrix (valid only during cull traversal).
Definition ParticleProcessor:299
bool _need_ltw_matrix
Definition ParticleProcessor:156
osg::Matrix _ltw_matrix
Definition ParticleProcessor:159
double _currentTime
Definition ParticleProcessor:169
bool isEnabled() const
Definition ParticleProcessor:189
osg::Vec3 transformLocalToWorld(const osg::Vec3 &P)
Transform a point from local to world coordinates (valid only during cull traversal).
Definition ParticleProcessor:305
The heart of this class library; its purpose is to hold a set of particles and manage particle creati...
Definition ParticleSystem:54
#define OSGPARTICLE_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.