OpenSceneGraph 3.6.5
FluidProgram
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
25namespace osgParticle
26{
27
34 public:
37
39
41 inline void setFluidViscosity(float v)
42 {
43 _viscosity = v;
45 }
46
48 inline float getFluidViscosity() const { return _viscosity; }
49
51 inline void setFluidDensity(float d)
52 {
53 _density = d;
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
104 float _density;
106
109 };
110
111
112}
113
114#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
float getFluidDensity() const
Get the density of the fluid.
Definition FluidProgram:58
virtual void execute(double dt)
Execute the program on the particle system. Must be overridden in descendant classes.
float _density
Definition FluidProgram:104
FluidProgram(const FluidProgram &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
const osg::Vec3 & getWind() const
Get the wind vector.
Definition FluidProgram:65
const osg::Vec3 & getAcceleration() const
Get the acceleration vector.
Definition FluidProgram:71
void setFluidToWater()
Set the fluid parameters as for pure water (20°C temperature).
Definition FluidProgram:87
float getFluidViscosity() const
Get the viscosity of the fluid.
Definition FluidProgram:48
float _densityCoefficient
Definition FluidProgram:108
osg::Vec3 _acceleration
Definition FluidProgram:102
osg::Vec3 _wind
Definition FluidProgram:105
void setAcceleration(const osg::Vec3 &v)
Set the acceleration vector.
Definition FluidProgram:68
virtual ~FluidProgram()
Definition FluidProgram:97
float _viscosity
Definition FluidProgram:103
void setFluidDensity(float d)
Set the density of the fluid.
Definition FluidProgram:51
META_Node(osgParticle, FluidProgram)
void setToGravity(float scale=1.0f)
Set the acceleration vector to the gravity on earth (0, 0, -9.81).
Definition FluidProgram:76
void setWind(const osg::Vec3 &wind)
Set the wind vector.
Definition FluidProgram:62
void setFluidToAir()
Set the fluid parameters as for air (20°C temperature).
Definition FluidProgram:79
float _viscosityCoefficient
Definition FluidProgram:107
FluidProgram & operator=(const FluidProgram &)
Definition FluidProgram:98
void setFluidViscosity(float v)
Set the viscosity of the fluid.
Definition FluidProgram:41
#define OSGPARTICLE_EXPORT
Definition Export:40

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