Waterflow
Visualize water in terrain
|
Loads and modifies terrain data for easier use. More...
#include <readData.h>
Public Member Functions | |
DataHandler (const char *inputfile) | |
Reads DEM data, scales it and generates a model. | |
~DataHandler () | |
Handle the internal pointers. | |
float | getCoord (int col, int row) |
Returns a datapoint from the mapdata. | |
float * | getData () |
Get a pointer to the mapdata data. | |
int | getDataHeight () |
Getter for the height of the data. | |
int | getDataWidth () |
Getter for the width of the data. | |
int | getElem () |
Getter for the number of datapoints. | |
GLuint | getHeightBuffer () |
Get the buffer ID containing the height data. | |
GLfloat | getTerrainScale () |
Get the terrain scale. | |
GLfloat | giveHeight (GLfloat x, GLfloat z) |
Gives a height for a certain position in the terrain. | |
Private Member Functions | |
void | normConvCompute () |
Performs normalized convolution of the input data as a single computeshader. | |
void | readDEM (const char *inputfile) |
Reads the input data to the private mapdata struct. | |
Private Attributes | |
mapdata * | readdata |
mapdata struct for the loaded terrain data. | |
GLuint | terrainBufferID |
terrainheight buffer corresponding to readdata data but on GPU. | |
GLfloat | terrainScale |
Height scale for the terrain. Calculated as the diff between min and max in the input data. |
Loads and modifies terrain data for easier use.
Use the DataHandler class to import terrain data and generate terrain. It automatically scales the data for easier filtering, and also generates an initial terrain from the data after the data is loaded.
Definition at line 36 of file readData.h.
DataHandler::DataHandler | ( | const char * | inputfile | ) |
Reads DEM data, scales it and generates a model.
Reads the inputfile for DEM data and populates a mapdata struct, and creates the buffer for Normalized convolution and finally generates an initial terrain height map.
inputfile | path to DEM data. |
Definition at line 15 of file readData.cpp.
float DataHandler::getCoord | ( | int | col, |
int | row | ||
) |
Returns a datapoint from the mapdata.
Simplifies the getting of data by allowing access by coordinate since the data is stored in a linear vector.
col | input column |
row | input row |
Definition at line 33 of file readData.cpp.
float* DataHandler::getData | ( | ) | [inline] |
Get a pointer to the mapdata data.
For uses like read all data to FBO or from GPU back to CPU.
Definition at line 73 of file readData.h.
int DataHandler::getDataHeight | ( | ) | [inline] |
Getter for the height of the data.
Definition at line 81 of file readData.h.
int DataHandler::getDataWidth | ( | ) | [inline] |
Getter for the width of the data.
Definition at line 77 of file readData.h.
int DataHandler::getElem | ( | ) | [inline] |
Getter for the number of datapoints.
Definition at line 85 of file readData.h.
GLuint DataHandler::getHeightBuffer | ( | ) | [inline] |
Get the buffer ID containing the height data.
Definition at line 93 of file readData.h.
GLfloat DataHandler::getTerrainScale | ( | ) | [inline] |
Get the terrain scale.
Definition at line 89 of file readData.h.
GLfloat DataHandler::giveHeight | ( | GLfloat | x, |
GLfloat | z | ||
) |
Gives a height for a certain position in the terrain.
Used if the interpolated height data for a certain point is needed Written by Ingemar Ragnemalm but slightly modfied
x | input width position |
z | input depth position |
Definition at line 53 of file readData.cpp.
void DataHandler::normConvCompute | ( | ) | [private] |
Performs normalized convolution of the input data as a single computeshader.
At the end of the function terrainBufferID containins the buffer ID to the heightmap. The heightmap is also stored in the terrainTexture and will be bound to texture 3
Definition at line 165 of file readData.cpp.
void DataHandler::readDEM | ( | const char * | inputfile | ) | [private] |
Reads the input data to the private mapdata struct.
Currently uses readFile to bulk read the file and then reads out the data info with sscanf and then another implementation of strtof to convert the data to floats.
inputfile | path to DEM data file. |
Definition at line 108 of file readData.cpp.