载入中...
搜索中...
未找到
TerrainSampler.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "procgen/Params.h"
7
8#include <cstdint>
9#include <functional>
10
11namespace eve::procgen {
12
30public:
32 TerrainSampler() = default;
33
35 float sample(float x, float y) const;
37 float sampleTile(int tileX, int tileY) const;
39 std::function<float(float, float)> asFunction() const;
40
42 void setSeed(uint32_t seed);
44 uint32_t getSeed() const;
46 void setScale(float scale);
48 float getScale() const;
50 void setFrequency(float frequency);
52 float getFrequency() const;
54 void setWavelength(float wavelength);
56 float getWavelength() const;
58 void setOctaves(int octaves);
60 int getOctaves() const;
62 void setLacunarity(float lacunarity);
64 float getLacunarity() const;
66 void setGain(float gain);
68 float getGain() const;
70 void setRidge(float ridge);
72 float getRidge() const;
74 void setWarp(float warp);
76 float getWarp() const;
78 void setExponent(float exponent);
80 float getExponent() const;
82 void setContinent(float continent);
84 float getContinent() const;
86 void setIsland(float island);
88 float getIsland() const;
90 void setCoastSoftness(float softness);
92 float getCoastSoftness() const;
94 void setWorldSize(int width, int height);
96 int getWorldWidth() const;
98 int getWorldHeight() const;
100 void setBase(float base);
102 float getBase() const;
104 void setAmplitude(float amplitude);
106 float getAmplitude() const;
108 void setClamp(bool enabled, float minHeight, float maxHeight);
110 bool isClamped() const;
112 float getClampMin() const;
114 float getClampMax() const;
115
117 static TerrainSampler fromParams(const Params &params);
118
119private:
120 NoiseField field_;
121 float frequency_ = 1.f / 32.f;
122 int octaves_ = 5;
123 float lacunarity_ = 2.f;
124 float gain_ = 0.5f;
125 float ridge_ = 0.35f;
126 float warp_ = 0.35f;
127 float exponent_ = 2.f;
128 float continent_ = 0.55f;
129 float island_ = 0.38f;
130 float coastSoft_ = 0.12f;
131 int worldW_ = 0;
132 int worldH_ = 0;
133 float base_ = 0.f;
134 float amplitude_ = 1.f;
135 bool clamp_ = true;
136 float clampMin_ = 0.f;
137 float clampMax_ = 1.f;
138};
139
142 float waterMax = 0.25f;
143 float sandMax = 0.35f;
144 float grassMax = 0.65f;
145 float dirtMax = 0.80f;
146 float stoneMax = 0.92f;
147
149 uint32_t semanticAt(float height) const;
151 static TerrainBands fromParams(const Params &params);
152};
153
154} // namespace eve::procgen
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
int island
#define EVENGINE_API_DOMAINS
Definition Export.h:110
float warp
std::uint32_t height
std::uint32_t width
std::array< float, 3 > scale
std::uint32_t seed
Definition PointSet.cpp:807
Owning, typed generation parameters.
Definition Params.h:27
Deterministic terrain height sampling (Red Blob Games / Perlin fBm recipe).
TerrainSampler()=default
Terrain sampler.
std::vector< ParamSpec > params
double sample(const Heightmap &map, double u, double v)
Sample.
bool enabled
Deterministic value-noise helpers for pixel textures. When periodX/periodY > 0, lattice wraps for sea...
Definition NoiseField.h:13
TerrainBands public API.
uint32_t semanticAt(float height) const
Semantic at.
static TerrainBands fromParams(const Params &params)
From params.