Deterministic terrain height sampling (Red Blob Games / Perlin fBm recipe). 更多...
#include <TerrainSampler.h>
Public 成员函数 | |
| TerrainSampler ()=default | |
| Terrain sampler. | |
| float | sample (float x, float y) const |
| Sample. | |
| float | sampleTile (int tileX, int tileY) const |
| Height at the center of map tile (tileX, tileY). | |
| std::function< float(float, float)> | asFunction () const |
| Float. | |
| void | setSeed (uint32_t seed) |
| Sets the seed. | |
| uint32_t | getSeed () const |
| Returns the seed. | |
| void | setScale (float scale) |
| Cycles per world unit (alias of frequency). Default 1/32. | |
| float | getScale () const |
| Returns the scale. | |
| void | setFrequency (float frequency) |
| Sets the frequency. | |
| float | getFrequency () const |
| Returns the frequency. | |
| void | setWavelength (float wavelength) |
| Distance per large oscillation. Sets frequency = 1/wavelength. | |
| float | getWavelength () const |
| Returns the wavelength. | |
| void | setOctaves (int octaves) |
| Sets the octaves. | |
| int | getOctaves () const |
| Returns the octaves. | |
| void | setLacunarity (float lacunarity) |
| Sets the lacunarity. | |
| float | getLacunarity () const |
| Returns the lacunarity. | |
| void | setGain (float gain) |
| Sets the gain. | |
| float | getGain () const |
| Returns the gain. | |
| void | setRidge (float ridge) |
| Sets the ridge. | |
| float | getRidge () const |
| Returns the ridge. | |
| void | setWarp (float warp) |
| Sets the warp. | |
| float | getWarp () const |
| Returns the warp. | |
| void | setExponent (float exponent) |
| Sets the exponent. | |
| float | getExponent () const |
| Returns the exponent. | |
| void | setContinent (float continent) |
| Sets the continent. | |
| float | getContinent () const |
| Returns the continent. | |
| void | setIsland (float island) |
| Sets the island. | |
| float | getIsland () const |
| Returns the island. | |
| void | setCoastSoftness (float softness) |
| Shore width of the land mask smoothstep. Smaller = cleaner, harder coast. | |
| float | getCoastSoftness () const |
| Returns the coast softness. | |
| void | setWorldSize (int width, int height) |
| Sets the world size. | |
| int | getWorldWidth () const |
| Returns the world width. | |
| int | getWorldHeight () const |
| Returns the world height. | |
| void | setBase (float base) |
| Sets the base. | |
| float | getBase () const |
| Returns the base. | |
| void | setAmplitude (float amplitude) |
| Sets the amplitude. | |
| float | getAmplitude () const |
| Returns the amplitude. | |
| void | setClamp (bool enabled, float minHeight, float maxHeight) |
| Sets the clamp. | |
| bool | isClamped () const |
| True when clamped. | |
| float | getClampMin () const |
| Returns the clamp min. | |
| float | getClampMax () const |
| Returns the clamp max. | |
静态 Public 成员函数 | |
| static TerrainSampler | fromParams (const Params ¶ms) |
| From params. | |
详细描述
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 第 29 行定义.
构造及析构函数说明
◆ TerrainSampler()
|
default |
Terrain sampler.
成员函数说明
◆ asFunction()
| std::function< float(float, float)> eve::procgen::TerrainSampler::asFunction | ( | ) | const |
◆ fromParams()
|
static |
From params.
在文件 TerrainSampler.cpp 第 128 行定义.
◆ getAmplitude()
| float eve::procgen::TerrainSampler::getAmplitude | ( | ) | const |
Returns the amplitude.
在文件 TerrainSampler.cpp 第 47 行定义.
◆ getBase()
| float eve::procgen::TerrainSampler::getBase | ( | ) | const |
Returns the base.
在文件 TerrainSampler.cpp 第 45 行定义.
◆ getClampMax()
| float eve::procgen::TerrainSampler::getClampMax | ( | ) | const |
Returns the clamp max.
在文件 TerrainSampler.cpp 第 55 行定义.
◆ getClampMin()
| float eve::procgen::TerrainSampler::getClampMin | ( | ) | const |
Returns the clamp min.
在文件 TerrainSampler.cpp 第 54 行定义.
◆ getCoastSoftness()
| float eve::procgen::TerrainSampler::getCoastSoftness | ( | ) | const |
Returns the coast softness.
在文件 TerrainSampler.cpp 第 37 行定义.
◆ getContinent()
| float eve::procgen::TerrainSampler::getContinent | ( | ) | const |
Returns the continent.
在文件 TerrainSampler.cpp 第 33 行定义.
◆ getExponent()
| float eve::procgen::TerrainSampler::getExponent | ( | ) | const |
Returns the exponent.
在文件 TerrainSampler.cpp 第 31 行定义.
◆ getFrequency()
| float eve::procgen::TerrainSampler::getFrequency | ( | ) | const |
Returns the frequency.
在文件 TerrainSampler.cpp 第 15 行定义.
◆ getGain()
| float eve::procgen::TerrainSampler::getGain | ( | ) | const |
Returns the gain.
在文件 TerrainSampler.cpp 第 25 行定义.
◆ getIsland()
| float eve::procgen::TerrainSampler::getIsland | ( | ) | const |
Returns the island.
在文件 TerrainSampler.cpp 第 35 行定义.
◆ getLacunarity()
| float eve::procgen::TerrainSampler::getLacunarity | ( | ) | const |
Returns the lacunarity.
在文件 TerrainSampler.cpp 第 23 行定义.
◆ getOctaves()
| int eve::procgen::TerrainSampler::getOctaves | ( | ) | const |
Returns the octaves.
在文件 TerrainSampler.cpp 第 21 行定义.
◆ getRidge()
| float eve::procgen::TerrainSampler::getRidge | ( | ) | const |
Returns the ridge.
在文件 TerrainSampler.cpp 第 27 行定义.
◆ getScale()
| float eve::procgen::TerrainSampler::getScale | ( | ) | const |
Returns the scale.
在文件 TerrainSampler.cpp 第 13 行定义.
◆ getSeed()
| uint32_t eve::procgen::TerrainSampler::getSeed | ( | ) | const |
◆ getWarp()
| float eve::procgen::TerrainSampler::getWarp | ( | ) | const |
Returns the warp.
在文件 TerrainSampler.cpp 第 29 行定义.
◆ getWavelength()
| float eve::procgen::TerrainSampler::getWavelength | ( | ) | const |
Returns the wavelength.
在文件 TerrainSampler.cpp 第 19 行定义.
◆ getWorldHeight()
| int eve::procgen::TerrainSampler::getWorldHeight | ( | ) | const |
Returns the world height.
在文件 TerrainSampler.cpp 第 43 行定义.
◆ getWorldWidth()
| int eve::procgen::TerrainSampler::getWorldWidth | ( | ) | const |
Returns the world width.
在文件 TerrainSampler.cpp 第 42 行定义.
◆ isClamped()
| bool eve::procgen::TerrainSampler::isClamped | ( | ) | const |
True when clamped.
在文件 TerrainSampler.cpp 第 53 行定义.
◆ sample()
| float eve::procgen::TerrainSampler::sample | ( | float | x, |
| float | y | ||
| ) | const |
Sample.
在文件 TerrainSampler.cpp 第 65 行定义.
引用了 cx, cy, d, detail, dx, dy, eve::procgen::NoiseField::fbmPerlin(), h, nx, ny, 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 | ) |
Sets the amplitude.
在文件 TerrainSampler.cpp 第 46 行定义.
◆ setBase()
| void eve::procgen::TerrainSampler::setBase | ( | float | base | ) |
Sets the base.
在文件 TerrainSampler.cpp 第 44 行定义.
◆ setClamp()
| void eve::procgen::TerrainSampler::setClamp | ( | bool | enabled, |
| float | minHeight, | ||
| float | maxHeight | ||
| ) |
◆ 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 | ) |
Sets the continent.
在文件 TerrainSampler.cpp 第 32 行定义.
◆ setExponent()
| void eve::procgen::TerrainSampler::setExponent | ( | float | exponent | ) |
Sets the exponent.
在文件 TerrainSampler.cpp 第 30 行定义.
◆ setFrequency()
| void eve::procgen::TerrainSampler::setFrequency | ( | float | frequency | ) |
◆ setGain()
| void eve::procgen::TerrainSampler::setGain | ( | float | gain | ) |
Sets the gain.
在文件 TerrainSampler.cpp 第 24 行定义.
◆ setIsland()
| void eve::procgen::TerrainSampler::setIsland | ( | float | island | ) |
◆ setLacunarity()
| void eve::procgen::TerrainSampler::setLacunarity | ( | float | lacunarity | ) |
Sets the lacunarity.
在文件 TerrainSampler.cpp 第 22 行定义.
◆ setOctaves()
| void eve::procgen::TerrainSampler::setOctaves | ( | int | octaves | ) |
Sets the octaves.
在文件 TerrainSampler.cpp 第 20 行定义.
◆ setRidge()
| void eve::procgen::TerrainSampler::setRidge | ( | float | ridge | ) |
Sets the 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 | ) |
Sets the seed.
在文件 TerrainSampler.cpp 第 10 行定义.
引用了 seed , 以及 eve::procgen::NoiseField::seed.
被这些函数引用 fromParams().
◆ setWarp()
| void eve::procgen::TerrainSampler::setWarp | ( | float | warp | ) |
◆ 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 | ||
| ) |
该类的文档由以下文件生成:
- src/modules/procgen/heightmap/TerrainSampler.h
- src/modules/procgen/heightmap/TerrainSampler.cpp