openscenegraph
ParticleSystemUpdater
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_PARTICLESYSTEMUPDATER
16#define OSGPARTICLE_PARTICLESYSTEMUPDATER 1
17
18#include <osgParticle/Export>
20
21#include <vector>
22
23#include <osg/ref_ptr>
24#include <osg/CopyOp>
25#include <osg/Object>
26#include <osg/Geode>
27#include <osg/NodeVisitor>
28
29#include <osgUtil/CullVisitor>
30
31namespace osgParticle
32{
33
40 public:
43
45
48
51
53 virtual bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1);
54
57
59 virtual bool setParticleSystem( unsigned int i, ParticleSystem* ps );
60
62 inline unsigned int getNumParticleSystems() const;
63
65 inline ParticleSystem* getParticleSystem(unsigned int i);
66
68 inline const ParticleSystem* getParticleSystem(unsigned int i) const;
69
71 inline bool containsParticleSystem( const ParticleSystem* ps ) const;
72
74 inline unsigned int getParticleSystemIndex( const ParticleSystem* ps ) const;
75
76 virtual void traverse(osg::NodeVisitor& nv);
77
79
80 protected:
83
84 private:
85 typedef std::vector<osg::ref_ptr<ParticleSystem> > ParticleSystem_Vector;
86
87 ParticleSystem_Vector _psv;
88 double _t0;
89
90 //added 1/17/06- bgandere@nps.edu
91 //a var to keep from doing multiple updates per frame
92 unsigned int _frameNumber;
93 };
94
95 // INLINE FUNCTIONS
96
98 {
99 return static_cast<int>(_psv.size());
100 }
101
103 {
104 return _psv[i].get();
105 }
106
108 {
109 return _psv[i].get();
110 }
111
113 {
114 for( ParticleSystem_Vector::const_iterator itr=_psv.begin();
115 itr!=_psv.end();
116 ++itr )
117 {
118 if( itr->get() == ps ) return true;
119 }
120 return false;
121 }
122
124 {
125 for( unsigned int particleSystemNum=0; particleSystemNum<_psv.size(); ++particleSystemNum )
126 {
127 if( _psv[particleSystemNum] == ps ) return particleSystemNum;
128 }
129 return _psv.size(); // node not found.
130 }
131
132}
133
134#endif
Definition ParticleSystemUpdater:39
bool containsParticleSystem(const ParticleSystem *ps) const
return true if ParticleSystem is contained within ParticlsSystemUpdater.
Definition ParticleSystemUpdater:112
virtual ~ParticleSystemUpdater()
Definition ParticleSystemUpdater:81
virtual bool replaceParticleSystem(ParticleSystem *origPS, ParticleSystem *newPS)
Replace ParticleSystem with another ParticleSystem.
virtual bool addParticleSystem(ParticleSystem *ps)
Add a particle system to the list.
unsigned int getParticleSystemIndex(const ParticleSystem *ps) const
get index number of ParticleSystem.
Definition ParticleSystemUpdater:123
virtual osg::BoundingSphere computeBound() const
META_Node(osgParticle, ParticleSystemUpdater)
ParticleSystemUpdater(const ParticleSystemUpdater &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
virtual bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1)
Remove a particle system(s) from the list (by index).
ParticleSystem * getParticleSystem(unsigned int i)
Get a particle system from the list.
Definition ParticleSystemUpdater:102
ParticleSystemUpdater & operator=(const ParticleSystemUpdater &)
Definition ParticleSystemUpdater:82
virtual bool removeParticleSystem(ParticleSystem *ps)
Remove a particle system from the list (by pointer).
virtual bool setParticleSystem(unsigned int i, ParticleSystem *ps)
set a particle system by index.
unsigned int getNumParticleSystems() const
Return the number of particle systems on the list.
Definition ParticleSystemUpdater:97
virtual void traverse(osg::NodeVisitor &nv)
Definition ParticleSystem:54
Definition BoundingSphere:35
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Definition NodeVisitor:82
Definition Node:72
Definition AccelOperator:27
#define OSGPARTICLE_EXPORT
Definition osgParticle/Export:40