15#ifndef OSGPARTICLE_PARTICLESYSTEM
16#define OSGPARTICLE_PARTICLESYSTEM 1
37#ifdef OSGPARTICLE_USE_ReadWriteMutex
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);
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
281 inline void update_bounds(
const osg::Vec3& p,
float r);
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
Definition ReadWriteMutex:23
Definition ReadWriteMutex:86
Definition ReadWriteMutex:100
Definition ParticleSystem:54
ParticleScaleReferenceFrame
Definition ParticleSystem:91
@ 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)
Definition ParticleSystem:412
void setFrozen(bool v)
Definition ParticleSystem:402
int _detail
Definition ParticleSystem:317
SortMode
Definition ParticleSystem:219
@ NO_SORT
Definition ParticleSystem:220
@ SORT_FRONT_TO_BACK
Definition ParticleSystem:221
virtual void resizeGLObjectBuffers(unsigned int maxSize)
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)
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)
Definition ParticleSystem:97
virtual void drawImplementation(osg::RenderInfo &renderInfo) const
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)
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
void setDefaultAttributes(const std::string &texturefile="", bool emissive_particles=true, bool lighting=false, int texture_unit=0)
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
bool _dirty_dt
Definition ParticleSystem:311
void setSortMode(SortMode 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
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)
ParticleScaleReferenceFrame _particleScaleReferenceFrame
Definition ParticleSystem:294
SortMode _sortMode
Definition ParticleSystem:318
OpenThreads::ScopedLock< OpenThreads::Mutex > ScopedWriteLock
Definition ParticleSystem:255
Alignment
Definition ParticleSystem:57
@ BILLBOARD
Definition ParticleSystem:58
ParticleScaleReferenceFrame getParticleScaleReferenceFrame() const
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)
Definition ParticleSystem:422
void setUseVertexArray(bool v)
Definition ParticleSystem:122
bool areAllParticlesDead() const
Get whether all particles are dead.
Definition ParticleSystem:161
bool _frozen
Definition ParticleSystem:301
void setVisibilityDistance(double distance)
Definition ParticleSystem:539
void kill()
Definition Particle:443
Definition BoundingBox:34
@ SHALLOW_COPY
Definition CopyOp:47
Definition NodeVisitor:82
value_type & z()
Definition Vec3f:82
value_type & y()
Definition Vec3f:81
value_type & x()
Definition Vec3f:80
Definition VertexArrayState:25
Definition AccelOperator:27
Vec3f Vec3
Definition Vec3:21
#define OSGPARTICLE_EXPORT
Definition osgParticle/Export:40
Definition ParticleSystem:326
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)