AireEngine
A 3D Open-World Game Engine
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Aire::Terrain Class Reference

A class that represents a terrain object. More...

#include <terrain.h>

Public Member Functions

 Terrain (TexturePtr heightMap, int numVertices=200, const float xzScale=50.f, const float yScale=10.f, TexturePtr diffuseMap=nullptr, TexturePtr normalMap=nullptr, TexturePtr roughnessmap=nullptr)
 Constructs a Terrain object with specified parameters.
 
 ~Terrain ()
 Destructor for the Terrain object.
 
bool saveHeightData ()
 Loads the height data from the height map texture.
 
float getHeightAt (const float x, const float z)
 Retrieves the height of the terrain at a given point in world space.
 
float getXZScale () const
 Gets the terrain scale factor in the x and z axes.
 
float getYScale () const
 Gets the terrain scale factor in the y axis.
 
void render (ShaderProgram &prog, Aire::Camera &camera)
 Renders the terrain using a specified shader program and camera.
 
void addWaterSurface (TextureManager *texManager, const Box2D &region, float height)
 Adds a water surface to the terrain.
 

Public Attributes

std::vector< glm::vec3 > vertices
 
std::vector< glm::vec2 > uvs
 
std::vector< unsigned intindices
 
glm::mat4 modelMatrix = glm::mat4(1.0f)
 
TexturePtr heightMap = nullptr
 
TexturePtr diffuseMap = nullptr
 
TexturePtr specularMap = nullptr
 
TexturePtr normalMap = nullptr
 
TexturePtr roughnessMap = nullptr
 
glm::vec3 diffuseColor = glm::vec3(0.f, 0.1f, 0.f)
 
glm::vec3 specularColor = glm::vec3(0.05f, 0.05f, 0.05f)
 
float shininessValue = 1.f
 
std::vector< Aire::WaterSurface * > waterSurfaces
 

Detailed Description

A class that represents a terrain object.

Constructor & Destructor Documentation

◆ Terrain()

Terrain::Terrain ( Aire::TexturePtr heightmap,
int numVertices = 200,
const float xzScale = 50.f,
const float yScale = 10.f,
Aire::TexturePtr diffuseMap = nullptr,
Aire::TexturePtr normalMap = nullptr,
Aire::TexturePtr roughnessMap = nullptr )

Constructs a Terrain object with specified parameters.

Parameters
heightMapThe height map texture to use for the terrain.
numVerticesThe number of vertices along one side of the terrain.
xzScaleThe scale of the terrain in the x and z axes.
yScaleThe scale of the terrain in the y axis.
diffuseMapOptional diffuse map texture (nullptr for no texture).
normalMapOptional normal map texture (nullptr for no texture).
roughnessMapOptional roughness map texture (nullptr for no texture).
Here is the call graph for this function:

Member Function Documentation

◆ addWaterSurface()

void Terrain::addWaterSurface ( TextureManager * texManager,
const Box2D & region,
float height )

Adds a water surface to the terrain.

Parameters
texManagerThe texture manager for loading water textures.
regionThe region of the terrain to add the water surface to.
heightThe height of the water surface.
Here is the caller graph for this function:

◆ getHeightAt()

float Terrain::getHeightAt ( const float x,
const float z )

Retrieves the height of the terrain at a given point in world space.

Parameters
xThe x coordinate of the point.
zThe z coordinate of the point.
Returns
The world coordinates height of the terrain at the given point.
Here is the caller graph for this function:

◆ getXZScale()

float Aire::Terrain::getXZScale ( ) const
inline

Gets the terrain scale factor in the x and z axes.

Returns
The scale factor applied to the x and z dimensions of the terrain.
Here is the caller graph for this function:

◆ getYScale()

float Aire::Terrain::getYScale ( ) const
inline

Gets the terrain scale factor in the y axis.

Returns
The scale factor applied to the y dimension of the terrain.
Here is the caller graph for this function:

◆ render()

void Terrain::render ( ShaderProgram & prog,
Aire::Camera & camera )

Renders the terrain using a specified shader program and camera.

Parameters
progThe shader program used for rendering.
cameraThe camera object used for view and projection matrices.
Here is the call graph for this function:

◆ saveHeightData()

bool Terrain::saveHeightData ( )

Loads the height data from the height map texture.

Returns
True if the height data was loaded successfully, false otherwise.
Here is the caller graph for this function:

Member Data Documentation

◆ diffuseColor

glm::vec3 Aire::Terrain::diffuseColor = glm::vec3(0.f, 0.1f, 0.f)

Diffuse color of the terrain material.

◆ diffuseMap

TexturePtr Aire::Terrain::diffuseMap = nullptr

Pointer to the diffuse map texture.

◆ heightMap

TexturePtr Aire::Terrain::heightMap = nullptr

Pointer to the height map texture.

◆ indices

std::vector<unsigned int> Aire::Terrain::indices

Indices defining the rendering order of vertices.

◆ modelMatrix

glm::mat4 Aire::Terrain::modelMatrix = glm::mat4(1.0f)

Model matrix of the terrain.

◆ normalMap

TexturePtr Aire::Terrain::normalMap = nullptr

Pointer to the normal map texture.

◆ roughnessMap

TexturePtr Aire::Terrain::roughnessMap = nullptr

Pointer to the roughness map texture.

◆ shininessValue

float Aire::Terrain::shininessValue = 1.f

Shininess value of the terrain material.

◆ specularColor

glm::vec3 Aire::Terrain::specularColor = glm::vec3(0.05f, 0.05f, 0.05f)

Specular color of the terrain material.

◆ specularMap

TexturePtr Aire::Terrain::specularMap = nullptr

Pointer to the specular map texture.

◆ uvs

std::vector<glm::vec2> Aire::Terrain::uvs

Texture coordinates corresponding to the vertices.

◆ vertices

std::vector<glm::vec3> Aire::Terrain::vertices

List of vertices defining the terrain geometry.

◆ waterSurfaces

std::vector<Aire::WaterSurface*> Aire::Terrain::waterSurfaces

List of water surfaces associated with the terrain.


The documentation for this class was generated from the following files: