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

Revision 13041, 4.4 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
14#ifndef OSGPARTICLE_PARTICLEEFFECT
15#define OSGPARTICLE_PARTICLEEFFECT
16
17#include <osgParticle/Emitter>
18#include <osgParticle/Program>
19
20namespace osgParticle
21{
22
23    class OSGPARTICLE_EXPORT ParticleEffect : public osg::Group
24    {
25    public:
26
27        explicit ParticleEffect(bool automaticSetup=true):
28            _automaticSetup(automaticSetup),
29            _useLocalParticleSystem(true),
30            _scale(1.0f),
31            _intensity(1.0f),
32            _startTime(0.0),
33            _emitterDuration(1.0),
34            _wind(0.0f,0.0f,0.0f)
35            {}
36
37        ParticleEffect(const ParticleEffect& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
38
39
40        virtual const char* libraryName() const { return "osgParticle"; }
41        virtual const char* className() const { return "ParticleEffect"; }
42        virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const ParticleEffect*>(obj) != 0; }
43        virtual void accept(osg::NodeVisitor& nv) { if (nv.validNodeMask(*this)) { nv.pushOntoNodePath(this); nv.apply(*this); nv.popFromNodePath(); } }
44
45        void setAutomaticSetup(bool flag) { _automaticSetup = flag; }
46        bool getAutomaticSetup() const { return _automaticSetup; }
47
48        void setUseLocalParticleSystem(bool local);
49        bool getUseLocalParticleSystem() const { return _useLocalParticleSystem; }
50
51        void setTextureFileName(const std::string& filename);
52        const std::string& getTextureFileName() const { return _textureFileName; }
53
54        void setDefaultParticleTemplate(const Particle& p);
55        const Particle& getDefaultParticleTemplate() const { return _defaultParticleTemplate; }
56
57        void setPosition(const osg::Vec3& position);
58        const osg::Vec3& getPosition() const { return _position; }
59
60        void setScale(float scale);
61        float getScale() const { return _scale; }
62
63        void setIntensity(float intensity);
64        float getIntensity() const { return _intensity; }
65
66        void setStartTime(double startTime);
67        double getStartTime() const { return _startTime; }
68
69        void setEmitterDuration(double duration);
70        double getEmitterDuration() const { return _emitterDuration; }
71
72        void setParticleDuration(double duration);
73        double getParticleDuration() const { return _defaultParticleTemplate.getLifeTime(); }
74
75        void setWind(const osg::Vec3& wind);
76        const osg::Vec3& getWind() const { return _wind; }
77
78        /// Get whether all particles are dead
79        bool areAllParticlesDead() const { return _particleSystem.valid()?_particleSystem->areAllParticlesDead():true; }
80
81        virtual Emitter* getEmitter() = 0;
82        virtual const Emitter* getEmitter() const  = 0;
83
84        virtual Program* getProgram()  = 0;
85        virtual const Program* getProgram() const  = 0;
86
87        void setParticleSystem(ParticleSystem* ps);
88        inline ParticleSystem* getParticleSystem() { return _particleSystem.get(); }
89        inline const ParticleSystem* getParticleSystem() const { return _particleSystem.get(); }
90
91        virtual void setDefaults();
92
93        virtual void setUpEmitterAndProgram() = 0;
94
95        virtual void buildEffect();
96
97    protected:
98
99        virtual ~ParticleEffect() {}
100
101        bool                            _automaticSetup;
102
103        osg::ref_ptr<ParticleSystem>    _particleSystem;
104
105        bool                            _useLocalParticleSystem;
106        std::string                     _textureFileName;
107        Particle                        _defaultParticleTemplate;
108        osg::Vec3                       _position;
109        float                           _scale;
110        float                           _intensity;
111        double                          _startTime;
112        double                          _emitterDuration;
113        osg::Vec3                       _wind;
114    };
115
116}
117
118#endif
Note: See TracBrowser for help on using the browser.