Waterflow
Visualize water in terrain
|
00001 00002 00003 00004 #ifndef HEIGHTFIELD_H 00005 #define HEIGHTFIELD_H 00006 #include "readData.h" 00007 #include "glm.hpp" 00008 #include "gtc/type_ptr.hpp" 00009 #include <vector> 00010 #include "xmlParsing.h" 00011 #include "flowSource.h" 00012 00015 class HeightField { 00016 private: 00017 GLuint numVoxels; 00018 GLuint voxelShader; 00019 GLuint voxelBuffer; 00020 GLuint voxelVAO; 00021 00022 const static int width = 50; 00023 const static int height = 50; 00024 00025 GLfloat u[width][height]; 00026 GLfloat unew[width][height]; 00027 GLfloat v[width][height]; 00028 std::vector<GLuint>* voxelPositions; 00029 00030 const static GLint samp = 1; 00031 GLfloat totTime; 00032 00033 GLuint texWidth; 00034 GLuint texHeight; 00035 00036 DataHandler* terr; 00037 00038 std::vector<Flood_Fill_data*> flood; 00039 00043 int clip(int n, int lower, int upper); 00044 00045 00049 float clipf(GLfloat n, GLfloat lower, GLfloat upper); 00050 00057 void initFloodFill(float* u); 00058 00059 00060 std::vector<FlowSource*> xmlFlow; 00061 float vol0; 00062 00063 GLuint drawBuffers[4]; 00064 00070 void updateSim(GLfloat); 00071 00076 void render(); 00077 00082 void initDraw(); 00083 00088 void initTest(); 00089 00094 void updateVoxelrender(); 00095 00100 void drawVoxels(glm::mat4 projectionMatrix, glm::mat4 viewMatrix); 00101 00106 std::vector<GLuint>* getVoxelPositions(); 00107 00108 00109 GLuint fieldProgram; 00110 GLuint addProgram; 00111 00112 00113 public: 00114 00115 GLuint fieldBuffers[5]; 00116 00122 void floodFill(float* u, int x, int z, float height); 00123 00128 void measureVolume(); 00129 00147 00148 HeightField(DataHandler *t, std::vector<Flood_Fill_data*> FFDataIn, std::vector<FlowSource*> FlowsourcesIN); 00149 00156 void initGPU(float** heightArray, float** velocityArray); 00157 00163 void runSimGPU(GLfloat dt = 1.0f / 30.0f); 00164 00170 GLfloat getHeight(int i, int j, GLfloat ourHeight); 00171 00182 void saveData(float** heightArray, float** velocityArray); 00183 }; 00184 #endif