35#ifndef TCOD_HEIGHTMAP_HPP_
36#define TCOD_HEIGHTMAP_HPP_
54class TCODLIB_API TCODHeightMap {
56 TCODHeightMap() =
default;
81 TCODHeightMap(
int width,
int height) : w{width}, h{height}, values{new float[width * height]{}} {}
87 if (w == rhs.w && h == rhs.h) {
88 for (ptrdiff_t i = 0; i < w * h; ++i) values[i] = rhs.values[i];
105 std::swap(values, rhs.values);
127 values[w * y + x] = v;
189 [[deprecated(
"Copy by value instead: 'x = y;'")]]
190 void copy(
const TCODHeightMap *source) {
191 if (source) *
this = *source;
223 void lerp(
const TCODHeightMap *a,
const TCODHeightMap *b,
float coef);
236 void add(
const TCODHeightMap *a,
const TCODHeightMap *b);
249 void multiply(
const TCODHeightMap *a,
const TCODHeightMap *b);
269 void addHill(
float x,
float y,
float radius,
float height);
287 void digHill(
float hx,
float hy,
float h_radius,
float height);
334 void kernelTransform(
int kernelSize,
const int *dx,
const int *dy,
const float *weight,
float minLevel,
float maxLevel);
369 void addFbm(
TCODNoise *noise,
float mul_x,
float mul_y,
float add_x,
float add_y,
float octaves,
float delta,
float scale);
380 void scaleFbm(
TCODNoise *noise,
float mul_x,
float mul_y,
float add_x,
float add_y,
float octaves,
float delta,
float scale);
399 void digBezier(
int px[4],
int py[4],
float startRadius,
float startDepth,
float endRadius,
float endDepth);
418 return values[w * y + x];
466 void getNormal(
float x,
float y,
float n[3],
float waterLevel=0.0f)
const;
524 void islandify(
float seaLevel,
TCODRandom *rnd);
Definition heightmap.hpp:54
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:81
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:126
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:417
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:190
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.