14 #ifndef OSGPARTICLE_PRECIPITATIONEFFECT
15 #define OSGPARTICLE_PRECIPITATIONEFFECT
18 #include <osg/BoundingBox>
20 #include <osg/Geometry>
22 #include <osgUtil/CullVisitor>
24 #include <osgParticle/Export>
35 virtual const char*
libraryName()
const {
return "osgParticle"; }
36 virtual const char*
className()
const {
return "PrecipitationEffect"; }
44 void rain(
float intensity);
47 void snow(
float intensity);
49 void setMaximumParticleDensity(
float density) {
if (_maximumParticleDensity==density)
return; _maximumParticleDensity = density; _dirty =
true;}
58 void setCellSize(
const osg::Vec3& cellSize) {
if (_cellSize==cellSize)
return; _cellSize = cellSize; _dirty =
true; }
61 void setParticleSpeed(
float particleSpeed) {
if (_particleSpeed==particleSpeed)
return; _particleSpeed = particleSpeed; _dirty =
true; }
64 void setParticleSize(
float particleSize) {
if (_particleSize==particleSize)
return; _particleSize = particleSize; _dirty =
true;}
124 Cell(
int in_i,
int in_j,
int in_k):
125 i(in_i), j(in_j), k(in_k) {}
127 inline bool operator < (
const Cell& rhs)
const
129 if (i<rhs.
i)
return true;
130 if (i>rhs.
i)
return false;
131 if (j<rhs.
j)
return true;
132 if (j>rhs.
j)
return false;
133 if (k<rhs.
k)
return true;
134 if (k>rhs.
k)
return false;
159 inline bool operator () (
const CellMatrixMap::value_type* lhs,
const CellMatrixMap::value_type* rhs)
const
161 return (*lhs).second<(*rhs).second;
171 _previousCellMatrixMap.swap(_currentCellMatrixMap);
172 _currentCellMatrixMap.clear();
199 void createGeometry(
unsigned int numParticles,
204 void setUpGeometries(
unsigned int numParticles);
void setRequiresPreviousMatrix(bool flag)
osg::Geometry * getPointGeometry()
float getParticleSize() const
void setFog(osg::Fog *fog)
Cell(int in_i, int in_j, int in_k)
virtual const char * className() const
osg::ref_ptr< osg::Fog > _fog
CellMatrixMap _previousCellMatrixMap
osg::ref_ptr< osg::StateSet > _lineStateSet
This class provides an object-oriented thread mutex interface.
void setGeometry(osg::Geometry *geom)
void setWind(const osg::Vec3 &wind)
float getFarTransition() const
const osg::Vec4 & getParticleColor() const
GLint GLenum GLsizei GLsizei GLsizei depth
bool _requiresPreviousMatrix
osg::ref_ptr< osg::StateSet > _quadStateSet
osg::StateSet * getLineStateSet()
osg::ref_ptr< osg::Geometry > _lineGeometry
osg::ref_ptr< osg::Geometry > _geometry
void setDrawType(GLenum type)
osg::StateSet * getQuadStateSet()
bool validNodeMask(const osg::Node &node) const
const osg::Fog * getFog() const
CellMatrixMap & getCurrentCellMatrixMap()
osg::Geometry * getLineGeometry()
virtual bool isSameKindAs(const osg::Object *obj) const
void setUseFarLineSegments(bool useFarLineSegments)
ViewDrawableMap _viewDrawableMap
osg::ref_ptr< osg::Geometry > _pointGeometry
virtual ~PrecipitationDrawable()
float getNearTransition() const
virtual bool supports(const osg::PrimitiveFunctor &) const
void setParticleSize(float particleSize)
#define OSGPARTICLE_EXPORT
virtual void accept(osg::PrimitiveFunctor &) const
osg::ref_ptr< osg::Uniform > _particleSizeUniform
osg::ref_ptr< osg::Uniform > _particleColorUniform
void setMaximumParticleDensity(float density)
CellMatrixMap & getPreviousCellMatrixMap()
virtual const char * libraryName() const
#define META_Object(library, name)
virtual void apply(Drawable &drawable)
void setPosition(const osg::Vec3 &position)
osg::StateSet * getPointStateSet()
osg::ref_ptr< osg::Geometry > _quadGeometry
unsigned int _numberOfVertices
void setCellSize(const osg::Vec3 &cellSize)
float getMaximumParticleDensity() const
osg::ref_ptr< osg::StateSet > _pointStateSet
void setParticleSpeed(float particleSpeed)
const osg::Vec3 & getPosition() const
std::pair< osg::NodeVisitor *, osg::NodePath > ViewIdentifier
void pushOntoNodePath(Node *node)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum type
OpenThreads::Mutex _mutex
bool getUseFarLineSegments() const
const osg::Vec3 & getCellSize() const
const osg::Vec3 & getWind() const
virtual void accept(osg::PrimitiveIndexFunctor &) const
std::map< Cell, DepthMatrixStartTime > CellMatrixMap
void setNearTransition(float nearTransition)
GLenum getDrawType() const
const osg::Geometry * getGeometry() const
float _maximumParticleDensity
virtual ~PrecipitationEffect()
std::map< ViewIdentifier, PrecipitationDrawableSet > ViewDrawableMap
osg::ref_ptr< PrecipitationDrawable > _linePrecipitationDrawable
osg::ref_ptr< PrecipitationDrawable > _pointPrecipitationDrawable
float getParticleSpeed() const
virtual bool supports(const osg::PrimitiveIndexFunctor &) const
void setNumberOfVertices(unsigned int numVertices)
osg::Geometry * getGeometry()
void setFarTransition(float farTransition)
double _previousFrameTime
void setParticleColor(const osg::Vec4 &color)
virtual void accept(osg::NodeVisitor &nv)
CellMatrixMap _currentCellMatrixMap
bool getRequiresPreviousMatrix() const
osg::Geometry * getQuadGeometry()
unsigned int getNumberOfVertices() const
osg::ref_ptr< osg::Uniform > _inversePeriodUniform
osg::ref_ptr< PrecipitationDrawable > _quadPrecipitationDrawable