Eulerian Smoke Simulation on the GPU
|
00001 #ifndef __FLUID_ENGINE_H__ 00002 #define __FLUID_ENGINE_H__ 00003 00004 //----------------------------------------------------------- 00007 //----------------------------------------------------------- 00008 00009 #include <ngl/TransformStack.h> 00010 #include "ComputeEngine.h" 00011 #include "GasSolver.h" 00012 #include "ImageUnitStack.h" 00013 #include "VertexArrayObject.h" 00014 #include "VolumeMesher.h" 00015 #include "VolumeSlicer.h" 00016 00025 class FluidEngine 00026 { 00027 public: 00029 enum RenderField{ 00030 VELOCITY, 00031 PRESSURE, 00032 TEMPERATURE, 00033 DENSITY 00034 }; 00035 00040 FluidEngine( 00041 int _simResX, 00042 int _simResY, 00043 int _simResZ 00044 ); 00045 00047 ~FluidEngine(); 00048 00050 void init(); 00051 00053 void updateOutputs(); 00054 00057 void drawMesh( 00058 RenderField _field, 00059 ngl::TransformStack &_transformStack 00060 ); 00061 00064 void setIsoLevel( 00065 float _isoLevel 00066 ); 00067 00070 void setSamplingChannel( 00071 int _channelIndex 00072 ); 00073 00076 void setMeshingMethod( 00077 int _meshingMethod 00078 ); 00079 00084 void setMeshColour( 00085 float _r, 00086 float _g, 00087 float _b 00088 ); 00089 00092 void drawSlice( 00093 RenderField _field, 00094 ngl::TransformStack &_transformStack 00095 ); 00096 00099 void setSliceOpacity( 00100 float _opacity 00101 ); 00102 00105 void setSlicePos( 00106 int _slicePos 00107 ); 00108 00111 void drawObstacles( 00112 ngl::TransformStack &_transformStack 00113 ); 00114 00117 void drawContainer( 00118 ngl::TransformStack &_transformStack 00119 ); 00120 00124 void passViewProjectionMatrix( 00125 ngl::Matrix _modelView, 00126 ngl::Matrix _projection 00127 ); 00128 00130 int getSimResX() const {return m_simResX;} 00132 int getSimResY() const {return m_simResY;} 00134 int getSimResZ() const {return m_simResZ;} 00135 00137 void resetResolution(); 00138 00140 inline GasSolver* getGasSolver() const {return m_gasSolver;} 00141 00144 void setObstacleGeometry( 00145 int _geoIndex 00146 ); 00147 00150 inline void setCellSize( 00151 float _cellSize 00152 ) 00153 { 00154 m_gasSolver->setCellSize(_cellSize); 00155 } 00156 00159 inline void setSplatRadius( 00160 float _splatRadius 00161 ) 00162 { 00163 00164 m_gasSolver->setSplatRadius(_splatRadius); 00165 } 00166 00169 inline void setAmbientTemperature( 00170 float _ambientTemperature 00171 ) 00172 { 00173 m_gasSolver->setAmbientTemperature(_ambientTemperature); 00174 } 00175 00178 inline void setImpulseTemperature( 00179 float _impulseTemperature 00180 ) 00181 { 00182 m_gasSolver->setImpulseTemperature(_impulseTemperature); 00183 } 00184 00187 inline void setImpulseDensity( 00188 float _impulseDensity 00189 ) 00190 { 00191 m_gasSolver->setImpulseDensity(_impulseDensity); 00192 } 00193 00198 inline void setImpulsePosition( 00199 float _posX, 00200 float _posY, 00201 float _posZ 00202 ) 00203 { 00204 m_gasSolver->setImpulsePosition(_posX, _posY, _posZ); 00205 } 00206 00209 inline void setPoissonIterations( 00210 int _numPoissonIterations 00211 ) 00212 { 00213 m_gasSolver->setPoissonIterations(_numPoissonIterations); 00214 } 00215 00218 inline void setTimestep( 00219 float _timestep 00220 ) 00221 { 00222 m_gasSolver->setTimestep(_timestep); 00223 } 00224 00227 inline void setBuoyancyLift( 00228 float _buoyancyLift 00229 ) 00230 { 00231 m_gasSolver->setBuoyancyLift(_buoyancyLift); 00232 } 00233 00236 inline void setGasWeight( 00237 float _gasWeight 00238 ) 00239 { 00240 m_gasSolver->setGasWeight(_gasWeight); 00241 } 00242 00247 inline void setBuoyancyDirection( 00248 float _dirX, 00249 float _dirY, 00250 float _dirZ 00251 ) 00252 { 00253 m_gasSolver->setBuoyancyDirection(_dirX, _dirY, _dirZ); 00254 } 00255 00258 inline void togglePeriodicNoise( 00259 bool _enablePeriodicNoise 00260 ) 00261 { 00262 m_gasSolver->togglePeriodicNoise(_enablePeriodicNoise); 00263 } 00264 00269 inline void setNoiseVariance( 00270 float _noiseVarianceX, 00271 float _noiseVarianceY, 00272 float _noiseVarianceZ 00273 ) 00274 { 00275 m_gasSolver->setNoiseVariance( 00276 _noiseVarianceX, 00277 _noiseVarianceY, 00278 _noiseVarianceZ 00279 ); 00280 } 00281 00286 inline void setNoiseDrivingFunc( 00287 int _funcIndexX, 00288 int _funcIndexY, 00289 int _funcIndexZ 00290 ) 00291 { 00292 m_gasSolver->setNoiseDrivingFunc( 00293 _funcIndexX, 00294 _funcIndexY, 00295 _funcIndexZ 00296 ); 00297 } 00298 00299 00302 inline void setTemperatureDissipation( 00303 float _temperatureDissipation 00304 ) 00305 { 00306 m_gasSolver->setTemperatureDissipation(_temperatureDissipation); 00307 } 00308 00311 inline void setDensityDissipation( 00312 float _densityDissipation 00313 ) 00314 { 00315 m_gasSolver->setDensityDissipation(_densityDissipation); 00316 } 00317 00320 inline void setVelocityDissipation( 00321 float _velocityDissipation 00322 ) 00323 { 00324 m_gasSolver->setVelocityDissipation(_velocityDissipation); 00325 } 00326 00327 private: 00329 int m_simResX; 00331 int m_simResY; 00333 int m_simResZ; 00334 00336 ComputeEngine* m_compute; 00338 ImageUnitStack* m_imageUnitStack; 00340 GasSolver* m_gasSolver; 00342 VolumeMesher* m_volumeMesher; 00344 VolumeSlicer* m_volumeSlicer; 00345 00347 float m_meshIsoLevel; 00349 int m_meshSamplingChannel; 00351 ngl::Colour* m_meshColour; 00352 00354 VertexArrayObject* m_containerVAO; 00355 }; 00356 00357 #endif // __FLUID_ENGINE_H__