1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
13//osgParticle - Copyright (C) 2002 Marco Jez
15#ifndef OSGPARTICLE_MODULAREMITTER
16#define OSGPARTICLE_MODULAREMITTER 1
18#include <osgParticle/Export>
19#include <osgParticle/Emitter>
20#include <osgParticle/Particle>
21#include <osgParticle/RandomRateCounter>
22#include <osgParticle/Placer>
23#include <osgParticle/PointPlacer>
24#include <osgParticle/Shooter>
25#include <osgParticle/RadialShooter>
26#include <osgParticle/ParticleSystem>
32#include <osg/NodeVisitor>
37 /** An emitter class that holds three objects to control the creation of particles.
38 These objects are a <I>counter</I>, a <I>placer</I> and a <I>shooter</I>.
39 The counter controls the number of particles to be emitted at each frame;
40 the placer must initialize the particle's position vector, while the shooter initializes
42 You can use the predefined counter/placer/shooter classes, or you can create your own.
44 class OSGPARTICLE_EXPORT ModularEmitter: public Emitter {
47 ModularEmitter(const ModularEmitter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
49 META_Node(osgParticle,ModularEmitter);
51 /// Get the counter object.
52 inline Counter* getCounter();
54 /// Get the const Counter object.
55 inline const Counter* getCounter() const;
57 /// Set the Counter object.
58 inline void setCounter(Counter* c);
60 /// Get the ratio between number of particle to create in compensation for movement of the emitter
61 inline float getNumParticlesToCreateMovementCompensationRatio() const;
63 /// Set the ratio between number of particle to create in compenstation for movement of the emitter
64 inline void setNumParticlesToCreateMovementCompensationRatio(float r);
67 /// Get the Placer object.
68 inline Placer* getPlacer();
70 /// Get the const Placer object.
71 inline const Placer* getPlacer() const;
73 /// Set the Placer object.
74 inline void setPlacer(Placer* p);
76 /// Get the Shooter object.
77 inline Shooter *getShooter();
79 /// Get the const Shooter object.
80 inline const Shooter *getShooter() const;
82 /// Set the Shooter object.
83 inline void setShooter(Shooter *s);
86 virtual ~ModularEmitter() {}
87 ModularEmitter &operator=(const ModularEmitter &) { return *this; }
89 virtual void emitParticles(double dt);
93 float _numParticleToCreateMovementCompensationRatio;
94 osg::ref_ptr<Counter> _counter;
95 osg::ref_ptr<Placer> _placer;
96 osg::ref_ptr<Shooter> _shooter;
101 inline Counter* ModularEmitter::getCounter()
103 return _counter.get();
106 inline const Counter* ModularEmitter::getCounter() const
108 return _counter.get();
111 inline void ModularEmitter::setCounter(Counter* c)
116 inline float ModularEmitter::getNumParticlesToCreateMovementCompensationRatio() const
118 return _numParticleToCreateMovementCompensationRatio;
121 inline void ModularEmitter::setNumParticlesToCreateMovementCompensationRatio(float r)
123 _numParticleToCreateMovementCompensationRatio = r;
126 inline Placer* ModularEmitter::getPlacer()
128 return _placer.get();
131 inline const Placer* ModularEmitter::getPlacer() const
133 return _placer.get();
136 inline void ModularEmitter::setPlacer(Placer* p)
141 inline Shooter *ModularEmitter::getShooter()
143 return _shooter.get();
146 inline const Shooter *ModularEmitter::getShooter() const
148 return _shooter.get();
151 inline void ModularEmitter::setShooter(Shooter *s)