ParticleSystemUpdater
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//osgParticle - Copyright (C) 2002 Marco Jez
#ifndef OSGPARTICLE_PARTICLESYSTEMUPDATER
#define OSGPARTICLE_PARTICLESYSTEMUPDATER 1
#include <osgParticle/Export>
#include <osgParticle/ParticleSystem>
#include <vector>
#include <osg/ref_ptr>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Geode>
#include <osg/NodeVisitor>
#include <osgUtil/CullVisitor>
namespace osgParticle
{
class OSGPARTICLE_EXPORT ParticleSystemUpdater: public osg::Node {
public:
ParticleSystemUpdater();
ParticleSystemUpdater(const ParticleSystemUpdater& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
META_Node(osgParticle,ParticleSystemUpdater);
virtual bool addParticleSystem(ParticleSystem* ps);
virtual bool removeParticleSystem(ParticleSystem* ps);
virtual bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1);
virtual bool replaceParticleSystem(ParticleSystem* origPS, ParticleSystem* newPS);
virtual bool setParticleSystem( unsigned int i, ParticleSystem* ps );
inline unsigned int getNumParticleSystems() const;
inline ParticleSystem* getParticleSystem(unsigned int i);
inline const ParticleSystem* getParticleSystem(unsigned int i) const;
inline bool containsParticleSystem( const ParticleSystem* ps ) const;
inline unsigned int getParticleSystemIndex( const ParticleSystem* ps ) const;
virtual void traverse(osg::NodeVisitor& nv);
virtual osg::BoundingSphere computeBound() const;
protected:
virtual ~ParticleSystemUpdater() {}
ParticleSystemUpdater &operator=(const ParticleSystemUpdater &) { return *this; }
private:
typedef std::vector<osg::ref_ptr<ParticleSystem> > ParticleSystem_Vector;
ParticleSystem_Vector _psv;
double _t0;
//added 1/17/06- bgandere@nps.edu
//a var to keep from doing multiple updates per frame
unsigned int _frameNumber;
};
// INLINE FUNCTIONS
inline unsigned int ParticleSystemUpdater::getNumParticleSystems() const
{
return static_cast<int>(_psv.size());
}
inline ParticleSystem* ParticleSystemUpdater::getParticleSystem(unsigned int i)
{
return _psv[i].get();
}
inline const ParticleSystem* ParticleSystemUpdater::getParticleSystem(unsigned int i) const
{
return _psv[i].get();
}
inline bool ParticleSystemUpdater::containsParticleSystem( const ParticleSystem* ps ) const
{
for( ParticleSystem_Vector::const_iterator itr=_psv.begin();
itr!=_psv.end();
++itr )
{
if( itr->get() == ps ) return true;
}
return false;
}
inline unsigned int ParticleSystemUpdater::getParticleSystemIndex( const ParticleSystem* ps ) const
{
for( unsigned int particleSystemNum=0; particleSystemNum<_psv.size(); ++particleSystemNum )
{
if( _psv[particleSystemNum] == ps ) return particleSystemNum;
}
return _psv.size(); // node not found.
}
}
#endif
CopyOp
CullVisitor
Geode
NodeVisitor
Object
ParticleSystem
osgParticle::ParticleSystemUpdater::containsParticleSystem
bool containsParticleSystem(const ParticleSystem *ps) const
return true if ParticleSystem is contained within ParticlsSystemUpdater.
Definition ParticleSystemUpdater:112
osgParticle::ParticleSystemUpdater::~ParticleSystemUpdater
virtual ~ParticleSystemUpdater()
Definition ParticleSystemUpdater:81
osgParticle::ParticleSystemUpdater::ParticleSystemUpdater
ParticleSystemUpdater()
osgParticle::ParticleSystemUpdater::replaceParticleSystem
virtual bool replaceParticleSystem(ParticleSystem *origPS, ParticleSystem *newPS)
Replace ParticleSystem with another ParticleSystem.
osgParticle::ParticleSystemUpdater::addParticleSystem
virtual bool addParticleSystem(ParticleSystem *ps)
Add a particle system to the list.
osgParticle::ParticleSystemUpdater::getParticleSystemIndex
unsigned int getParticleSystemIndex(const ParticleSystem *ps) const
get index number of ParticleSystem.
Definition ParticleSystemUpdater:123
osgParticle::ParticleSystemUpdater::computeBound
virtual osg::BoundingSphere computeBound() const
osgParticle::ParticleSystemUpdater::META_Node
META_Node(osgParticle, ParticleSystemUpdater)
osgParticle::ParticleSystemUpdater::ParticleSystemUpdater
ParticleSystemUpdater(const ParticleSystemUpdater &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgParticle::ParticleSystemUpdater::removeParticleSystem
virtual bool removeParticleSystem(unsigned int i, unsigned int numParticleSystemsToRemove=1)
Remove a particle system(s) from the list (by index).
osgParticle::ParticleSystemUpdater::getParticleSystem
ParticleSystem * getParticleSystem(unsigned int i)
Get a particle system from the list.
Definition ParticleSystemUpdater:102
osgParticle::ParticleSystemUpdater::operator=
ParticleSystemUpdater & operator=(const ParticleSystemUpdater &)
Definition ParticleSystemUpdater:82
osgParticle::ParticleSystemUpdater::removeParticleSystem
virtual bool removeParticleSystem(ParticleSystem *ps)
Remove a particle system from the list (by pointer).
osgParticle::ParticleSystemUpdater::setParticleSystem
virtual bool setParticleSystem(unsigned int i, ParticleSystem *ps)
set a particle system by index.
osgParticle::ParticleSystemUpdater::getNumParticleSystems
unsigned int getNumParticleSystems() const
Return the number of particle systems on the list.
Definition ParticleSystemUpdater:97
osgParticle::ParticleSystemUpdater::traverse
virtual void traverse(osg::NodeVisitor &nv)
osgParticle::ParticleSystem
Definition ParticleSystem:54
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osgParticle
Definition AccelOperator:27
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
Export
OSGPARTICLE_EXPORT
#define OSGPARTICLE_EXPORT
Definition osgParticle/Export:40
ref_ptr