- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgParticle/ParticleProcessor
r12056 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 38 38 class OSGPARTICLE_EXPORT ParticleProcessor: public osg::Node { 39 39 public: 40 40 41 41 enum ReferenceFrame { 42 42 RELATIVE_RF, 43 43 ABSOLUTE_RF 44 44 }; 45 45 46 46 ParticleProcessor(); 47 47 ParticleProcessor(const ParticleProcessor& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); … … 50 50 virtual const char* className() const { return "ParticleProcessor"; } 51 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 52 virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } } 53 54 54 /// Get the reference frame. 55 55 inline ReferenceFrame getReferenceFrame() const; 56 56 57 57 /// Set the reference frame. 58 58 inline void setReferenceFrame(ReferenceFrame rf); 59 59 60 60 /// Get whether this processor is enabled or not. 61 61 bool getEnabled() const { return _enabled; } 62 62 inline bool isEnabled() const; 63 63 64 64 /// Set whether this processor is enabled or not. 65 65 inline void setEnabled(bool v); 66 66 67 67 /// Get a pointer to the destination particle system. 68 68 inline ParticleSystem* getParticleSystem(); 69 69 70 70 /// Get a const pointer to the destination particle system. 71 71 inline const ParticleSystem* getParticleSystem() const; 72 72 73 73 /// Set the destination particle system. 74 74 inline void setParticleSystem(ParticleSystem* ps); 75 75 76 76 /// Set the endless flag of this processor. 77 77 inline void setEndless(bool type); 78 78 79 79 /// Check whether this processor is endless. 80 80 bool getEndless() const { return _endless; } 81 81 inline bool isEndless() const; 82 82 83 83 /// Set the lifetime of this processor. 84 84 inline void setLifeTime(double t); 85 85 86 86 /// Get the lifetime of this processor. 87 87 inline double getLifeTime() const; 88 88 89 89 /// Set the start time of this processor. 90 90 inline void setStartTime(double t); 91 91 92 92 /// Get the start time of this processor. 93 93 inline double getStartTime() const; … … 95 95 /// Set the current time of this processor. 96 96 inline void setCurrentTime(double t); 97 97 98 98 /// Get the current time of this processor. 99 99 inline double getCurrentTime() const; 100 100 101 101 /// Set the reset time of this processor. A value of 0 disables reset. 102 102 inline void setResetTime(double t); 103 103 104 104 /// Get the reset time of this processor. 105 105 inline double getResetTime() const; 106 106 107 107 /** 108 108 Check whether the processor is alive with respect to start time and 109 life duration. Note that this method may return true even if the 109 life duration. Note that this method may return true even if the 110 110 processor has been disabled by calling setEnabled(false). To test 111 111 whether the processor is actually processing particles or not, you … … 113 113 */ 114 114 inline bool isAlive() const; 115 115 116 116 void traverse(osg::NodeVisitor& nv); 117 117 118 118 /// Get the current local-to-world transformation matrix (valid only during cull traversal). 119 119 inline const osg::Matrix& getLocalToWorldMatrix(); 120 120 121 121 /// Get the current world-to-local transformation matrix (valid only during cull traversal). 122 122 inline const osg::Matrix& getWorldToLocalMatrix(); 123 123 124 124 /// Get the previous local-to-world transformation matrix (valid only during cull traversal). 125 125 inline const osg::Matrix& getPreviousLocalToWorldMatrix(); 126 126 127 127 /// Get the previous world-to-local transformation matrix (valid only during cull traversal). 128 128 inline const osg::Matrix& getPreviousWorldToLocalMatrix(); … … 131 131 /// Transform a point from local to world coordinates (valid only during cull traversal). 132 132 inline osg::Vec3 transformLocalToWorld(const osg::Vec3& P); 133 133 134 134 /// Transform a vector from local to world coordinates, discarding translation (valid only during cull traversal). 135 135 inline osg::Vec3 rotateLocalToWorld(const osg::Vec3& P); 136 136 137 137 /// Transform a point from world to local coordinates (valid only during cull traversal). 138 138 inline osg::Vec3 transformWorldToLocal(const osg::Vec3& P); 139 139 140 140 /// Transform a vector from world to local coordinates, discarding translation (valid only during cull traversal). 141 141 inline osg::Vec3 rotateWorldToLocal(const osg::Vec3& P); 142 142 143 virtual osg::BoundingSphere computeBound() const; 143 virtual osg::BoundingSphere computeBound() const; 144 144 145 145 protected: 146 146 virtual ~ParticleProcessor() {} 147 147 ParticleProcessor& operator=(const ParticleProcessor&) { return *this; } 148 148 149 149 virtual void process(double dt) = 0; 150 150 151 151 private: 152 152 ReferenceFrame _rf; … … 163 163 osg::Matrix _previous_wtl_matrix; 164 164 osg::NodeVisitor* _current_nodevisitor; 165 165 166 166 bool _endless; 167 167 168 168 double _lifeTime; 169 169 double _startTime; 170 170 double _currentTime; 171 171 double _resetTime; 172 173 //added- 1/17/06- bgandere@nps.edu 172 173 //added- 1/17/06- bgandere@nps.edu 174 174 //a var to keep from doing multiple updates 175 175 unsigned int _frameNumber; 176 176 }; 177 177 178 178 // INLINE FUNCTIONS 179 179 180 180 inline ParticleProcessor::ReferenceFrame ParticleProcessor::getReferenceFrame() const 181 181 { 182 182 return _rf; 183 183 } 184 184 185 185 inline void ParticleProcessor::setReferenceFrame(ReferenceFrame rf) 186 186 { 187 187 _rf = rf; 188 188 } 189 189 190 190 inline bool ParticleProcessor::isEnabled() const 191 191 { 192 192 return _enabled; 193 193 } 194 194 195 195 inline void ParticleProcessor::setEnabled(bool v) 196 196 { … … 201 201 } 202 202 } 203 203 204 204 inline ParticleSystem* ParticleProcessor::getParticleSystem() 205 205 { … … 211 211 return _ps.get(); 212 212 } 213 213 214 214 inline void ParticleProcessor::setParticleSystem(ParticleSystem* ps) 215 215 { 216 216 _ps = ps; 217 217 } 218 218 219 219 inline void ParticleProcessor::setEndless(bool type) 220 220 { 221 221 _endless = type; 222 222 } 223 223 224 224 inline bool ParticleProcessor::isEndless() const 225 225 { … … 231 231 _lifeTime = t; 232 232 } 233 233 234 234 inline double ParticleProcessor::getLifeTime() const 235 235 { 236 236 return _lifeTime; 237 237 } 238 238 239 239 inline void ParticleProcessor::setStartTime(double t) 240 240 { 241 241 _startTime = t; 242 242 } 243 243 244 244 inline double ParticleProcessor::getStartTime() const 245 245 { … … 250 250 _currentTime = t; 251 251 } 252 252 253 253 inline double ParticleProcessor::getCurrentTime() const 254 254 { 255 255 return _currentTime; 256 256 } 257 257 258 258 inline void ParticleProcessor::setResetTime(double t) 259 259 { 260 260 _resetTime = t; 261 261 } 262 262 263 263 inline double ParticleProcessor::getResetTime() const 264 264 { … … 266 266 } 267 267 268 inline const osg::Matrix& ParticleProcessor::getLocalToWorldMatrix() 268 inline const osg::Matrix& ParticleProcessor::getLocalToWorldMatrix() 269 269 { 270 270 if (_need_ltw_matrix) { … … 281 281 } 282 282 283 inline const osg::Matrix& ParticleProcessor::getWorldToLocalMatrix() 283 inline const osg::Matrix& ParticleProcessor::getWorldToLocalMatrix() 284 284 { 285 285 if (_need_wtl_matrix) { … … 295 295 return _wtl_matrix; 296 296 } 297 297 298 298 inline const osg::Matrix& ParticleProcessor::getPreviousLocalToWorldMatrix() 299 299 { … … 312 312 return getLocalToWorldMatrix().preMult(P); 313 313 } 314 314 315 315 inline osg::Vec3 ParticleProcessor::transformWorldToLocal(const osg::Vec3& P) 316 316 { … … 320 320 inline osg::Vec3 ParticleProcessor::rotateLocalToWorld(const osg::Vec3& P) 321 321 { 322 return getLocalToWorldMatrix().preMult(P) - 322 return getLocalToWorldMatrix().preMult(P) - 323 323 getLocalToWorldMatrix().preMult(osg::Vec3(0, 0, 0)); 324 324 } 325 325 326 326 inline osg::Vec3 ParticleProcessor::rotateWorldToLocal(const osg::Vec3& P) 327 327 { … … 329 329 getWorldToLocalMatrix().preMult(osg::Vec3(0, 0, 0)); 330 330 } 331 331 332 332 inline bool ParticleProcessor::isAlive() const 333 333 {
