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

2D terrain based on height map which consists of multiple equally large segments. More...

#include <Terrain2D.h>

Public Member Functions

 Terrain2D (void)
 
 ~Terrain2D (void)
 
osg::ref_ptr< osg::Group > GetTerrainGroup () const
 
const osg::Vec3f & GetPoint (int x, int y) const
 
void SetPoint (int x, int y, const osg::Vec3f &point)
 
float GetPointHeight (int x, int y) const
 
void SetPointHeight (int x, int y, float height)
 
bool ImportFromHeightMap (const std::string &path)
 
void GenerateByRandomFaultsAlgorithm (int iterations, float faultValueMin, float faultValueMax)
 
void GenerateByMidpointDisplacementAlgorithm (float cornerValueFrom, float cornerValueTo)
 
void GenerateByPerlinNoiseAlgorithm (float persistence, int octaveCount)
 
void Flatten (float height)
 
void Export (FileTypeExport fileType)
 
void Preprocessing ()
 
void Postprocessing ()
 

Detailed Description

2D terrain based on height map which consists of multiple equally large segments.

Constructor & Destructor Documentation

Terrain2D::Terrain2D ( void  )

Initializes the whole terrain object.

  • zeroes the segments pointer
  • initializes the terrain group node
Terrain2D::~Terrain2D ( void  )

Releases all memory allocated by the object.

Member Function Documentation

void Terrain2D::Export ( FileTypeExport  fileType)

Exports the whole terrain and all of its segments to the file on the disk with path and filetype specified by XML properties.

Parameters
[in]fileTypeEnumeration determining fileformat in which the terrain node is saved onto the disk.
void Terrain2D::Flatten ( float  height)

Sets the same height of the terrain to all points in all segments. [in] Height which is set to every point in all segments.

void Terrain2D::GenerateByMidpointDisplacementAlgorithm ( float  cornerValueFrom,
float  cornerValueTo 
)

Generates the terrain data according to the midpoint displacement generation algorithm.

Parameters
[in]fractalDimensionFractal dimension of the generated terrain surface.
[in]cornerValueFromLower boundary of the interval in which the corner value is generated.
[in]cornerValueToUpper boundary of the interval in which the corner value is generated.
void Terrain2D::GenerateByPerlinNoiseAlgorithm ( float  persistence,
int  octaveCount 
)

Generates the terrain data according to the Perlin noise algorithm.

Parameters
[in]persistenceProperty similar to fractal dimension - the higher the persistence is, the more rough the terrain is and vice versa.
[in]octaveCountNumber of noise surfaces which are summed up together.
void Terrain2D::GenerateByRandomFaultsAlgorithm ( int  iterations,
float  faultValueMin,
float  faultValueMax 
)

Generates the terrain data according to the random faults generation algorithm.

Parameters
[in]iterationsNumber of iterations of the algorithm.
[in]faultValueMinLower boundary of the interval in which the fault value is generated.
[in]faultValueMaxUpper boundary of the interval in which the fault value is generated.
const osg::Vec3f & Terrain2D::GetPoint ( int  x,
int  y 
) const

Returns a point from the whole terrain surface.

Parameters
[in]xCoordinate of the point on the X-axis.
[in]yCoordinate of the point on the Y-axis.
Returns
Point from the terrain surface.
float Terrain2D::GetPointHeight ( int  x,
int  y 
) const

Height value of the point at the given coordinates.

Parameters
[in]xCoordinate of the point on the X-axis.
[in]yCoordinate of the point on the Y-axis.
Returns
Height value of the point at the given coordinates.
osg::ref_ptr<osg::Group> APNature::Terrain2D::GetTerrainGroup ( ) const
inline

Return the OSG Geode containing the whole 2D terrain.

Returns
OSG Geode containing the whole 2D terrain.
bool Terrain2D::ImportFromHeightMap ( const std::string &  path)

Loads the terrain data from the source image with values based on the intensity values in the specific channel(s). [in] Path to the source heightmap from which the terrain data are loaded.

Returns
TRUE if everything succeeded, FALSE otherwise.
void Terrain2D::Postprocessing ( )

Computes the normals for every point of every terrain segment and adds all of the terrain segments to terrain group.

void Terrain2D::Preprocessing ( )

Allocates all terrain segments and their points, and initializes their values (e.g. proper point position) and initializes neighbour connections among the terrain segments.

void Terrain2D::SetPoint ( int  x,
int  y,
const osg::Vec3f &  point 
)

Changes value of a point in a terrain surface

Parameters
[in]xCoordinate of the point on the X-axis.
[in]yCoordinate of the point on the Y-axis.
[in]pointNew point that will replace the old one in the terrain surface.
void Terrain2D::SetPointHeight ( int  x,
int  y,
float  height 
)

Changes only the height value of the point at the given coordinates, leaving other two coordinates unchanged.

Parameters
[in]xCoordinate of the point on the X-axis.
[in]yCoordinate of the point on the Y-axis.
[in]heightNew height value of the given point.

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