< index
< 15. Heightmap toolkit
< 15.3 Modifying the heightmap

=====================================
15.4 Reading data from the heightmap
=====================================

> 15.5 Destroying a heightmap

Those functions return raw or computed information about the heightmap.
15.4.1 Get the value of a cell
15.4.2 Interpolate the height
15.4.3 Get the map slope
15.4.4 Get the map normal
15.4.5 Count the map cells inside a height range
15.4.6 Check if the map is an island
15.4.7 Get the map min and max values

15.4.1 Get the value of a cell

This function returns the height value of a map cell.

C++ : float TCODHeightmap::getValue(int x, int y) const
C   : float TCOD_heightmap_get_value(const TCOD_heightmap_t *hm, int x, int y)
Py  : heightmap_get_value(hm,  x, y)

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
x,yCoordinates of the map cell.
0 <= x < map width
0 <= y < map height

15.4.2 Interpolate the height

This function returns the interpolated height at non integer coordinates.

C++ : float TCODHeightmap::getInterpolatedValue(float x, float y) const
C   : float TCOD_heightmap_get_interpolated_value(const TCOD_heightmap_t *hm, float x, float y)
Py  : heightmap_get_interpolated_value(hm, x, y)

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
x,yCoordinates of the map cell.
0 <= x < map width
0 <= y < map height

15.4.3 Get the map slope

This function returns the slope between 0 and PI/2 at given coordinates.

C++ : float TCODHeightmap::getSlope(int x, int y) const
C   : float TCOD_heightmap_get_slope(const TCOD_heightmap_t *hm, int x, int y)
Py  : heightmap_get_slope(hm, x, y)

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
x,yCoordinates of the map cell.
0 <= x < map width
0 <= y < map height

15.4.4 Get the map normal

This function returns the map normal at given coordinates.

C++ : void TCODHeightmap::getNormal(float x, float y,float n[3], float waterLevel=0.0f) const
C   : void TCOD_heightmap_get_normal(const TCOD_heightmap_t *hm, float x, float y, float n[3], float waterLevel)
Py  : heightmap_get_normal(hm, x, y, waterLevel) # returns nx,ny,nz

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
x,yCoordinates of the map cell.
0 <= x < map width
0 <= y < map height
nThe function stores the normalized normal vector in this array.
waterLevelThe map height is clamped at waterLevel so that the sea is flat.

15.4.5 Count the map cells inside a height range

This function returns the number of map cells which value is between min and max.

C++ : int TCODHeightmap::countCells(float min,float max) const
C   : int TCOD_heightmap_count_cells(const TCOD_heightmap_t *hm, float min, float max)
Py  : heightmap_count_cells(hm, min, max)

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
min,maxOnly cells which value is >=min and <= max are counted.

15.4.6 Check if the map is an island

This function checks if the cells on the map border are below a certain height.

C++ : bool TCODHeightmap::hasLandOnBorder(float waterLevel) const
C   : bool TCOD_heightmap_has_land_on_border(const TCOD_heightmap_t *hm, float waterLevel)
Py  : heightmap_has_land_on_border(hm, waterLevel)

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
waterLevelReturn true only if no border cell is > waterLevel.

15.4.7 Get the map min and max values

This function calculates the min and max of all values inside the map.

C++ : void TCODHeightmap::getMinMax(float *min, float *max) const
C   : void TCOD_heightmap_get_minmax(const TCOD_heightmap_t *hm, float *min, float *max)
Py  : heightmap_get_minmax(hm) # returns min,max

ParameterDescription
hmIn the C version, the address of the heightmap struct returned by the creation function.
min, maxThe min and max values are returned in these variables.

insert a comment