14.4. Reading data from the heightmap
Those functions return raw or computed information about the heightmap.
Get the value of a cell
This function returns the height value of a map cell.
float TCODHeightMap::getValue(int x, int y) const
float TCOD_heightmap_get_value(const TCOD_heightmap_t *hm, int x, int y)
heightmap_get_value(hm, x, y)
float TCODHeightMap::getValue(int x, int y)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
x,y | Coordinates of the map cell. 0 <= x < map width 0 <= y < map height |
Interpolate the height
This function returns the interpolated height at non integer coordinates.
float TCODHeightMap::getInterpolatedValue(float x, float y) const
float TCOD_heightmap_get_interpolated_value(const TCOD_heightmap_t *hm, float x, float y)
heightmap_get_interpolated_value(hm, x, y)
float TCODHeightMap::getInterpolatedValue(float x, float y)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
x,y | Coordinates of the map cell. 0 <= x < map width 0 <= y < map height |
Get the map slope
This function returns the slope between 0 and PI/2 at given coordinates.
float TCODHeightMap::getSlope(int x, int y) const
float TCOD_heightmap_get_slope(const TCOD_heightmap_t *hm, int x, int y)
heightmap_get_slope(hm, x, y)
float TCODHeightMap::getSlope(int x, int y)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
x,y | Coordinates of the map cell. 0 <= x < map width 0 <= y < map height |
Get the map normal
This function returns the map normal at given coordinates.
void TCODHeightMap::getNormal(float x, float y,float n[3], float waterLevel=0.0f) const
void TCOD_heightmap_get_normal(const TCOD_heightmap_t *hm, float x, float y, float n[3], float waterLevel)
heightmap_get_normal(hm, x, y, waterLevel)
void TCODHeightMap::getNormal(float x, float y, float[] n, float waterLevel)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
x,y | Coordinates of the map cell. 0 <= x < map width 0 <= y < map height |
n | The function stores the normalized normal vector in this array. |
waterLevel | The map height is clamped at waterLevel so that the sea is flat. |
Count the map cells inside a height range
This function returns the number of map cells which value is between min and max.
int TCODHeightMap::countCells(float min,float max) const
int TCOD_heightmap_count_cells(const TCOD_heightmap_t *hm, float min, float max)
heightmap_count_cells(hm, min, max)
int TCODHeightMap::countCells(float min, float max)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
min,max | Only cells which value is >=min and <= max are counted. |
Check if the map is an island
This function checks if the cells on the map border are below a certain height.
bool TCODHeightMap::hasLandOnBorder(float waterLevel) const
bool TCOD_heightmap_has_land_on_border(const TCOD_heightmap_t *hm, float waterLevel)
heightmap_has_land_on_border(hm, waterLevel)
bool TCODHeightMap::hasLandOnBorder(float waterLevel)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
waterLevel | Return true only if no border cell is > waterLevel. |
Get the map min and max values
This function calculates the min and max of all values inside the map.
void TCODHeightMap::getMinMax(float *min, float *max) const
void TCOD_heightmap_get_minmax(const TCOD_heightmap_t *hm, float *min, float *max)
heightmap_get_minmax(hm)
void TCODHeightMap::getMinMax(out float min, out float max)
Parameter | Description |
---|---|
hm | In the C version, the address of the heightmap struct returned by the creation function. |
min, | max The min and max values are returned in these variables. |