Eulerian Smoke Simulation on the GPU
|
00001 #ifndef __IMPLICIT_SURFACE_H__ 00002 #define __IMPLICIT_SURFACE_H__ 00003 00004 //----------------------------------------------------------------- 00007 //----------------------------------------------------------------- 00008 00009 #include <ngl/Vector.h> 00010 #include <boost/math/special_functions/acosh.hpp> 00011 #include <boost/math/special_functions/atanh.hpp> 00012 #include <boost/math/special_functions/pow.hpp> 00013 00021 class ImplicitSurface 00022 { 00023 public: 00024 friend class Obstacle; 00025 00027 ImplicitSurface(); 00028 00030 ~ImplicitSurface(); 00031 00036 void sampleSphere( 00037 int _resX, 00038 int _resY, 00039 int _resZ 00040 ); 00041 00046 void sampleTorus( 00047 int _resX, 00048 int _resY, 00049 int _resZ 00050 ); 00051 00056 void sampleDoubleTorus( 00057 int _resX, 00058 int _resY, 00059 int _resZ 00060 ); 00061 00066 void sampleCayley( 00067 int _resX, 00068 int _resY, 00069 int _resZ 00070 ); 00071 00076 void sampleMandelbulb( 00077 int _resX, 00078 int _resY, 00079 int _resZ 00080 ); 00081 00086 void sampleHeart( 00087 int _resX, 00088 int _resY, 00089 int _resZ 00090 ); 00091 00096 void clearField( 00097 int _resX, 00098 int _resY, 00099 int _resZ 00100 ); 00101 00103 inline float* getScalarField() const {return &m_scalFieldData[0];} 00104 00106 inline int getResX() const {return m_resX;} 00108 inline int getResY() const {return m_resY;} 00110 inline int getResZ() const {return m_resZ;} 00111 00112 private: 00114 float *m_scalFieldData; 00115 00117 int m_resX; 00119 int m_resY; 00121 int m_resZ; 00122 00123 private: 00127 float sphereFunc( 00128 ngl::Vector _coords, 00129 float _r 00130 ); 00131 00136 float torusFunc( 00137 ngl::Vector _coords, 00138 float _r, 00139 float _R 00140 ); 00141 00144 float doubleTorusFunc( 00145 ngl::Vector _coords 00146 ); 00147 00150 float cayleyFunc( 00151 ngl::Vector _coords 00152 ); 00153 00157 float mandelbulbFunc( 00158 ngl::Vector _coords, 00159 int _n 00160 ); 00161 00164 float heartFunc( 00165 ngl::Vector _coords 00166 ); 00167 00168 00173 inline ngl::Vector normalizeTuple( 00174 int _i, 00175 int _j, 00176 int _k 00177 ) 00178 { 00179 return ngl::Vector( 00180 2.0f/m_resX*_i - 1.0f, 00181 2.0f/m_resY*_j - 1.0f, 00182 2.0f/m_resZ*_k - 1.0f 00183 ); 00184 } 00185 00190 inline int index1D( 00191 int _i, 00192 int _j, 00193 int _k 00194 ) 00195 { 00196 return _i + _j*m_resX + _k*m_resX*m_resY; 00197 } 00198 }; 00199 00200 #endif // __IMPLICIT_SURFACE_H__