OpenSceneGraph 3.6.5
FluidFrictionOperator
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
25namespace 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
Vec3f Vec3
Definition Vec3:21
const double PI
Definition Math:30
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
Definition FluidFrictionOperator:124
float getOverrideRadius() const
Get the overriden radius value.
Definition FluidFrictionOperator:130
float getFluidViscosity() const
Get the viscosity of the fluid.
Definition FluidFrictionOperator:101
virtual ~FluidFrictionOperator()
Definition FluidFrictionOperator:81
const osg::Vec3 & getWind() const
Get the wind vector.
Definition FluidFrictionOperator:60
FluidFrictionOperator(const FluidFrictionOperator &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void setWind(const osg::Vec3 &wind)
Set the wind vector.
Definition FluidFrictionOperator:57
void setOverrideRadius(float r)
Set the overriden radius value (pass 0 if you want to use particle's radius).
Definition FluidFrictionOperator:135
FluidFrictionOperator & operator=(const FluidFrictionOperator &)
Definition FluidFrictionOperator:82
void operate(Particle *P, double dt)
Apply the friction forces to a particle. Do not call this method manually.
void setFluidViscosity(float v)
Set the viscosity of the fluid.
Definition FluidFrictionOperator:112
void beginOperate(Program *prg)
Perform some initializations. Do not call this method manually.
Definition FluidFrictionOperator:140
float getFluidDensity() const
Get the density of the fluid.
Definition FluidFrictionOperator:96
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
Definition FluidFrictionOperator:118
META_Object(osgParticle, FluidFrictionOperator)
void setFluidDensity(float d)
Set the density of the fluid.
Definition FluidFrictionOperator:106
Operator()
Definition Operator:92
Implementation of a particle.
Definition Particle:47
An abstract ParticleProcessor descendant for modifying particles "on the fly" during the cull travers...
Definition Program:36
#define OSGPARTICLE_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.