vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
APNature::TerrainAlgorithm Class Reference

#include <TerrainAlgorithm.h>

Inheritance diagram for APNature::TerrainAlgorithm:
APNature::MidpointDisplacementAlgorithm APNature::PerlinNoiseAlgorithm APNature::RandomFaultsAlgorithm

Public Member Functions

 TerrainAlgorithm (int width, int height)
 
 ~TerrainAlgorithm ()
 
unsigned int PointIndex (int x, int y) const
 
float GetLowestValue () const
 
float GetHighestValue () const
 

Protected Member Functions

float * Allocate (int width, int height)
 
void Release ()
 
void Zero ()
 
void Flatten (float height)
 
float GetPointHeight (int x, int y) const
 
void SetPointHeight (int x, int y, float height)
 

Protected Attributes

float * _terrain
 
int _width
 
int _height
 

Constructor & Destructor Documentation

TerrainAlgorithm::TerrainAlgorithm ( int  width,
int  height 
)

Initializes the attributes and allocates the memory for the terrain data.

Parameters
[in]widthSize of the terrain surface to generate in X-axis.
[in]heightSize of the terrain surface to generate in Y-axis.
TerrainAlgorithm::~TerrainAlgorithm ( )

Member Function Documentation

float * TerrainAlgorithm::Allocate ( int  width,
int  height 
)
protected

Allocates the memory needed to store the terrain height values, if possible. In case there is not enough memory available, std::bac_alloc is thrown.

Parameters
[in]widthSize of the array in X-axis.
[in]heightSize of the array in Y-axis.
Returns
Pointer to the first byte of the allocated array if the allocation succeeded, NULL otherwise.
void TerrainAlgorithm::Flatten ( float  height)
protected

Sets the same height for all of the terrain points.

Parameters
[in]heightHeight which is set to every point.
float TerrainAlgorithm::GetHighestValue ( ) const

Returns the value of the point with the highest value in the whole array.

Returns
The highest value from from the whole array.
float TerrainAlgorithm::GetLowestValue ( ) const

Returns the value of the point with the lowest value in the whole array.

Returns
The lowest value from from the whole array.
float APNature::TerrainAlgorithm::GetPointHeight ( int  x,
int  y 
) const
inlineprotected

Returns the height value of the point at the given coordinates.

Parameters
[in]xLocation of the point on the X-axis.
[in]yLocation of the point on the Y-axis.
Returns
Height value of the point at the given coordinates
unsigned int APNature::TerrainAlgorithm::PointIndex ( int  x,
int  y 
) const
inline

Returns the mapped index in the one-dimensional data array. [in] X-coordinate [in] Y-coordinate

Returns
Mapped index in the one-dimensional data array.
void TerrainAlgorithm::Release ( )
protected

Releases all memory previously used by the object instance which was not deallocated yet.

void APNature::TerrainAlgorithm::SetPointHeight ( int  x,
int  y,
float  height 
)
inlineprotected

Sets the height value of the point at the given coordinates.

Parameters
[in]xLocation of the point on the X-axis.
[in]yLocation of the point on the Y-axis.
[in]heightHeight value of the point at the given coordinates
void TerrainAlgorithm::Zero ( )
protected

Fills all of the terrain values with zeroes.

Member Data Documentation

int APNature::TerrainAlgorithm::_height
protected
float* APNature::TerrainAlgorithm::_terrain
protected
int APNature::TerrainAlgorithm::_width
protected

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