OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FluidFrictionOperator.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 //osgParticle - Copyright (C) 2002 Marco Jez
14 
15 #ifndef OSGPARTICLE_FLUIDFRICTIONOPERATOR
16 #define OSGPARTICLE_FLUIDFRICTIONOPERATOR 1
17 
18 #include <osgParticle/Export>
19 #include <osgParticle/Operator>
20 
21 #include <osg/CopyOp>
22 #include <osg/Object>
23 #include <osg/Math>
24 
25 namespace osgParticle
26 {
27 
28  class Particle;
29 
37  public:
38 
41 
43 
45  inline void setFluidDensity(float d);
46 
48  inline float getFluidDensity() const;
49 
51  inline void setFluidViscosity(float v);
52 
54  inline float getFluidViscosity() const;
55 
57  inline void setWind(const osg::Vec3& wind) { _wind = wind; }
58 
60  inline const osg::Vec3& getWind() const { return _wind; }
61 
63  inline void setOverrideRadius(float r);
64 
66  inline float getOverrideRadius() const;
67 
69  inline void setFluidToAir();
70 
72  inline void setFluidToWater();
73 
75  void operate(Particle* P, double dt);
76 
78  inline void beginOperate(Program* prg);
79 
80  protected:
83 
84  private:
85  float _coeff_A;
86  float _coeff_B;
87  float _density;
88  float _viscosity;
89  float _ovr_rad;
90  osg::Vec3 _wind;
91  Program* _current_program;
92  };
93 
94  // INLINE FUNCTIONS
95 
97  {
98  return _density;
99  }
100 
102  {
103  return _viscosity;
104  }
105 
107  {
108  _density = d;
109  _coeff_B = 0.2f * osg::PI * _density;
110  }
111 
113  {
114  _viscosity = v;
115  _coeff_A = 6 * osg::PI * _viscosity;
116  }
117 
119  {
120  setFluidViscosity(1.8e-5f);
121  setFluidDensity(1.2929f);
122  }
123 
125  {
126  setFluidViscosity(1.002e-3f);
127  setFluidDensity(1.0f);
128  }
129 
131  {
132  return _ovr_rad;
133  }
134 
136  {
137  _ovr_rad = r;
138  }
139 
141  {
142  _current_program = prg;
143  }
144 
145 }
146 
147 
148 #endif
float getOverrideRadius() const
Get the overriden radius value.
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
void beginOperate(Program *prg)
Perform some initializations. Do not call this method manually.
FluidFrictionOperator & operator=(const FluidFrictionOperator &)
float getFluidViscosity() const
Get the viscosity of the fluid.
#define OSGPARTICLE_EXPORT
Definition: Export.h:40
#define META_Object(library, name)
Definition: Object.h:42
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
void setFluidDensity(float d)
Set the density of the fluid.
void setOverrideRadius(float r)
Set the overriden radius value (pass 0 if you want to use particle's radius).
void setWind(const osg::Vec3 &wind)
Set the wind vector.
const osg::Vec3 & getWind() const
Get the wind vector.
void setFluidViscosity(float v)
Set the viscosity of the fluid.
const double PI
Definition: Math.h:30
float getFluidDensity() const
Get the density of the fluid.