Waterflow
Visualize water in terrain
|
This class can be used to create models from height maps. More...
#include <myDrawable.h>
Inherits myDrawable.
Inherited by Water.
Public Member Functions | |
HeightMap (GLuint drawProgram, GLuint *sizes, GLfloat maxHeight, GLuint inputHeightBuffer) | |
Simple contructor. | |
virtual void | draw () |
Draws the height field using the set draw program and texture. | |
void | generateHeightTexture () |
Generates the height data texture. | |
virtual void | update () |
Calculates the new vertex data from the height map buffer. | |
Static Public Member Functions | |
static void TW_CALL | GetTextureCB (void *value, void *clientData) |
Used by AntTweakBar to get which texture is in use. | |
static void TW_CALL | SetTextureCB (const void *value, void *clientData) |
Used by AntTweakBar to set which texture to use. | |
Protected Member Functions | |
void | initDraw () |
Sets the VAO pointers for drawing the model. | |
void | initUpdate () |
Creates the buffers and shader programs. | |
Protected Attributes | |
GLuint | dataHeight |
Height of the data in the height map. | |
GLfloat | dataTerrainHeight |
Diff between lowest and highest point in the height map. | |
GLuint | dataWidth |
Width of the data in the height map. | |
GLuint | drawBuffers [4] |
The vertice data buffers in order: Vertex coordinate, Texture Coordinate, Normals, Incides. | |
GLuint | drawVAO |
Vertex Array for the drawable information. | |
GLuint | heightBuffer |
Buffer with the height data information. | |
GLuint | heightMapProgram |
Compute shader that generates the rest of the vertex data. | |
GLuint | normalsProgram |
Compute shader for calculating the normals from a height map. | |
GLuint | numData |
Total number of vertices needed. | |
GLuint | numIndices |
Total number of indices needed. | |
GLuint | texnum |
Currently used texture. | |
GLuint | textureProgram |
Creates a texture with normal and height data, for use in other shaders where interpolation is important. |
This class can be used to create models from height maps.
Creates vertex data from a heightmap, generates vertices, normals, texture coordinates and indices for drawing.
Definition at line 104 of file myDrawable.h.
HeightMap::HeightMap | ( | GLuint | drawProgram, |
GLuint * | sizes, | ||
GLfloat | maxHeight, | ||
GLuint | inputHeightBuffer | ||
) |
Simple contructor.
Takes a few parameters for initial setup of the size of the height map data.
drawProgram | The initial program to use for drawing the model |
sizes | Width and Height of the data |
maxHeight | The height map maximum height (low assumed to be 0) |
inputHeightBuffer | Buffer ID of the height map data |
Definition at line 179 of file myDrawable.cpp.
void HeightMap::initDraw | ( | ) | [protected] |
Sets the VAO pointers for drawing the model.
Also uploads some of the static uniforms that are used for drawing.
Definition at line 230 of file myDrawable.cpp.
void HeightMap::initUpdate | ( | ) | [protected] |
Creates the buffers and shader programs.
Init for creating buffers and shaders used for creating and/or updating the model vertice data.
Definition at line 197 of file myDrawable.cpp.
void HeightMap::update | ( | ) | [virtual] |
Calculates the new vertex data from the height map buffer.
Calculates the normals first using sobel filters in x and z direction and then sets a height for y that makes the result look good (might need tuning). After that the rest of the data is pretty straight forward to generate.
Implements myDrawable.
Definition at line 298 of file myDrawable.cpp.