8 #include "../Noise/InterpolNoise.h"
10 #include "../LinearUpscale.h"
11 #include "../IniFile.h"
51 m_Choice.
Generate3D(smallChoice, 33, 5, 5, startX, endX, startY, endY, startZ, endZ, workspace);
61 int idxChoice = 257 * 17 * z + 257 * x;
66 int height =
static_cast<int>(
ClampedLerp(heightA, heightB, choice[idxChoice++]));
67 a_Shape[idxShape++] = (y < height) ? 1 : 0;
88 for (
int i = 0; i < 4; i++)
118 return std::make_unique<cTwoHeights>(a_Seed, a_BiomeGen);
std::unique_ptr< cTerrainShapeGen > CreateShapeGenTwoHeights(int a_Seed, cBiomeGen &a_BiomeGen)
Creates and returns a new instance of the cTwoHeights terrain shape generator.
void LinearUpscale3DArray(TYPE *a_Src, int a_SrcSizeX, int a_SrcSizeY, int a_SrcSizeZ, TYPE *a_Dst, int a_UpscaleX, int a_UpscaleY, int a_UpscaleZ)
Linearly interpolates values in the array between the equidistant anchor points (upscales).
NOISE_DATATYPE ClampedLerp(NOISE_DATATYPE a_Val1, NOISE_DATATYPE a_Val2, NOISE_DATATYPE a_Ratio)
Linearly interpolates between two values, clamping the ratio to [0, 1] first.
float NOISE_DATATYPE
The datatype used by all the noise generators.
Wraps the chunk coords into a single structure.
HEIGHTTYPE HeightMap[Width *Width]
The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the hig...
static HEIGHTTYPE GetHeight(const HeightMap &a_HeightMap, int a_X, int a_Z)
Byte Shape[256 *16 *16]
The datatype used to represent the entire chunk worth of shape.
The interface that a biome generator must implement A biome generator takes chunk coords on input and...
The interface that a terrain shape generator must implement A terrain shape generator takes chunk coo...
virtual void InitializeHeightGen(cIniFile &a_IniFile) override
Initializes the generator, reading its parameters from the INI file.
virtual void GenHeightMap(cChunkCoords a_ChunkCoords, cChunkDef::HeightMap &a_HeightMap) override
Retrieves the heightmap for the specified chunk.
cOctavedNoise< cInterpolNoise< Interp5Deg > > m_Choice
The noise used to decide between the two heightmaps.
virtual void GenShape(cChunkCoords a_ChunkCoords, cChunkDesc::Shape &a_Shape) override
Generates the shape for the given chunk.
cHeiGenBiomal m_HeightA
The first height generator.
NOISE_DATATYPE m_FrequencyY
cHeiGenBiomal m_HeightB
The second height generator.
virtual void InitializeShapeGen(cIniFile &a_IniFile) override
Reads parameters from the ini file, prepares generator for use.
NOISE_DATATYPE m_FrequencyX
The base frequencies for m_Choice in each of the world axis directions.
cTwoHeights(int a_Seed, cBiomeGen &a_BiomeGen)
NOISE_DATATYPE m_FrequencyZ
double GetValueSetF(const AString &keyname, const AString &valuename, const double defValue=0.0)
void Generate3D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ, NOISE_DATATYPE *a_Workspace=nullptr) const
Fills a 3D array with the values of the noise.
void AddOctave(NOISE_DATATYPE a_Frequency, NOISE_DATATYPE a_Amplitude)
Adds a new octave to the list of octaves that compose this noise.