OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Emitter.h
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_EMITTER
16 #define OSGPARTICLE_EMITTER 1
17 
18 #include <osgParticle/Export>
19 #include <osgParticle/ParticleProcessor>
20 #include <osgParticle/Particle>
21 
22 #include <osg/Object>
23 #include <osg/Node>
24 #include <osg/NodeVisitor>
25 #include <osg/CopyOp>
26 
27 namespace osgParticle
28 {
29 
36  public:
37  Emitter();
38  Emitter(const Emitter& 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 "Emitter"; }
42  virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Emitter*>(obj) != 0; }
43  virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
44 
46  inline const Particle& getParticleTemplate() const;
47 
49  inline void setParticleTemplate(const Particle& p);
50 
52  inline bool getUseDefaultTemplate() const;
53 
58  inline void setUseDefaultTemplate(bool v);
59 
60  protected:
61  virtual ~Emitter() {}
62  Emitter& operator=(const Emitter&) { return *this; }
63 
64  inline void process(double dt);
65 
66  virtual void emitParticles(double dt) = 0;
67 
70  };
71 
72  // INLINE FUNCTIONS
73 
74  inline const Particle& Emitter::getParticleTemplate() const
75  {
76  return _ptemp;
77  }
78 
79  inline void Emitter::setParticleTemplate(const Particle& p)
80  {
81  _ptemp = p;
82  _usedeftemp = false;
83  }
84 
85  inline bool Emitter::getUseDefaultTemplate() const
86  {
87  return _usedeftemp;
88  }
89 
90  inline void Emitter::setUseDefaultTemplate(bool v)
91  {
92  _usedeftemp = v;
93  }
94 
95  inline void Emitter::process(double dt)
96  {
97  emitParticles(dt);
98  }
99 
100 
101 }
102 
103 
104 #endif
105 
virtual bool isSameKindAs(const osg::Object *obj) const
Definition: Emitter.h:42
Particle _ptemp
Definition: Emitter.h:69
virtual ~Emitter()
Definition: Emitter.h:61
void popFromNodePath()
Definition: NodeVisitor.h:204
void setParticleTemplate(const Particle &p)
Set the particle template (particle is copied).
Definition: Emitter.h:79
bool validNodeMask(const osg::Node &node) const
Definition: NodeVisitor.h:166
bool getUseDefaultTemplate() const
Return whether the particle system's default template should be used.
Definition: Emitter.h:85
void setUseDefaultTemplate(bool v)
Definition: Emitter.h:90
virtual const char * className() const
Definition: Emitter.h:41
virtual void accept(osg::NodeVisitor &nv)
Definition: Emitter.h:43
#define OSGPARTICLE_EXPORT
Definition: Export.h:40
virtual void apply(Drawable &drawable)
const Particle & getParticleTemplate() const
Get the particle template.
Definition: Emitter.h:74
Emitter & operator=(const Emitter &)
Definition: Emitter.h:62
virtual const char * libraryName() const
Definition: Emitter.h:40
void pushOntoNodePath(Node *node)
Definition: NodeVisitor.h:198
virtual void emitParticles(double dt)=0
void process(double dt)
Definition: Emitter.h:95