#include <mesh.h>
Public Member Functions | |
| Mesh () | |
| Constructor for mesh. | |
| ~Mesh () | |
| Destructor for mesh. | |
| void | GenerateGrid (int resX, int resY, float x0, float x1, float y0, float y1, bool vertical) |
| Generates a grid. | |
| bool | LoadHeightMap (const char *filename, float x0, float x1, float y0, float y1, float h0, float h1) |
| Generate grid from heightmap texture. | |
| void | CreateVBO () |
| Creates a Vertex Buffer Object (VBO). | |
| void | DeleteVBO () |
| Deletes a Vertex Buffer Object (VBO). | |
| void | DrawOpenGL () |
| Draws the grid in OpenGL. | |
| void | DrawVBO () |
| Draws the grid as a Vertex Buffer Object (VBO). | |
| unsigned int | GetNumTriangles () |
| Calculates the number of triangles (faces) in the grid. | |
Data Fields | |
| float | hmin |
| float | hmax |
Private Member Functions | |
| void | m_AddVertex (float x, float y, float z, Vec3f &normal) |
| Adds a vertex in the list of vertices. | |
| void | m_Clear () |
| Clears the vertex list and the face list. | |
| void | m_ReadHeight (int x, int z, float dx, float dz, float h0, float h1, unsigned char *data, int bytesPerPixel, int width, int height, float &h, Vec3f &n) |
| Convert pixel values to a height value and a normal. | |
Private Attributes | |
| int | m_numVertices |
| int | m_numFaces |
| GLfloat * | m_vertArray |
| GLuint * | m_faceArray |
| GLuint | m_vertexVBO |
| GLuint | m_indexVBO |
Defines a horizontal or vertical grid. Support for VBO also included.
| Mesh::Mesh | ( | ) |
Constructor for mesh.
| Mesh::~Mesh | ( | ) |
Destructor for mesh.
| void Mesh::GenerateGrid | ( | int | resX, | |
| int | resY, | |||
| float | x0, | |||
| float | x1, | |||
| float | y0, | |||
| float | y1, | |||
| bool | vertical | |||
| ) |
Generates a grid.
Generates a rectangular grid between (x0,y0) and (x1,y1). If vertical is TRUE the grid will be in the xy-plane, otherwise it will be in the xz-plane.
| resX | the resolution in the x direction. | |
| resY | the resolution in the y(z) direction. | |
| x0 | the x component of the starting point. | |
| x1 | the x component of the ending point. | |
| y0 | the y component of the starting point. | |
| y1 | the y component of the ending point. | |
| vertical | decides if the grid is vertical or horizontal. |
| bool Mesh::LoadHeightMap | ( | const char * | filename, | |
| float | x0, | |||
| float | x1, | |||
| float | z0, | |||
| float | z1, | |||
| float | h0, | |||
| float | h1 | |||
| ) |
Generate grid from heightmap texture.
Load a TGA-image and create a mesh with the same resolution and set the gray-scale values as height.
| filename | filename | |
| x0 | x lower bound | |
| x1 | x upper bound | |
| z0 | z lower bound | |
| z1 | z upper bound | |
| h0 | y lower bound | |
| h1 | y upper bound |
| void Mesh::CreateVBO | ( | ) |
Creates a Vertex Buffer Object (VBO).
| void Mesh::DeleteVBO | ( | ) |
Deletes a Vertex Buffer Object (VBO).
| void Mesh::DrawOpenGL | ( | ) |
Draws the grid in OpenGL.
| void Mesh::DrawVBO | ( | ) |
Draws the grid as a Vertex Buffer Object (VBO).
| unsigned int Mesh::GetNumTriangles | ( | ) |
Calculates the number of triangles (faces) in the grid.
| void Mesh::m_AddVertex | ( | float | x, | |
| float | y, | |||
| float | z, | |||
| Vec3f & | normal | |||
| ) | [private] |
Adds a vertex in the list of vertices.
| x | x position | |
| y | y position | |
| z | z position | |
| normal | normal vector |
| void Mesh::m_Clear | ( | ) | [private] |
Clears the vertex list and the face list.
| void Mesh::m_ReadHeight | ( | int | x, | |
| int | z, | |||
| float | dx, | |||
| float | dz, | |||
| float | h0, | |||
| float | h1, | |||
| unsigned char * | data, | |||
| int | bytesPerPixel, | |||
| int | width, | |||
| int | height, | |||
| float & | h, | |||
| Vec3f & | n | |||
| ) | [private] |
Convert pixel values to a height value and a normal.
| x | x position | |
| z | z position | |
| dx | x scale | |
| dz | z scale | |
| h0 | lower bound for mesh | |
| h1 | upper bound for mesh | |
| data | pointer to pixel data | |
| bytesPerPixel | format of pixel data | |
| width | width of height texture | |
| height | height of height texture | |
| h | height at given point | |
| n | normal at given point |
| float Mesh::hmin |
| float Mesh::hmax |
int Mesh::m_numVertices [private] |
Number of vertices
int Mesh::m_numFaces [private] |
Number of triangles
GLfloat* Mesh::m_vertArray [private] |
List of vertices
GLuint* Mesh::m_faceArray [private] |
List of faces
GLuint Mesh::m_vertexVBO [private] |
Identification for VBO
GLuint Mesh::m_indexVBO [private] |
Identification for VBO
1.5.2