OpenSceneGraph 3.6.5
Operator
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_OPERATOR
16#define OSGPARTICLE_OPERATOR 1
17
18#include <osgParticle/Program>
19
20#include <osg/CopyOp>
21#include <osg/Object>
22#include <osg/Matrix>
23
24namespace osgParticle
25{
26
27 // forward declaration to avoid including the whole header file
28 class Particle;
29
35 class Operator: public osg::Object {
36 public:
37 inline Operator();
38 inline Operator(const Operator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
39
40 virtual const char* libraryName() const { return "osgParticle"; }
41 virtual const char* className() const { return "Operator"; }
42 virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Operator* >(obj) != 0; }
43
45 inline bool isEnabled() const;
46
48 inline void setEnabled(bool v);
49
55 virtual void operateParticles(ParticleSystem* ps, double dt)
56 {
57 int n = ps->numParticles();
58 for (int i=0; i<n; ++i)
59 {
60 Particle* P = ps->getParticle(i);
61 if (P->isAlive() && isEnabled()) operate(P, dt);
62 }
63 }
64
70 virtual void operate(Particle* P, double dt) = 0;
71
77 virtual void beginOperate(Program *) {}
78
80 virtual void endOperate() {}
81
82 protected:
83 virtual ~Operator() {}
84 Operator &operator=(const Operator &) { return *this; }
85
86 private:
87 bool _enabled;
88 };
89
90 // INLINE FUNCTIONS
91
93 : osg::Object(), _enabled(true)
94 {
95 }
96
97 inline Operator::Operator(const Operator& copy, const osg::CopyOp& copyop)
98 : osg::Object(copy, copyop), _enabled(copy._enabled)
99 {
100 }
101
102 inline bool Operator::isEnabled() const
103 {
104 return _enabled;
105 }
106
107 inline void Operator::setEnabled(bool v)
108 {
109 _enabled = v;
110 }
111
112
113}
114
115#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Object()
Construct an object.
Definition Object:69
virtual const char * libraryName() const
return the name of the object's library.
Definition Operator:40
void setEnabled(bool v)
Enable or disable this operator.
Definition Operator:107
virtual ~Operator()
Definition Operator:83
virtual void endOperate()
Do something after all particles have been processed.
Definition Operator:80
virtual const char * className() const
return the name of the object's class type.
Definition Operator:41
virtual void operateParticles(ParticleSystem *ps, double dt)
Do something on all emitted particles.
Definition Operator:55
bool isEnabled() const
Get whether this operator is enabled.
Definition Operator:102
Operator & operator=(const Operator &)
Definition Operator:84
virtual void operate(Particle *P, double dt)=0
Do something on a particle.
Operator()
Definition Operator:92
virtual bool isSameKindAs(const osg::Object *obj) const
Definition Operator:42
virtual void beginOperate(Program *)
Do something before processing particles via the operate() method.
Definition Operator:77
Implementation of a particle.
Definition Particle:47
bool isAlive() const
Get whether the particle is still alive.
Definition Particle:348
The heart of this class library; its purpose is to hold a set of particles and manage particle creati...
Definition ParticleSystem:54
Particle * getParticle(int i)
Get a pointer to the i-th particle.
Definition ParticleSystem:437
int numParticles() const
Get the number of allocated particles (alive + dead).
Definition ParticleSystem:427
An abstract ParticleProcessor descendant for modifying particles "on the fly" during the cull travers...
Definition Program:36

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.