- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgParticle/FluidFrictionOperator
r5328 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 26 26 { 27 27 28 class Particle; 28 class Particle; 29 29 30 30 /** An operator that simulates the friction of a fluid. 31 31 By using this operator you can let the particles move in a fluid of a given <I>density</I> 32 32 and <I>viscosity</I>. There are two functions to quickly setup the parameters for pure water 33 and air. You can decide whether to compute the forces using the particle's physical 33 and air. You can decide whether to compute the forces using the particle's physical 34 34 radius or another value, by calling the <CODE>setOverrideRadius()</CODE> method. 35 35 */ 36 36 class OSGPARTICLE_EXPORT FluidFrictionOperator: public Operator { 37 37 public: 38 38 39 39 FluidFrictionOperator(); 40 40 FluidFrictionOperator(const FluidFrictionOperator& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); 41 41 42 42 META_Object(osgParticle, FluidFrictionOperator); 43 43 44 44 /// Set the density of the fluid. 45 45 inline void setFluidDensity(float d); … … 47 47 /// Get the density of the fluid. 48 48 inline float getFluidDensity() const; 49 49 50 50 /// Set the viscosity of the fluid. 51 51 inline void setFluidViscosity(float v); 52 52 53 53 /// Get the viscosity of the fluid. 54 54 inline float getFluidViscosity() const; 55 55 56 56 /// Set the wind vector. 57 57 inline void setWind(const osg::Vec3& wind) { _wind = wind; } 58 58 59 59 /// Get the wind vector. 60 60 inline const osg::Vec3& getWind() const { return _wind; } 61 61 62 62 /// Set the overriden radius value (pass 0 if you want to use particle's radius). 63 63 inline void setOverrideRadius(float r); 64 64 65 65 /// Get the overriden radius value. 66 inline float getOverrideRadius() const; 67 66 inline float getOverrideRadius() const; 67 68 68 /// Set the fluid parameters as for air (20°C temperature). 69 69 inline void setFluidToAir(); 70 70 71 71 /// Set the fluid parameters as for pure water (20°C temperature). 72 72 inline void setFluidToWater(); 73 73 74 74 /// Apply the friction forces to a particle. Do not call this method manually. 75 75 void operate(Particle* P, double dt); 76 76 77 77 /// Perform some initializations. Do not call this method manually. 78 78 inline void beginOperate(Program* prg); 79 79 80 80 protected: 81 81 virtual ~FluidFrictionOperator() {} 82 82 FluidFrictionOperator &operator=(const FluidFrictionOperator &) { return *this; } 83 83 84 84 private: 85 85 float _coeff_A; … … 91 91 Program* _current_program; 92 92 }; 93 93 94 94 // INLINE FUNCTIONS 95 95 96 96 inline float FluidFrictionOperator::getFluidDensity() const 97 97 { … … 103 103 return _viscosity; 104 104 } 105 105 106 106 inline void FluidFrictionOperator::setFluidDensity(float d) 107 107 { … … 115 115 _coeff_A = 6 * osg::PI * _viscosity; 116 116 } 117 117 118 118 inline void FluidFrictionOperator::setFluidToAir() 119 119 { … … 127 127 setFluidDensity(1.0f); 128 128 } 129 129 130 130 inline float FluidFrictionOperator::getOverrideRadius() const 131 131 { 132 132 return _ovr_rad; 133 133 } 134 134 135 135 inline void FluidFrictionOperator::setOverrideRadius(float r) 136 136 { 137 137 _ovr_rad = r; 138 138 } 139 139 140 140 inline void FluidFrictionOperator::beginOperate(Program* prg) 141 141 {
