Deterministic terrain height sampling (Red Blob Games / Perlin fBm recipe). 更多...
#include <TerrainSampler.h>
Public 成员函数 | |
| TerrainSampler ()=default | |
| float | sample (float x, float y) const |
| float | sampleTile (int tileX, int tileY) const |
| Height at the center of map tile (tileX, tileY). | |
| std::function< float(float, float)> | asFunction () const |
| void | setSeed (uint32_t seed) |
| uint32_t | getSeed () const |
| void | setScale (float scale) |
| Cycles per world unit (alias of frequency). Default 1/32. | |
| float | getScale () const |
| void | setFrequency (float frequency) |
| float | getFrequency () const |
| void | setWavelength (float wavelength) |
| Distance per large oscillation. Sets frequency = 1/wavelength. | |
| float | getWavelength () const |
| void | setOctaves (int octaves) |
| int | getOctaves () const |
| void | setLacunarity (float lacunarity) |
| float | getLacunarity () const |
| void | setGain (float gain) |
| float | getGain () const |
| void | setRidge (float ridge) |
| float | getRidge () const |
| void | setWarp (float warp) |
| float | getWarp () const |
| void | setExponent (float exponent) |
| float | getExponent () const |
| void | setContinent (float continent) |
| float | getContinent () const |
| void | setIsland (float island) |
| float | getIsland () const |
| void | setCoastSoftness (float softness) |
| Shore width of the land mask smoothstep. Smaller = cleaner, harder coast. | |
| float | getCoastSoftness () const |
| void | setWorldSize (int width, int height) |
| int | getWorldWidth () const |
| int | getWorldHeight () const |
| void | setBase (float base) |
| float | getBase () const |
| void | setAmplitude (float amplitude) |
| float | getAmplitude () const |
| void | setClamp (bool enabled, float minHeight, float maxHeight) |
| bool | isClamped () const |
| float | getClampMin () const |
| float | getClampMax () const |
静态 Public 成员函数 | |
| static TerrainSampler | fromParams (const Params ¶ms) |
详细描述
Deterministic terrain height sampling (Red Blob Games / Perlin fBm recipe).
sample(x, y) maps any continuous map coordinate (tile/world units) to a height in [0, 1] by default. Same coordinate + same config ⇒ same height.
Frequency is cycles per world unit. A wavelength of 32 (frequency 1/32) means one large hill every 32 tiles/pixels — this is what makes coherent terrain instead of white noise. scale is an alias for frequency.
Pipeline:
- 2-octave Perlin continent (low frequency) — this is the land shape
- low-frequency domain warp of that field (bays / peninsulas)
- optional multiplicative island falloff (kills map corners, not the shape)
- smoothstep → solid coastline; hills / ridges only inland
在文件 TerrainSampler.h 第 27 行定义.
构造及析构函数说明
◆ TerrainSampler()
|
default |
成员函数说明
◆ asFunction()
| std::function< float(float, float)> eve::procgen::TerrainSampler::asFunction | ( | ) | const |
◆ fromParams()
|
static |
◆ getAmplitude()
| float eve::procgen::TerrainSampler::getAmplitude | ( | ) | const |
在文件 TerrainSampler.cpp 第 47 行定义.
◆ getBase()
| float eve::procgen::TerrainSampler::getBase | ( | ) | const |
在文件 TerrainSampler.cpp 第 45 行定义.
◆ getClampMax()
| float eve::procgen::TerrainSampler::getClampMax | ( | ) | const |
在文件 TerrainSampler.cpp 第 55 行定义.
◆ getClampMin()
| float eve::procgen::TerrainSampler::getClampMin | ( | ) | const |
在文件 TerrainSampler.cpp 第 54 行定义.
◆ getCoastSoftness()
| float eve::procgen::TerrainSampler::getCoastSoftness | ( | ) | const |
在文件 TerrainSampler.cpp 第 37 行定义.
◆ getContinent()
| float eve::procgen::TerrainSampler::getContinent | ( | ) | const |
在文件 TerrainSampler.cpp 第 33 行定义.
◆ getExponent()
| float eve::procgen::TerrainSampler::getExponent | ( | ) | const |
在文件 TerrainSampler.cpp 第 31 行定义.
◆ getFrequency()
| float eve::procgen::TerrainSampler::getFrequency | ( | ) | const |
在文件 TerrainSampler.cpp 第 15 行定义.
◆ getGain()
| float eve::procgen::TerrainSampler::getGain | ( | ) | const |
在文件 TerrainSampler.cpp 第 25 行定义.
◆ getIsland()
| float eve::procgen::TerrainSampler::getIsland | ( | ) | const |
在文件 TerrainSampler.cpp 第 35 行定义.
◆ getLacunarity()
| float eve::procgen::TerrainSampler::getLacunarity | ( | ) | const |
在文件 TerrainSampler.cpp 第 23 行定义.
◆ getOctaves()
| int eve::procgen::TerrainSampler::getOctaves | ( | ) | const |
在文件 TerrainSampler.cpp 第 21 行定义.
◆ getRidge()
| float eve::procgen::TerrainSampler::getRidge | ( | ) | const |
在文件 TerrainSampler.cpp 第 27 行定义.
◆ getScale()
| float eve::procgen::TerrainSampler::getScale | ( | ) | const |
在文件 TerrainSampler.cpp 第 13 行定义.
◆ getSeed()
| uint32_t eve::procgen::TerrainSampler::getSeed | ( | ) | const |
在文件 TerrainSampler.cpp 第 11 行定义.
◆ getWarp()
| float eve::procgen::TerrainSampler::getWarp | ( | ) | const |
在文件 TerrainSampler.cpp 第 29 行定义.
◆ getWavelength()
| float eve::procgen::TerrainSampler::getWavelength | ( | ) | const |
在文件 TerrainSampler.cpp 第 19 行定义.
◆ getWorldHeight()
| int eve::procgen::TerrainSampler::getWorldHeight | ( | ) | const |
在文件 TerrainSampler.cpp 第 43 行定义.
被这些函数引用 eve::procgen::Heightmap::generate().
◆ getWorldWidth()
| int eve::procgen::TerrainSampler::getWorldWidth | ( | ) | const |
在文件 TerrainSampler.cpp 第 42 行定义.
被这些函数引用 eve::procgen::Heightmap::generate().
◆ isClamped()
| bool eve::procgen::TerrainSampler::isClamped | ( | ) | const |
在文件 TerrainSampler.cpp 第 53 行定义.
◆ sample()
| float eve::procgen::TerrainSampler::sample | ( | float | x, |
| float | y | ||
| ) | const |
在文件 TerrainSampler.cpp 第 65 行定义.
引用了 cx, cy, d, eve::procgen::NoiseField::fbmPerlin(), h, eve::procgen::NoiseField::perlinNoise(), eve::procgen::NoiseField::ridgedPerlin(), x , 以及 y.
被这些函数引用 sampleTile().
◆ sampleTile()
| float eve::procgen::TerrainSampler::sampleTile | ( | int | tileX, |
| int | tileY | ||
| ) | const |
◆ setAmplitude()
| void eve::procgen::TerrainSampler::setAmplitude | ( | float | amplitude | ) |
在文件 TerrainSampler.cpp 第 46 行定义.
◆ setBase()
| void eve::procgen::TerrainSampler::setBase | ( | float | base | ) |
在文件 TerrainSampler.cpp 第 44 行定义.
◆ setClamp()
| void eve::procgen::TerrainSampler::setClamp | ( | bool | enabled, |
| float | minHeight, | ||
| float | maxHeight | ||
| ) |
在文件 TerrainSampler.cpp 第 48 行定义.
引用了 enabled.
◆ setCoastSoftness()
| void eve::procgen::TerrainSampler::setCoastSoftness | ( | float | softness | ) |
Shore width of the land mask smoothstep. Smaller = cleaner, harder coast.
在文件 TerrainSampler.cpp 第 36 行定义.
◆ setContinent()
| void eve::procgen::TerrainSampler::setContinent | ( | float | continent | ) |
在文件 TerrainSampler.cpp 第 32 行定义.
◆ setExponent()
| void eve::procgen::TerrainSampler::setExponent | ( | float | exponent | ) |
在文件 TerrainSampler.cpp 第 30 行定义.
◆ setFrequency()
| void eve::procgen::TerrainSampler::setFrequency | ( | float | frequency | ) |
◆ setGain()
| void eve::procgen::TerrainSampler::setGain | ( | float | gain | ) |
在文件 TerrainSampler.cpp 第 24 行定义.
◆ setIsland()
| void eve::procgen::TerrainSampler::setIsland | ( | float | island | ) |
在文件 TerrainSampler.cpp 第 34 行定义.
◆ setLacunarity()
| void eve::procgen::TerrainSampler::setLacunarity | ( | float | lacunarity | ) |
在文件 TerrainSampler.cpp 第 22 行定义.
◆ setOctaves()
| void eve::procgen::TerrainSampler::setOctaves | ( | int | octaves | ) |
在文件 TerrainSampler.cpp 第 20 行定义.
◆ setRidge()
| void eve::procgen::TerrainSampler::setRidge | ( | float | ridge | ) |
在文件 TerrainSampler.cpp 第 26 行定义.
◆ setScale()
| void eve::procgen::TerrainSampler::setScale | ( | float | scale | ) |
Cycles per world unit (alias of frequency). Default 1/32.
在文件 TerrainSampler.cpp 第 12 行定义.
引用了 scale.
被这些函数引用 setFrequency().
◆ setSeed()
| void eve::procgen::TerrainSampler::setSeed | ( | uint32_t | seed | ) |
在文件 TerrainSampler.cpp 第 10 行定义.
引用了 seed , 以及 eve::procgen::NoiseField::seed.
被这些函数引用 fromParams().
◆ setWarp()
| void eve::procgen::TerrainSampler::setWarp | ( | float | warp | ) |
在文件 TerrainSampler.cpp 第 28 行定义.
◆ setWavelength()
| void eve::procgen::TerrainSampler::setWavelength | ( | float | wavelength | ) |
Distance per large oscillation. Sets frequency = 1/wavelength.
在文件 TerrainSampler.cpp 第 16 行定义.
引用了 setFrequency().
◆ setWorldSize()
| void eve::procgen::TerrainSampler::setWorldSize | ( | int | width, |
| int | height | ||
| ) |
在文件 TerrainSampler.cpp 第 38 行定义.
被这些函数引用 eve::procgen::Heightmap::generate().
该类的文档由以下文件生成:
- src/modules/procgen/heightmap/TerrainSampler.h
- src/modules/procgen/heightmap/TerrainSampler.cpp