15#ifndef OSGPARTICLE_PARTICLESYSTEM
16#define OSGPARTICLE_PARTICLESYSTEM 1
37#ifdef OSGPARTICLE_USE_ReadWriteMutex
38 #include <OpenThreads/ReadWriteMutex>
40 #include <OpenThreads/Mutex>
41 #include <OpenThreads/ScopedLock>
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;
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);
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
281 inline void update_bounds(
const osg::Vec3& p,
float r);
Vec3f Vec3
Definition Vec3:21
BoundingBoxd BoundingBox
Definition BoundingBox:257
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
Pure virtual base class for drawable geometry.
Definition Drawable:89
Visitor for type safe operations on osg::Nodes.
Definition NodeVisitor:82
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
value_type & z()
Definition Vec3f:82
value_type & y()
Definition Vec3f:81
value_type & x()
Definition Vec3f:80
Definition VertexArrayState:25
Implementation of a particle.
Definition Particle:47
ParticleScaleReferenceFrame
Definition ParticleSystem:91
@ WORLD_COORDINATES
Definition ParticleSystem:93
@ LOCAL_COORDINATES
Definition ParticleSystem:92
int getEstimatedMaxNumOfParticles() const
Definition ParticleSystem:273
std::stack< Particle * > Death_stack
Definition ParticleSystem:284
void setDefaultBoundingBox(const osg::BoundingBox &bbox)
Set the default bounding box.
Definition ParticleSystem:412
void setFrozen(bool v)
Set or reset the frozen state.
Definition ParticleSystem:402
int _detail
Definition ParticleSystem:317
SortMode
Definition ParticleSystem:219
@ SORT_BACK_TO_FRONT
Definition ParticleSystem:222
@ NO_SORT
Definition ParticleSystem:220
@ SORT_FRONT_TO_BACK
Definition ParticleSystem:221
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
bool getUseShaders() const
Return true if shaders are required.
Definition ParticleSystem:125
osg::Vec3 _bmin
Definition ParticleSystem:303
bool _doublepass
Definition ParticleSystem:300
void setLevelOfDetail(int v)
(EXPERIMENTAL) Set the level of detail.
Definition ParticleSystem:518
int _estimatedMaxNumOfParticles
Definition ParticleSystem:323
bool getUseVertexArray() const
Return true if we use vertex arrays for rendering particles.
Definition ParticleSystem:114
bool _freeze_on_cull
Definition ParticleSystem:312
void setParticleScaleReferenceFrame(ParticleScaleReferenceFrame rf)
Set whether the particles should be scaled relative to world coordaintes or local coordinates.
Definition ParticleSystem:97
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
drawImplementation(RenderInfo&) is a pure virtual method for the actual implementation of OpenGL draw...
OpenThreads::ScopedLock< OpenThreads::Mutex > ScopedReadLock
Definition ParticleSystem:254
virtual Particle * createParticle(const Particle *ptemplate)
Create a new particle from the specified template (or the default one if ptemplate is null).
double _t0
Definition ParticleSystem:314
Particle & getDefaultParticleTemplate()
Get a reference to the default particle template.
Definition ParticleSystem:488
virtual void destroyParticle(int i)
Destroy the i-th particle.
Definition ParticleSystem:447
std::vector< Particle > Particle_vector
Definition ParticleSystem:283
void update_bounds(const osg::Vec3 &p, float r)
Definition ParticleSystem:470
SortMode getSortMode() const
Get the sort mode.
Definition ParticleSystem:524
Particle_vector _particles
Definition ParticleSystem:286
unsigned int getLastFrameNumber() const
Get the last frame number.
Definition ParticleSystem:452
Particle _def_ptemp
Definition ParticleSystem:309
void setUseShaders(bool v)
Set to use GLSL shaders for rendering particles.
Definition ParticleSystem:131
Particle * getParticle(int i)
Get a pointer to the i-th particle.
Definition ParticleSystem:437
double _visibilityDistance
Definition ParticleSystem:319
bool _reset_bounds_flag
Definition ParticleSystem:306
ParticleSystem & operator=(const ParticleSystem &)
Definition ParticleSystem:279
virtual osg::VertexArrayState * createVertexArrayStateImplementation(osg::RenderInfo &renderInfo) const
Implementation of Create the VertexArrayState object.
void setDefaultAttributes(const std::string &texturefile="", bool emissive_particles=true, bool lighting=false, int texture_unit=0)
A useful method to set the most common StateAttribute's in one call.
osg::buffered_object< ArrayData > BufferedArrayData
Definition ParticleSystem:355
ReadWriterMutex _readWriteMutex
Definition ParticleSystem:321
void setAlignVectorY(const osg::Vec3 &v)
Set the Y-axis alignment vector.
Definition ParticleSystem:386
ParticleSystem(const ParticleSystem ©, const osg::CopyOp ©op=osg::CopyOp::SHALLOW_COPY)
const osg::BoundingBox & getDefaultBoundingBox() const
Get the default bounding box.
Definition ParticleSystem:407
osg::Vec3 _bmax
Definition ParticleSystem:304
bool getFreezeOnCull() const
Get whether the particle system can freeze when culled.
Definition ParticleSystem:503
double _dt
Definition ParticleSystem:315
void setEstimatedMaxNumOfParticles(int num)
Definition ParticleSystem:272
virtual void reuseParticle(int i)
Reuse the i-th particle.
Definition ParticleSystem:176
virtual osg::BoundingBox computeBoundingBox() const
Compute the bounding box around Drawables's geometry.
bool _dirty_dt
Definition ParticleSystem:311
void setSortMode(SortMode mode)
Set the sort mode.
Definition ParticleSystem:529
bool isFrozen() const
Definition ParticleSystem:397
double getVisibilityDistance() const
Get the visibility distance.
Definition ParticleSystem:534
virtual void releaseGLObjects(osg::State *state=0) const
If State is non-zero, this function releases OpenGL objects for the specified graphics context.
META_Object(osgParticle, ParticleSystem)
void adjustEstimatedMaxNumOfParticles(int delta)
Definition ParticleSystem:270
BufferedArrayData _bufferedArrayData
Definition ParticleSystem:356
void setParticleAlignment(Alignment a)
Set the alignment type of particles.
Definition ParticleSystem:366
ReadWriterMutex * getReadWriteMutex() const
Definition ParticleSystem:258
Alignment getParticleAlignment() const
Get the alignment type of particles.
Definition ParticleSystem:361
void setFreezeOnCull(bool v)
Set whether the particle system can freeze when culled (default is true)
Definition ParticleSystem:508
const osg::Vec3 & getAlignVectorY() const
Get the Y-axis alignment vector.
Definition ParticleSystem:381
void setAlignVectors(const osg::Vec3 &X, const osg::Vec3 &Y)
Set the alignment vectors.
Definition ParticleSystem:391
virtual ~ParticleSystem()
bool _dirty_uniforms
Definition ParticleSystem:298
Alignment _alignment
Definition ParticleSystem:291
double & getDeltaTime(double currentTime)
Get the unique delta time for emitters and updaters to use.
Definition ParticleSystem:457
osg::Vec3 _align_Y_axis
Definition ParticleSystem:293
void setDefaultParticleTemplate(const Particle &p)
Set the default particle template (particle is copied).
Definition ParticleSystem:498
virtual void update(double dt, osg::NodeVisitor &nv)
Update the particles. Don't call this directly, use a ParticleSystemUpdater instead.
Death_stack _deadparts
Definition ParticleSystem:287
osg::Vec3 _align_X_axis
Definition ParticleSystem:292
void setDefaultAttributesUsingShaders(const std::string &texturefile="", bool emissive_particles=true, int texture_unit=0)
A useful method to set the most common StateAttribute and use GLSL shaders to draw particles.
ParticleScaleReferenceFrame _particleScaleReferenceFrame
Definition ParticleSystem:294
SortMode _sortMode
Definition ParticleSystem:318
OpenThreads::ScopedLock< OpenThreads::Mutex > ScopedWriteLock
Definition ParticleSystem:255
Alignment
Definition ParticleSystem:57
@ FIXED
Definition ParticleSystem:59
@ BILLBOARD
Definition ParticleSystem:58
ParticleScaleReferenceFrame getParticleScaleReferenceFrame() const
Get whether the particles should be scaled relative to world coordaintes or local coordinates.
Definition ParticleSystem:100
osg::BoundingBox _def_bbox
Definition ParticleSystem:289
int numDeadParticles() const
Get the number of dead particles.
Definition ParticleSystem:432
bool getFrozen() const
Return true if the particle system is frozen.
Definition ParticleSystem:146
bool getDoublePassRendering() const
Get the double pass rendering flag.
Definition ParticleSystem:417
const osg::Vec3 & getAlignVectorX() const
Get the X-axis alignment vector.
Definition ParticleSystem:371
int getLevelOfDetail() const
(EXPERIMENTAL) Get the level of detail.
Definition ParticleSystem:513
int numParticles() const
Get the number of allocated particles (alive + dead).
Definition ParticleSystem:427
void setAlignVectorX(const osg::Vec3 &v)
Set the X-axis alignment vector.
Definition ParticleSystem:376
bool _useShaders
Definition ParticleSystem:297
unsigned int _last_frame
Definition ParticleSystem:310
bool _useVertexArray
Definition ParticleSystem:296
bool _bounds_computed
Definition ParticleSystem:307
OpenThreads::Mutex ReadWriterMutex
Definition ParticleSystem:253
void setDoublePassRendering(bool v)
Set the double pass rendering flag.
Definition ParticleSystem:422
void setUseVertexArray(bool v)
Set to use vertex arrays for rendering particles.
Definition ParticleSystem:122
bool areAllParticlesDead() const
Get whether all particles are dead.
Definition ParticleSystem:161
bool _frozen
Definition ParticleSystem:301
void setVisibilityDistance(double distance)
Set the visibility distance which allows the particles to be rendered only when depth is inside the d...
Definition ParticleSystem:539
void resize(unsigned int numVertices)
osg::ref_ptr< osg::Vec2Array > texcoords2
Definition ParticleSystem:347
osg::ref_ptr< osg::Vec3Array > normals
Definition ParticleSystem:345
Primitives primitives
Definition ParticleSystem:352
osg::ref_ptr< osg::Vec3Array > vertices
Definition ParticleSystem:344
osg::ref_ptr< osg::Vec4Array > colors
Definition ParticleSystem:346
osg::ref_ptr< osg::Vec3Array > texcoords3
Definition ParticleSystem:348
std::pair< GLenum, unsigned int > ModeCount
Definition ParticleSystem:350
void dispatchPrimitives()
void releaseGLObjects(osg::State *state)
void resizeGLObjectBuffers(unsigned int maxSize)
osg::ref_ptr< osg::BufferObject > vertexBufferObject
Definition ParticleSystem:343
std::vector< ModeCount > Primitives
Definition ParticleSystem:351
void dispatchArrays(osg::State &state)
void reserve(unsigned int numVertices)
#define OSGPARTICLE_EXPORT
Definition Export:40