Represents a 3D terrain generated from a heightmap. More...
#include <Terrain.h>
| Classes | |
| struct | CellMinMax | 
| < Structure to hold min and max Y values for terrain cells.  More... | |
| Public Member Functions | |
| Terrain (const Terrain &)=delete | |
| Terrain & | operator= (const Terrain &)=delete | 
| Terrain (const char *heightmapFile, float sideLength, float maxHeight, float worldZeroAltitude, std::string texture, float uRep, float vRep) | |
| Constructs a Terrain from a heightmap file. | |
| void | ShowCellBelow (const Vect &pos) const | 
| Visualizes the cell below a given world position. | |
| Vect | GetHeight (const Vect &pos) | 
| Gets the height at a given world position. | |
| Vect | GetHeightAndNormal (const Vect &pos, Vect &outNormal) | 
| Gets the height and normal at a given world position. | |
| const CollisionVolumeAABB & | GetCellAABB (int x, int z) const | 
| Gets the AABB for a specific terrain cell. | |
| void | GetCoveredCells (const CollisionVolume &vol, int &xMin, int &zMin, int &xMax, int &zMax) const | 
| Computes the range of cells covered by a collision volume. | |
| int | GetMaxCellIndex () const | 
| Gets the maximum valid cell index (for both X and Z). | |
| float | GetSideLen () const | 
| Gets the side length of the terrain. | |
| int | GetImgSize () const | 
| Gets the size of the heightmap image (number of pixels per side). | |
| void | EnableWireframe (bool enable) | 
| Enables or disables wireframe rendering for the terrain. | |
| void | EnableMinMax (bool enable) | 
| Enables or disables MinMax visualization for terrain cells. | |
| Private Member Functions | |
| void | Draw () | 
| Renders the terrain. | |
| int | VertexIndex (int i, int j) | 
| Computes the vertex index for grid coordinates. | |
| int | PixelIndex (int i, int j) | 
| Computes the pixel index for grid coordinates. | |
| int | TriIndex (int i, int j) | 
| Computes the triangle index for grid coordinates. | |
| float | GetCellX (int j) const | 
| float | GetCellZ (int i) const | 
| float | GetCellLength () const | 
| Private Attributes | |
| GraphicsObject_WireframeAutoColor * | pWireframe | 
| Wireframe object for terrain visualization. | |
| GraphicsObject_TextureFlat * | pGOTerrain | 
| Graphics object for terrain texture. | |
| Model * | pModelTerrain | 
| Model object for terrain geometry. | |
| VertexStride_VUN * | pVerts | 
| Vertex data for terrain. | |
| TriangleIndex * | tlist | 
| Triangle list for terrain. | |
| int | imgSize | 
| Size of the heightmap image (number of pixels per side). | |
| float | sideLen | 
| Length of one side of the terrain (world units). | |
| CellMinMax * | cellBounds | 
| Array of min/max Y values for terrain cells. | |
| CollisionVolumeAABB * | cellAABBs | 
| Array of AABBs for terrain cells. | |
| bool | wireframeEnabled | 
| Flag to enable/disable wireframe rendering. | |
| bool | minmaxEnabled | 
| Flag to enable/disable MinMax visualization. | |
| Friends | |
| class | TerrainAttorney | 
Represents a 3D terrain generated from a heightmap.
The Terrain class encapsulates the data and operations for a 3D terrain, including geometry generation, collision detection, and rendering. It provides methods to query height and normal at a position, visualize cells, and interact with collidable objects.
| Terrain::Terrain | ( | const char * | heightmapFile, | 
| float | sideLength, | ||
| float | maxHeight, | ||
| float | worldZeroAltitude, | ||
| std::string | texture, | ||
| float | uRep, | ||
| float | vRep ) | 
Constructs a Terrain from a heightmap file.
| heightmapFile | Path to the heightmap image file. | 
| sideLength | Length of one side of the terrain (world units). | 
| maxHeight | Maximum height of the terrain (world units). | 
| worldZeroAltitude | Altitude in world space corresponding to heightmap zero. | 
| texture | Path to the texture file. | 
| uRep | U texture repeat factor. | 
| vRep | V texture repeat factor. | 

| void Terrain::EnableMinMax | ( | bool | enable | ) | 
Enables or disables MinMax visualization for terrain cells.
| enable | True to enable MinMax visualization, false to disable. | 
| void Terrain::EnableWireframe | ( | bool | enable | ) | 
Enables or disables wireframe rendering for the terrain.
| enable | True to enable wireframe, false to disable. | 
| const CollisionVolumeAABB & Terrain::GetCellAABB | ( | int | x, | 
| int | z ) const | 
Gets the AABB for a specific terrain cell.
| x | Cell X index. | 
| z | Cell Z index. | 
| void Terrain::GetCoveredCells | ( | const CollisionVolume & | vol, | 
| int & | xMin, | ||
| int & | zMin, | ||
| int & | xMax, | ||
| int & | zMax ) const | 
Computes the range of cells covered by a collision volume.
| vol | Collision volume. | 
| xMin | Output minimum X index. | 
| zMin | Output minimum Z index. | 
| xMax | Output maximum X index. | 
| zMax | Output maximum Z index. | 


| Vect Terrain::GetHeight | ( | const Vect & | pos | ) | 
Gets the height at a given world position.
| pos | World position to query. | 

| Vect Terrain::GetHeightAndNormal | ( | const Vect & | pos, | 
| Vect & | outNormal ) | 
Gets the height and normal at a given world position.
| pos | World position to query. | 
| outNormal | Output parameter for the normal vector. | 

| int Terrain::GetImgSize | ( | ) | const | 
Gets the size of the heightmap image (number of pixels per side).

| int Terrain::GetMaxCellIndex | ( | ) | const | 
Gets the maximum valid cell index (for both X and Z).
| float Terrain::GetSideLen | ( | ) | const | 
Gets the side length of the terrain.
| 
 | private | 
Computes the pixel index for grid coordinates.
| i | Row index. | 
| j | Column index. | 

| void Terrain::ShowCellBelow | ( | const Vect & | pos | ) | const | 
Visualizes the cell below a given world position.
| pos | World position to query. | 

| 
 | private | 
Computes the triangle index for grid coordinates.
| i | Row index. | 
| j | Column index. | 

| 
 | private | 
Computes the vertex index for grid coordinates.
| i | Row index. | 
| j | Column index. | 
