2012-03-22 01:36:20 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
2012-03-22 01:36:20 +08:00
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
2003-01-22 00:45:36 +08:00
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
2012-03-22 01:36:20 +08:00
|
|
|
*
|
2003-01-22 00:45:36 +08:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-03-22 01:36:20 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2003-01-22 00:45:36 +08:00
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-06-05 20:44:55 +08:00
|
|
|
//osgParticle - Copyright (C) 2002 Marco Jez
|
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
#ifndef OSGPARTICLE_MODULAREMITTER
|
|
|
|
#define OSGPARTICLE_MODULAREMITTER 1
|
2002-06-05 20:44:55 +08:00
|
|
|
|
|
|
|
#include <osgParticle/Export>
|
|
|
|
#include <osgParticle/Emitter>
|
|
|
|
#include <osgParticle/Particle>
|
|
|
|
#include <osgParticle/RandomRateCounter>
|
|
|
|
#include <osgParticle/Placer>
|
|
|
|
#include <osgParticle/PointPlacer>
|
|
|
|
#include <osgParticle/Shooter>
|
|
|
|
#include <osgParticle/RadialShooter>
|
|
|
|
#include <osgParticle/ParticleSystem>
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <osg/CopyOp>
|
|
|
|
#include <osg/Object>
|
|
|
|
#include <osg/Node>
|
|
|
|
#include <osg/NodeVisitor>
|
|
|
|
|
|
|
|
namespace osgParticle
|
|
|
|
{
|
|
|
|
|
|
|
|
/** An emitter class that holds three objects to control the creation of particles.
|
|
|
|
These objects are a <I>counter</I>, a <I>placer</I> and a <I>shooter</I>.
|
2012-03-22 01:36:20 +08:00
|
|
|
The counter controls the number of particles to be emitted at each frame;
|
|
|
|
the placer must initialize the particle's position vector, while the shooter initializes
|
2002-06-05 20:44:55 +08:00
|
|
|
its velocity vector.
|
|
|
|
You can use the predefined counter/placer/shooter classes, or you can create your own.
|
|
|
|
*/
|
|
|
|
class OSGPARTICLE_EXPORT ModularEmitter: public Emitter {
|
|
|
|
public:
|
|
|
|
ModularEmitter();
|
2005-04-29 17:47:57 +08:00
|
|
|
ModularEmitter(const ModularEmitter& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-06 21:25:36 +08:00
|
|
|
META_Node(osgParticle,ModularEmitter);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Get the counter object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline Counter* getCounter();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Get the const Counter object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline const Counter* getCounter() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Set the Counter object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline void setCounter(Counter* c);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2007-06-28 04:36:16 +08:00
|
|
|
/// Get the ratio between number of particle to create in compensation for movement of the emitter
|
|
|
|
inline float getNumParticlesToCreateMovementCompensationRatio() const;
|
2005-08-25 22:12:08 +08:00
|
|
|
|
|
|
|
/// Set the ratio between number of particle to create in compenstation for movement of the emitter
|
2007-06-28 04:36:16 +08:00
|
|
|
inline void setNumParticlesToCreateMovementCompensationRatio(float r);
|
2005-08-25 22:12:08 +08:00
|
|
|
|
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Get the Placer object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline Placer* getPlacer();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
|
|
|
/// Get the const Placer object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline const Placer* getPlacer() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Set the Placer object.
|
2005-04-29 17:47:57 +08:00
|
|
|
inline void setPlacer(Placer* p);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Get the Shooter object.
|
|
|
|
inline Shooter *getShooter();
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Get the const Shooter object.
|
|
|
|
inline const Shooter *getShooter() const;
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
/// Set the Shooter object.
|
2012-03-22 01:36:20 +08:00
|
|
|
inline void setShooter(Shooter *s);
|
2002-06-05 20:44:55 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ~ModularEmitter() {}
|
|
|
|
ModularEmitter &operator=(const ModularEmitter &) { return *this; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-07-31 00:06:22 +08:00
|
|
|
virtual void emitParticles(double dt);
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
private:
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-08-25 22:12:08 +08:00
|
|
|
float _numParticleToCreateMovementCompensationRatio;
|
2005-04-29 17:47:57 +08:00
|
|
|
osg::ref_ptr<Counter> _counter;
|
|
|
|
osg::ref_ptr<Placer> _placer;
|
|
|
|
osg::ref_ptr<Shooter> _shooter;
|
2002-06-05 20:44:55 +08:00
|
|
|
};
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
// INLINE FUNCTIONS
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline Counter* ModularEmitter::getCounter()
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _counter.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline const Counter* ModularEmitter::getCounter() const
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _counter.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline void ModularEmitter::setCounter(Counter* c)
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
_counter = c;
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
2007-06-28 04:36:16 +08:00
|
|
|
inline float ModularEmitter::getNumParticlesToCreateMovementCompensationRatio() const
|
2005-08-25 22:12:08 +08:00
|
|
|
{
|
|
|
|
return _numParticleToCreateMovementCompensationRatio;
|
|
|
|
}
|
|
|
|
|
2007-06-28 04:36:16 +08:00
|
|
|
inline void ModularEmitter::setNumParticlesToCreateMovementCompensationRatio(float r)
|
2005-08-25 22:12:08 +08:00
|
|
|
{
|
|
|
|
_numParticleToCreateMovementCompensationRatio = r;
|
|
|
|
}
|
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline Placer* ModularEmitter::getPlacer()
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _placer.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline const Placer* ModularEmitter::getPlacer() const
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _placer.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
2005-04-29 17:47:57 +08:00
|
|
|
inline void ModularEmitter::setPlacer(Placer* p)
|
2002-06-05 20:44:55 +08:00
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
_placer = p;
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline Shooter *ModularEmitter::getShooter()
|
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _shooter.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline const Shooter *ModularEmitter::getShooter() const
|
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
return _shooter.get();
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void ModularEmitter::setShooter(Shooter *s)
|
|
|
|
{
|
2005-04-29 17:47:57 +08:00
|
|
|
_shooter = s;
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2002-06-05 20:44:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|