OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FluidProgram.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSGPARTICLE_FLUIDPROGRAM
15 #define OSGPARTICLE_FLUIDPROGRAM 1
16 
17 #include <osgParticle/Export>
18 #include <osgParticle/Program>
19 
20 #include <osg/CopyOp>
21 #include <osg/Object>
22 #include <osg/Node>
23 #include <osg/NodeVisitor>
24 
25 namespace osgParticle
26 {
27 
34  public:
35  FluidProgram();
36  FluidProgram(const FluidProgram& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
37 
39 
41  inline void setFluidViscosity(float v)
42  {
43  _viscosity = v;
44  _viscosityCoefficient = 6 * osg::PI * _viscosity;
45  }
46 
48  inline float getFluidViscosity() const { return _viscosity; }
49 
51  inline void setFluidDensity(float d)
52  {
53  _density = d;
54  _densityCoefficient = 0.2f * osg::PI * _density;
55  }
56 
58  inline float getFluidDensity() const { return _density; }
59 
60 
62  inline void setWind(const osg::Vec3& wind) { _wind = wind; }
63 
65  inline const osg::Vec3& getWind() const { return _wind; }
66 
68  inline void setAcceleration(const osg::Vec3& v) { _acceleration = v; }
69 
71  inline const osg::Vec3& getAcceleration() const { return _acceleration; }
72 
76  inline void setToGravity(float scale = 1.0f) { _acceleration.set(0, 0, -9.81f*scale); }
77 
79  inline void setFluidToAir()
80  {
81  setToGravity(1.0f);
82  setFluidDensity(1.2929f);
83  setFluidViscosity(1.8e-5f);
84  }
85 
87  inline void setFluidToWater()
88  {
89  setToGravity(1.0f);
90  setFluidDensity(1.0f);
91  setFluidViscosity(1.002e-3f);
92  }
93 
94 
95  protected:
96 
97  virtual ~FluidProgram() {}
98  FluidProgram& operator=(const FluidProgram&) { return *this; }
99 
100  virtual void execute(double dt);
101 
103  float _viscosity;
104  float _density;
106 
109  };
110 
111 
112 }
113 
114 #endif
float getFluidViscosity() const
Get the viscosity of the fluid.
Definition: FluidProgram.h:48
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
Definition: FluidProgram.h:79
void setAcceleration(const osg::Vec3 &v)
Set the acceleration vector.
Definition: FluidProgram.h:68
#define META_Node(library, name)
Definition: Node.h:59
const osg::Vec3 & getWind() const
Get the wind vector.
Definition: FluidProgram.h:65
#define OSGPARTICLE_EXPORT
Definition: Export.h:40
void setFluidDensity(float d)
Set the density of the fluid.
Definition: FluidProgram.h:51
float getFluidDensity() const
Get the density of the fluid.
Definition: FluidProgram.h:58
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
Definition: FluidProgram.h:87
void setFluidViscosity(float v)
Set the viscosity of the fluid.
Definition: FluidProgram.h:41
void setToGravity(float scale=1.0f)
Definition: FluidProgram.h:76
const double PI
Definition: Math.h:30
void setWind(const osg::Vec3 &wind)
Set the wind vector.
Definition: FluidProgram.h:62
FluidProgram & operator=(const FluidProgram &)
Definition: FluidProgram.h:98
const osg::Vec3 & getAcceleration() const
Get the acceleration vector.
Definition: FluidProgram.h:71