Operator
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_OPERATOR
#define OSGPARTICLE_OPERATOR 1
#include <osgParticle/Program>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Matrix>
namespace osgParticle
{
// forward declaration to avoid including the whole header file
class Particle;
class Operator: public osg::Object {
public:
inline Operator();
inline Operator(const Operator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
virtual const char* libraryName() const { return "osgParticle"; }
virtual const char* className() const { return "Operator"; }
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Operator* >(obj) != 0; }
inline bool isEnabled() const;
inline void setEnabled(bool v);
virtual void operateParticles(ParticleSystem* ps, double dt)
{
int n = ps->numParticles();
for (int i=0; i<n; ++i)
{
Particle* P = ps->getParticle(i);
if (P->isAlive() && isEnabled()) operate(P, dt);
}
}
virtual void operate(Particle* P, double dt) = 0;
virtual void beginOperate(Program *) {}
virtual void endOperate() {}
protected:
virtual ~Operator() {}
Operator &operator=(const Operator &) { return *this; }
private:
bool _enabled;
};
// INLINE FUNCTIONS
inline Operator::Operator()
: osg::Object(), _enabled(true)
{
}
inline Operator::Operator(const Operator& copy, const osg::CopyOp& copyop)
: osg::Object(copy, copyop), _enabled(copy._enabled)
{
}
inline bool Operator::isEnabled() const
{
return _enabled;
}
inline void Operator::setEnabled(bool v)
{
_enabled = v;
}
}
#endif
CopyOp
Matrix
Object
osgParticle::Operator::libraryName
virtual const char * libraryName() const
Definition Operator:40
osgParticle::Operator::setEnabled
void setEnabled(bool v)
Enable or disable this operator.
Definition Operator:107
osgParticle::Operator::~Operator
virtual ~Operator()
Definition Operator:83
osgParticle::Operator::endOperate
virtual void endOperate()
Do something after all particles have been processed.
Definition Operator:80
osgParticle::Operator::className
virtual const char * className() const
Definition Operator:41
osgParticle::Operator::operateParticles
virtual void operateParticles(ParticleSystem *ps, double dt)
Definition Operator:55
osgParticle::Operator::isEnabled
bool isEnabled() const
Get whether this operator is enabled.
Definition Operator:102
osgParticle::Operator::operator=
Operator & operator=(const Operator &)
Definition Operator:84
osgParticle::Operator::operate
virtual void operate(Particle *P, double dt)=0
osgParticle::Operator::Operator
Operator()
Definition Operator:92
osgParticle::Operator::isSameKindAs
virtual bool isSameKindAs(const osg::Object *obj) const
Definition Operator:42
osgParticle::Operator::beginOperate
virtual void beginOperate(Program *)
Definition Operator:77
osgParticle::ParticleSystem
Definition ParticleSystem:54
osgParticle::ParticleSystem::getParticle
Particle * getParticle(int i)
Get a pointer to the i-th particle.
Definition ParticleSystem:437
osgParticle::ParticleSystem::numParticles
int numParticles() const
Get the number of allocated particles (alive + dead).
Definition ParticleSystem:427
osgParticle::Particle
Definition Particle:47
osgParticle::Particle::isAlive
bool isAlive() const
Get whether the particle is still alive.
Definition Particle:348
osgParticle::Program
Definition osgParticle/Program:36
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Object
Definition Object:61
osg::Object::Object
Object()
Definition Object:69
osgParticle
Definition AccelOperator:27
osg
Definition AlphaFunc:19
Program