Waterflow
Visualize water in terrain
HeightMap Class Reference

This class can be used to create models from height maps. More...

#include <myDrawable.h>

Inherits myDrawable.

Inherited by Water.

List of all members.

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.

Detailed Description

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.


Constructor & Destructor Documentation

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.

Parameters:
drawProgramThe initial program to use for drawing the model
sizesWidth and Height of the data
maxHeightThe height map maximum height (low assumed to be 0)
inputHeightBufferBuffer ID of the height map data

Definition at line 179 of file myDrawable.cpp.


Member Function Documentation

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.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations