FluidFrictionOperator
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.
*/
//osgParticle - Copyright (C) 2002 Marco Jez
#ifndef OSGPARTICLE_FLUIDFRICTIONOPERATOR
#define OSGPARTICLE_FLUIDFRICTIONOPERATOR 1
#include <osgParticle/Export>
#include <osgParticle/Operator>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Math>
namespace osgParticle
{
class Particle;
class OSGPARTICLE_EXPORT FluidFrictionOperator: public Operator {
public:
FluidFrictionOperator();
FluidFrictionOperator(const FluidFrictionOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
META_Object(osgParticle, FluidFrictionOperator);
inline void setFluidDensity(float d);
inline float getFluidDensity() const;
inline void setFluidViscosity(float v);
inline float getFluidViscosity() const;
inline void setWind(const osg::Vec3& wind) { _wind = wind; }
inline const osg::Vec3& getWind() const { return _wind; }
inline void setOverrideRadius(float r);
inline float getOverrideRadius() const;
inline void setFluidToAir();
inline void setFluidToWater();
void operate(Particle* P, double dt);
inline void beginOperate(Program* prg);
protected:
virtual ~FluidFrictionOperator() {}
FluidFrictionOperator &operator=(const FluidFrictionOperator &) { return *this; }
private:
float _coeff_A;
float _coeff_B;
float _density;
float _viscosity;
float _ovr_rad;
osg::Vec3 _wind;
Program* _current_program;
};
// INLINE FUNCTIONS
inline float FluidFrictionOperator::getFluidDensity() const
{
return _density;
}
inline float FluidFrictionOperator::getFluidViscosity() const
{
return _viscosity;
}
inline void FluidFrictionOperator::setFluidDensity(float d)
{
_density = d;
_coeff_B = 0.2f * osg::PI * _density;
}
inline void FluidFrictionOperator::setFluidViscosity(float v)
{
_viscosity = v;
_coeff_A = 6 * osg::PI * _viscosity;
}
inline void FluidFrictionOperator::setFluidToAir()
{
setFluidViscosity(1.8e-5f);
setFluidDensity(1.2929f);
}
inline void FluidFrictionOperator::setFluidToWater()
{
setFluidViscosity(1.002e-3f);
setFluidDensity(1.0f);
}
inline float FluidFrictionOperator::getOverrideRadius() const
{
return _ovr_rad;
}
inline void FluidFrictionOperator::setOverrideRadius(float r)
{
_ovr_rad = r;
}
inline void FluidFrictionOperator::beginOperate(Program* prg)
{
_current_program = prg;
}
}
#endif
CopyOp
Math
Object
Operator
osgParticle::FluidFrictionOperator::setFluidToWater
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
Definition FluidFrictionOperator:124
osgParticle::FluidFrictionOperator::getOverrideRadius
float getOverrideRadius() const
Get the overriden radius value.
Definition FluidFrictionOperator:130
osgParticle::FluidFrictionOperator::getFluidViscosity
float getFluidViscosity() const
Get the viscosity of the fluid.
Definition FluidFrictionOperator:101
osgParticle::FluidFrictionOperator::~FluidFrictionOperator
virtual ~FluidFrictionOperator()
Definition FluidFrictionOperator:81
osgParticle::FluidFrictionOperator::getWind
const osg::Vec3 & getWind() const
Get the wind vector.
Definition FluidFrictionOperator:60
osgParticle::FluidFrictionOperator::FluidFrictionOperator
FluidFrictionOperator(const FluidFrictionOperator &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgParticle::FluidFrictionOperator::setWind
void setWind(const osg::Vec3 &wind)
Set the wind vector.
Definition FluidFrictionOperator:57
osgParticle::FluidFrictionOperator::setOverrideRadius
void setOverrideRadius(float r)
Set the overriden radius value (pass 0 if you want to use particle's radius).
Definition FluidFrictionOperator:135
osgParticle::FluidFrictionOperator::operator=
FluidFrictionOperator & operator=(const FluidFrictionOperator &)
Definition FluidFrictionOperator:82
osgParticle::FluidFrictionOperator::operate
void operate(Particle *P, double dt)
Apply the friction forces to a particle. Do not call this method manually.
osgParticle::FluidFrictionOperator::setFluidViscosity
void setFluidViscosity(float v)
Set the viscosity of the fluid.
Definition FluidFrictionOperator:112
osgParticle::FluidFrictionOperator::FluidFrictionOperator
FluidFrictionOperator()
osgParticle::FluidFrictionOperator::beginOperate
void beginOperate(Program *prg)
Perform some initializations. Do not call this method manually.
Definition FluidFrictionOperator:140
osgParticle::FluidFrictionOperator::getFluidDensity
float getFluidDensity() const
Get the density of the fluid.
Definition FluidFrictionOperator:96
osgParticle::FluidFrictionOperator::setFluidToAir
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
Definition FluidFrictionOperator:118
osgParticle::FluidFrictionOperator::META_Object
META_Object(osgParticle, FluidFrictionOperator)
osgParticle::FluidFrictionOperator::setFluidDensity
void setFluidDensity(float d)
Set the density of the fluid.
Definition FluidFrictionOperator:106
osgParticle::Operator::Operator
Operator()
Definition Operator:92
osgParticle::Particle
Definition Particle:47
osgParticle::Program
Definition osgParticle/Program:36
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