35#ifndef TCOD_HEIGHTMAP_HPP_
36#define TCOD_HEIGHTMAP_HPP_
56class TCODLIB_API TCODHeightMap {
58 TCODHeightMap() =
default;
83 TCODHeightMap(
int width,
int height) : w{width}, h{height}, values{new float[width * height]{}} {}
89 if (w == rhs.w && h == rhs.h) {
90 for (ptrdiff_t i = 0; i < w * h; ++i) values[i] = rhs.values[i];
107 std::swap(values, rhs.values);
129 values[w * y + x] = v;
191 [[deprecated(
"Copy by value instead: 'x = y;'")]]
192 void copy(
const TCODHeightMap *source) {
193 if (source) *
this = *source;
225 void lerp(
const TCODHeightMap *a,
const TCODHeightMap *b,
float coef);
238 void add(
const TCODHeightMap *a,
const TCODHeightMap *b);
251 void multiply(
const TCODHeightMap *a,
const TCODHeightMap *b);
271 void addHill(
float x,
float y,
float radius,
float height);
289 void digHill(
float hx,
float hy,
float h_radius,
float height);
336 void kernelTransform(
int kernelSize,
const int *dx,
const int *dy,
const float *weight,
float minLevel,
float maxLevel);
371 void addFbm(
TCODNoise *noise,
float mul_x,
float mul_y,
float add_x,
float add_y,
float octaves,
float delta,
float scale);
382 void scaleFbm(
TCODNoise *noise,
float mul_x,
float mul_y,
float add_x,
float add_y,
float octaves,
float delta,
float scale);
401 void digBezier(
int px[4],
int py[4],
float startRadius,
float startDepth,
float endRadius,
float endDepth);
420 return values[w * y + x];
468 void getNormal(
float x,
float y,
float n[3],
float waterLevel=0.0f)
const;
526 void islandify(
float seaLevel,
TCODRandom *rnd);
Definition heightmap.hpp:56
void scaleFbm(TCODNoise *noise, float mul_x, float mul_y, float add_x, float add_y, float octaves, float delta, float scale)
This function works exactly as the previous one, but it multiplies the resulting value instead of add...
float getSlope(int x, int y) const
This function returns the slope between 0 and PI/2 at given coordinates.
void addFbm(TCODNoise *noise, float mul_x, float mul_y, float add_x, float add_y, float octaves, float delta, float scale)
This function adds values from a simplex fbm function to the map.
float getInterpolatedValue(float x, float y) const
This function returns the interpolated height at non integer coordinates.
void addHill(float x, float y, float radius, float height)
This function adds a hill (a half spheroid) at given position.
void digBezier(int px[4], int py[4], float startRadius, float startDepth, float endRadius, float endDepth)
This function carve a path along a cubic Bezier curve using the digHill function.
void midPointDisplacement(TCODRandom *rnd=NULL, float roughness=0.45f)
This algorithm generates a realistic fractal heightmap using the diamond-square (or random midpoint d...
void lerp(const TCODHeightMap *a, const TCODHeightMap *b, float coef)
TCODHeightMap(int width, int height)
As with other modules, you have to create a heightmap object first : Note that whereas most other mod...
Definition heightmap.hpp:83
void setValue(int x, int y, float v)
Once the heightmap has been created, you can do some basic operations on the values inside it....
Definition heightmap.hpp:128
void rainErosion(int nbDrops, float erosionCoef, float sedimentationCoef, TCODRandom *rnd)
This function simulates the effect of rain drops on the terrain, resulting in erosion patterns.
bool hasLandOnBorder(float waterLevel) const
This function checks if the cells on the map border are below a certain height.
float getValue(int x, int y) const
This function returns the height value of a map cell.
Definition heightmap.hpp:419
void multiply(const TCODHeightMap *a, const TCODHeightMap *b)
void digHill(float hx, float hy, float h_radius, float height)
This function takes the highest value (if height > 0) or the lowest (if height < 0) between the map a...
void kernelTransform(int kernelSize, const int *dx, const int *dy, const float *weight, float minLevel, float maxLevel)
This function allows you to apply a generic transformation on the map, so that each resulting cell va...
void getMinMax(float *min, float *max) const
This function calculates the min and max of all values inside the map.
void getNormal(float x, float y, float n[3], float waterLevel=0.0f) const
This function returns the map normal at given coordinates.
void addVoronoi(int nbPoints, int nbCoef, const float *coef, TCODRandom *rnd)
This function adds values from a Voronoi diagram to the map.
void clamp(float min, float max)
int countCells(float min, float max) const
This function returns the number of map cells which value is between min and max.
void add(const TCODHeightMap *a, const TCODHeightMap *b)
void copy(const TCODHeightMap *source)
Definition heightmap.hpp:192
void normalize(float newMin=0.0f, float newMax=1.0f)
void TCODHeightMap::normalize() void TCODHeightMap::normalize(float min) void TCODHeightMap::normaliz...
Usage example: 1D noise : the variation of a torch intensity 2D fbm : heightfield generation or cloud...
Definition noise.hpp:79
Definition mersenne.hpp:94
Terrain heightmap module.
Texture noise generator module.