OpenSceneGraph 3.6.5
ParticleEffect
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
14#ifndef OSGPARTICLE_PARTICLEEFFECT
15#define OSGPARTICLE_PARTICLEEFFECT
16
17#include <osgParticle/Emitter>
18#include <osgParticle/Program>
19
20namespace osgParticle
21{
22
24 {
25 public:
26
27 explicit ParticleEffect(bool automaticSetup=true):
28 _automaticSetup(automaticSetup),
30 _scale(1.0f),
31 _intensity(1.0f),
32 _startTime(0.0),
34 _wind(0.0f,0.0f,0.0f)
35 {}
36
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);
50
51 void setTextureFileName(const std::string& filename);
52 const std::string& getTextureFileName() const { return _textureFileName; }
53
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
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
88 template<class T> void setParticleSystem(const osg::ref_ptr<T>& ri) { setParticleSystem(ri.get()); }
89
91 inline const ParticleSystem* getParticleSystem() const { return _particleSystem.get(); }
92
93 virtual void setDefaults();
94
95 virtual void setUpEmitterAndProgram() = 0;
96
97 virtual void buildEffect();
98
99 protected:
100
101 virtual ~ParticleEffect() {}
102
104
106
108 std::string _textureFileName;
111 float _scale;
116 };
117
118}
119
120#endif
Vec3f Vec3
Definition Vec3:21
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
General group node which maintains a list of children.
Definition Group:29
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
virtual void apply(Drawable &drawable)
void pushOntoNodePath(Node *node)
Method called by osg::Node::accept() method before a call to the NodeVisitor::apply(....
Definition NodeVisitor:287
bool validNodeMask(const osg::Node &node) const
Method to called by Node and its subclass' Node::accept() method, if the result is true it is used to...
Definition NodeVisitor:221
void popFromNodePath()
Method called by osg::Node::accept() method after a call to NodeVisitor::apply(..).
Definition NodeVisitor:293
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
An abstract base class for particle emitters.
Definition Emitter:35
Implementation of a particle.
Definition Particle:47
Particle _defaultParticleTemplate
Definition ParticleEffect:109
const osg::Vec3 & getWind() const
Definition ParticleEffect:76
const Particle & getDefaultParticleTemplate() const
Definition ParticleEffect:55
void setAutomaticSetup(bool flag)
Definition ParticleEffect:45
virtual const char * libraryName() const
return the name of the node's library.
Definition ParticleEffect:40
virtual const Emitter * getEmitter() const =0
bool getUseLocalParticleSystem() const
Definition ParticleEffect:49
double getParticleDuration() const
Definition ParticleEffect:73
bool areAllParticlesDead() const
Get whether all particles are dead.
Definition ParticleEffect:79
ParticleEffect(bool automaticSetup=true)
Definition ParticleEffect:27
virtual void setUpEmitterAndProgram()=0
const ParticleSystem * getParticleSystem() const
Definition ParticleEffect:91
void setTextureFileName(const std::string &filename)
std::string _textureFileName
Definition ParticleEffect:108
double _emitterDuration
Definition ParticleEffect:114
osg::Vec3 _wind
Definition ParticleEffect:115
void setPosition(const osg::Vec3 &position)
void setIntensity(float intensity)
double getStartTime() const
Definition ParticleEffect:67
void setEmitterDuration(double duration)
virtual const Program * getProgram() const =0
double getEmitterDuration() const
Definition ParticleEffect:70
void setUseLocalParticleSystem(bool local)
void setWind(const osg::Vec3 &wind)
ParticleSystem * getParticleSystem()
Definition ParticleEffect:90
osg::ref_ptr< ParticleSystem > _particleSystem
Definition ParticleEffect:105
const std::string & getTextureFileName() const
Definition ParticleEffect:52
float _intensity
Definition ParticleEffect:112
double _startTime
Definition ParticleEffect:113
void setParticleDuration(double duration)
void setParticleSystem(const osg::ref_ptr< T > &ri)
Definition ParticleEffect:88
const osg::Vec3 & getPosition() const
Definition ParticleEffect:58
bool getAutomaticSetup() const
Definition ParticleEffect:46
virtual Program * getProgram()=0
float getIntensity() const
Definition ParticleEffect:64
virtual Emitter * getEmitter()=0
void setStartTime(double startTime)
bool _automaticSetup
Definition ParticleEffect:103
osg::Vec3 _position
Definition ParticleEffect:110
void setParticleSystem(ParticleSystem *ps)
virtual void accept(osg::NodeVisitor &nv)
Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.
Definition ParticleEffect:43
virtual bool isSameKindAs(const osg::Object *obj) const
return true if this and obj are of the same kind of object.
Definition ParticleEffect:42
float getScale() const
Definition ParticleEffect:61
void setDefaultParticleTemplate(const Particle &p)
float _scale
Definition ParticleEffect:111
virtual ~ParticleEffect()
Definition ParticleEffect:101
virtual const char * className() const
return the name of the node's class type.
Definition ParticleEffect:41
ParticleEffect(const ParticleEffect &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void setScale(float scale)
bool _useLocalParticleSystem
Definition ParticleEffect:107
The heart of this class library; its purpose is to hold a set of particles and manage particle creati...
Definition ParticleSystem:54
An abstract ParticleProcessor descendant for modifying particles "on the fly" during the cull travers...
Definition Program:36
#define OSGPARTICLE_EXPORT
Definition Export:40

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