FluidProgram
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* 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
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGPARTICLE_FLUIDPROGRAM
#define OSGPARTICLE_FLUIDPROGRAM 1
#include <osgParticle/Export>
#include <osgParticle/Program>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Node>
#include <osg/NodeVisitor>
namespace osgParticle
{
class OSGPARTICLE_EXPORT FluidProgram: public Program {
public:
FluidProgram();
FluidProgram(const FluidProgram& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
META_Node(osgParticle,FluidProgram);
inline void setFluidViscosity(float v)
{
_viscosity = v;
_viscosityCoefficient = 6 * osg::PI * _viscosity;
}
inline float getFluidViscosity() const { return _viscosity; }
inline void setFluidDensity(float d)
{
_density = d;
_densityCoefficient = 0.2f * osg::PI * _density;
}
inline float getFluidDensity() const { return _density; }
inline void setWind(const osg::Vec3& wind) { _wind = wind; }
inline const osg::Vec3& getWind() const { return _wind; }
inline void setAcceleration(const osg::Vec3& v) { _acceleration = v; }
inline const osg::Vec3& getAcceleration() const { return _acceleration; }
inline void setToGravity(float scale = 1.0f) { _acceleration.set(0, 0, -9.81f*scale); }
inline void setFluidToAir()
{
setToGravity(1.0f);
setFluidDensity(1.2929f);
setFluidViscosity(1.8e-5f);
}
inline void setFluidToWater()
{
setToGravity(1.0f);
setFluidDensity(1.0f);
setFluidViscosity(1.002e-3f);
}
protected:
virtual ~FluidProgram() {}
FluidProgram& operator=(const FluidProgram&) { return *this; }
virtual void execute(double dt);
osg::Vec3 _acceleration;
float _viscosity;
float _density;
osg::Vec3 _wind;
float _viscosityCoefficient;
float _densityCoefficient;
};
}
#endif
CopyOp
NodeVisitor
Node
Object
osgParticle::FluidProgram::getFluidDensity
float getFluidDensity() const
Get the density of the fluid.
Definition FluidProgram:58
osgParticle::FluidProgram::execute
virtual void execute(double dt)
Execute the program on the particle system. Must be overridden in descendant classes.
osgParticle::FluidProgram::_density
float _density
Definition FluidProgram:104
osgParticle::FluidProgram::FluidProgram
FluidProgram(const FluidProgram &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgParticle::FluidProgram::getWind
const osg::Vec3 & getWind() const
Get the wind vector.
Definition FluidProgram:65
osgParticle::FluidProgram::getAcceleration
const osg::Vec3 & getAcceleration() const
Get the acceleration vector.
Definition FluidProgram:71
osgParticle::FluidProgram::setFluidToWater
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
Definition FluidProgram:87
osgParticle::FluidProgram::getFluidViscosity
float getFluidViscosity() const
Get the viscosity of the fluid.
Definition FluidProgram:48
osgParticle::FluidProgram::_densityCoefficient
float _densityCoefficient
Definition FluidProgram:108
osgParticle::FluidProgram::_acceleration
osg::Vec3 _acceleration
Definition FluidProgram:102
osgParticle::FluidProgram::_wind
osg::Vec3 _wind
Definition FluidProgram:105
osgParticle::FluidProgram::FluidProgram
FluidProgram()
osgParticle::FluidProgram::setAcceleration
void setAcceleration(const osg::Vec3 &v)
Set the acceleration vector.
Definition FluidProgram:68
osgParticle::FluidProgram::~FluidProgram
virtual ~FluidProgram()
Definition FluidProgram:97
osgParticle::FluidProgram::_viscosity
float _viscosity
Definition FluidProgram:103
osgParticle::FluidProgram::setFluidDensity
void setFluidDensity(float d)
Set the density of the fluid.
Definition FluidProgram:51
osgParticle::FluidProgram::META_Node
META_Node(osgParticle, FluidProgram)
osgParticle::FluidProgram::setToGravity
void setToGravity(float scale=1.0f)
Definition FluidProgram:76
osgParticle::FluidProgram::setWind
void setWind(const osg::Vec3 &wind)
Set the wind vector.
Definition FluidProgram:62
osgParticle::FluidProgram::setFluidToAir
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
Definition FluidProgram:79
osgParticle::FluidProgram::_viscosityCoefficient
float _viscosityCoefficient
Definition FluidProgram:107
osgParticle::FluidProgram::operator=
FluidProgram & operator=(const FluidProgram &)
Definition FluidProgram:98
osgParticle::FluidProgram::setFluidViscosity
void setFluidViscosity(float v)
Set the viscosity of the fluid.
Definition FluidProgram:41
osgParticle::Program::Program
Program()
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osgParticle
Definition AccelOperator:27
osg::Vec3
Vec3f Vec3
Definition Vec3:21
osg::PI
const double PI
Definition Math:30
Export
OSGPARTICLE_EXPORT
#define OSGPARTICLE_EXPORT
Definition osgParticle/Export:40
Program