2D terrain based on height map which consists of multiple equally large segments.
More...
#include <Terrain2D.h>
|
| 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 () |
|
2D terrain based on height map which consists of multiple equally large segments.
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.
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] | fileType | Enumeration 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] | fractalDimension | Fractal dimension of the generated terrain surface. |
[in] | cornerValueFrom | Lower boundary of the interval in which the corner value is generated. |
[in] | cornerValueTo | Upper 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] | persistence | Property similar to fractal dimension - the higher the persistence is, the more rough the terrain is and vice versa. |
[in] | octaveCount | Number 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] | iterations | Number of iterations of the algorithm. |
[in] | faultValueMin | Lower boundary of the interval in which the fault value is generated. |
[in] | faultValueMax | Upper 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] | x | Coordinate of the point on the X-axis. |
[in] | y | Coordinate 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] | x | Coordinate of the point on the X-axis. |
[in] | y | Coordinate 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] | x | Coordinate of the point on the X-axis. |
[in] | y | Coordinate of the point on the Y-axis. |
[in] | point | New 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] | x | Coordinate of the point on the X-axis. |
[in] | y | Coordinate of the point on the Y-axis. |
[in] | height | New height value of the given point. |
The documentation for this class was generated from the following files:
- C:/Documents/School/OSG/VRECKO/include/vreckoAP/Nature/Terrain/Terrain2D.h
- C:/Documents/School/OSG/VRECKO/src/vreckoAP/Nature/Terrain/Terrain2D.cpp