root/OpenSceneGraph/trunk/include/osgParticle/Emitter @ 13041

Revision 13041, 3.2 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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
27namespace osgParticle
28{
29
30    /** An abstract base class for particle emitters.
31        Descendant classes must override the <CODE>emitParticles()</CODE> method to generate new particles by
32        calling the <CODE>ParticleSystem::createParticle()</CODE> method on the particle system associated
33        to the emitter.
34    */
35    class OSGPARTICLE_EXPORT Emitter: public ParticleProcessor {
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
45        /// Get the particle template.
46        inline const Particle& getParticleTemplate() const;
47
48        /// Set the particle template (particle is copied).
49        inline void setParticleTemplate(const Particle& p);
50
51        /// Return whether the particle system's default template should be used.
52        inline bool getUseDefaultTemplate() const;
53
54        /** Set whether the default particle template should be used.
55            When this flag is true, the particle template is ignored, and the
56            particle system's default template is used instead.
57        */
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
68        bool _usedeftemp;
69        Particle _ptemp;
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
Note: See TracBrowser for help on using the browser.