Checked in osgParticle, writtten by Marco Jez.
This commit is contained in:
91
include/osgParticle/Operator
Normal file
91
include/osgParticle/Operator
Normal file
@@ -0,0 +1,91 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
//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;
|
||||
|
||||
/** An abstract base class used by <CODE>ModularProgram</CODE> to perform operations on particles before they are updated.
|
||||
To implement a new operator, derive from this class and override the <CODE>operate()</CODE> method.
|
||||
You should also override the <CODE>beginOperate()</CODE> method to query the calling program for the reference frame
|
||||
used, and initialize the right transformations if needed.
|
||||
*/
|
||||
class Operator: public osg::Object {
|
||||
public:
|
||||
inline Operator();
|
||||
inline Operator(const Operator ©, const osg::CopyOp ©op = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual const char *className() const { return "Operator"; }
|
||||
virtual bool isSameKindAs(const osg::Object *obj) const { return dynamic_cast<const Operator *>(obj) != 0; }
|
||||
|
||||
/// Get whether this operator is enabled.
|
||||
inline bool isEnabled() const;
|
||||
|
||||
/// Enable or disable this operator.
|
||||
inline void setEnabled(bool v);
|
||||
|
||||
/** Do something on a particle.
|
||||
This method is called by <CODE>ModularProgram</CODE> objects to perform some operations
|
||||
on the particles. You must override it in descendant classes. Common operations
|
||||
consist of modifying the particle's velocity vector. The <CODE>dt</CODE> parameter is
|
||||
the time elapsed from last operation.
|
||||
*/
|
||||
virtual void operate(Particle *P, double dt) = 0;
|
||||
|
||||
/** Do something before processing particles via the <CODE>operate()</CODE> method.
|
||||
Overriding this method could be necessary to query the calling <CODE>Program</CODE> object
|
||||
for the current reference frame. If the reference frame is RELATIVE_TO_PARENTS, then your
|
||||
class should prepare itself to do all operations in local coordinates.
|
||||
*/
|
||||
virtual void beginOperate(Program *) {}
|
||||
|
||||
/// Do something after all particles have been processed.
|
||||
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 ©, const osg::CopyOp ©op)
|
||||
: osg::Object(copy, copyop), enabled_(copy.enabled_)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool Operator::isEnabled() const
|
||||
{
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
inline void Operator::setEnabled(bool v)
|
||||
{
|
||||
enabled_ = v;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user