15 #ifndef OSGPARTICLE_PARTICLESYSTEM
16 #define OSGPARTICLE_PARTICLESYSTEM 1
18 #include <osgParticle/Export>
19 #include <osgParticle/Particle>
27 #include <osg/Drawable>
31 #include <osg/BoundingBox>
37 #ifdef OSGPARTICLE_USE_ReadWriteMutex
38 #include <OpenThreads/ReadWriteMutex>
40 #include <OpenThreads/Mutex>
41 #include <OpenThreads/ScopedLock>
68 inline Alignment getParticleAlignment()
const;
71 inline void setParticleAlignment(Alignment a);
74 inline const osg::Vec3& getAlignVectorX()
const;
77 inline void setAlignVectorX(
const osg::Vec3& v);
80 inline const osg::Vec3& getAlignVectorY()
const;
83 inline void setAlignVectorY(
const osg::Vec3& v);
134 inline bool getDoublePassRendering()
const;
143 inline void setDoublePassRendering(
bool v);
147 inline bool isFrozen()
const;
152 inline void setFrozen(
bool v);
155 inline int numParticles()
const;
158 inline int numDeadParticles()
const;
164 inline Particle* getParticle(
int i);
167 inline const Particle* getParticle(
int i)
const;
173 inline virtual void destroyParticle(
int i);
176 inline virtual void reuseParticle(
int i) { _deadparts.push(&(_particles[i])); }
179 inline unsigned int getLastFrameNumber()
const;
182 inline double& getDeltaTime(
double currentTime );
185 inline Particle& getDefaultParticleTemplate();
188 inline const Particle& getDefaultParticleTemplate()
const;
191 inline void setDefaultParticleTemplate(
const Particle& p);
194 inline bool getFreezeOnCull()
const;
197 inline void setFreezeOnCull(
bool v);
202 void setDefaultAttributes(
const std::string& texturefile =
"",
bool emissive_particles =
true,
bool lighting =
false,
int texture_unit = 0);
208 void setDefaultAttributesUsingShaders(
const std::string& texturefile =
"",
bool emissive_particles =
true,
int texture_unit = 0);
211 inline int getLevelOfDetail()
const;
216 inline void setLevelOfDetail(
int v);
226 inline SortMode getSortMode()
const;
231 inline void setSortMode(SortMode mode);
234 inline double getVisibilityDistance()
const;
239 inline void setVisibilityDistance(
double distance);
248 #ifdef OSGPARTICLE_USE_ReadWriteMutex
266 inline void update_bounds(
const osg::Vec3& p,
float r);
OpenThreads::Mutex ReadWriterMutex
int getLevelOfDetail() const
(EXPERIMENTAL) Get the level of detail.
Particle_vector _particles
bool areAllParticlesDead() const
Get whether all particles are dead.
ReadWriterMutex * getReadWriteMutex() const
This class provides an object-oriented thread mutex interface.
bool getUseVertexArray() const
Return true if we use vertex arrays for rendering particles.
int numParticles() const
Get the number of allocated particles (alive + dead).
void setSortMode(SortMode mode)
void setAlignVectorY(const osg::Vec3 &v)
Set the Y-axis alignment vector.
ReadWriterMutex _readWriteMutex
virtual void destroyParticle(int i)
Destroy the i-th particle.
double & getDeltaTime(double currentTime)
Get the unique delta time for emitters and updaters to use.
double getVisibilityDistance() const
Get the visibility distance.
ParticleScaleReferenceFrame _particleScaleReferenceFrame
ParticleScaleReferenceFrame getParticleScaleReferenceFrame() const
virtual void reuseParticle(int i)
Reuse the i-th particle.
void setAlignVectors(const osg::Vec3 &X, const osg::Vec3 &Y)
Set the alignment vectors.
void setAlignVectorX(const osg::Vec3 &v)
Set the X-axis alignment vector.
#define OSGPARTICLE_EXPORT
void setFreezeOnCull(bool v)
Set whether the particle system can freeze when culled (default is true)
const osg::BoundingBox & getDefaultBoundingBox() const
Get the default bounding box.
double _visibilityDistance
void setDoublePassRendering(bool v)
#define META_Object(library, name)
OpenThreads::ScopedLock< OpenThreads::Mutex > ScopedReadLock
ParticleScaleReferenceFrame
void setVisibilityDistance(double distance)
void setDefaultBoundingBox(const osg::BoundingBox &bbox)
void setUseShaders(bool v)
const osg::Vec3 & getAlignVectorY() const
Get the Y-axis alignment vector.
osg::BoundingBox _def_bbox
ParticleSystem & operator=(const ParticleSystem &)
std::vector< Particle > Particle_vector
void setParticleScaleReferenceFrame(ParticleScaleReferenceFrame rf)
bool getUseShaders() const
Return true if shaders are required.
int numDeadParticles() const
Get the number of dead particles.
std::stack< Particle * > Death_stack
virtual Particle * createParticle(const Particle *ptemplate)
Create a new particle from the specified template (or the default one if ptemplate is null)...
void update_bounds(const osg::Vec3 &p, float r)
Alignment getParticleAlignment() const
Get the alignment type of particles.
SortMode getSortMode() const
Get the sort mode.
Particle * getParticle(int i)
Get a pointer to the i-th particle.
unsigned int getLastFrameNumber() const
Get the last frame number.
void setDefaultParticleTemplate(const Particle &p)
Set the default particle template (particle is copied).
void setUseVertexArray(bool v)
void setParticleAlignment(Alignment a)
Set the alignment type of particles.
bool getFrozen() const
Return true if the particle system is frozen.
void setLevelOfDetail(int v)
OpenThreads::ScopedLock< OpenThreads::Mutex > ScopedWriteLock
bool getDoublePassRendering() const
Get the double pass rendering flag.
bool getFreezeOnCull() const
Get whether the particle system can freeze when culled.
Particle & getDefaultParticleTemplate()
Get a reference to the default particle template.
const osg::Vec3 & getAlignVectorX() const
Get the X-axis alignment vector.