summaryrefslogtreecommitdiffstats
path: root/src/Generating/HeiGen.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-06-09 23:40:51 +0200
committermadmaxoft <github@xoft.cz>2014-06-09 23:40:51 +0200
commit9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f (patch)
tree2d8c81b23358817f5cb6d50f2f633ceca5d754fc /src/Generating/HeiGen.cpp
parentAdded cRidgedMultiNoise, fixed cPerlinNoise. (diff)
downloadcuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar.gz
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar.bz2
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar.lz
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar.xz
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.tar.zst
cuberite-9ff0ef87d4bca688b7fab8c7f4c9f9fcf683c06f.zip
Diffstat (limited to '')
-rw-r--r--src/Generating/HeiGen.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/Generating/HeiGen.cpp b/src/Generating/HeiGen.cpp
index 3621421c2..25ac912fd 100644
--- a/src/Generating/HeiGen.cpp
+++ b/src/Generating/HeiGen.cpp
@@ -47,6 +47,10 @@ cTerrainHeightGen * cTerrainHeightGen::CreateHeightGen(cIniFile &a_IniFile, cBio
{
res = new cEndGen(a_Seed);
}
+ else if (NoCaseCompare(HeightGenName, "Mountains") == 0)
+ {
+ res = new cHeiGenMountains(a_Seed);
+ }
else if (NoCaseCompare(HeightGenName, "Noise3D") == 0)
{
res = new cNoise3DComposable(a_Seed);
@@ -301,6 +305,68 @@ void cHeiGenClassic::InitializeHeightGen(cIniFile & a_IniFile)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// cHeiGenMountains:
+
+cHeiGenMountains::cHeiGenMountains(int a_Seed) :
+ m_Seed(a_Seed),
+ m_Noise(a_Seed)
+{
+}
+
+
+
+
+
+void cHeiGenMountains::GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap)
+{
+ NOISE_DATATYPE StartX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width);
+ NOISE_DATATYPE EndX = (NOISE_DATATYPE)(a_ChunkX * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE StartZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width);
+ NOISE_DATATYPE EndZ = (NOISE_DATATYPE)(a_ChunkZ * cChunkDef::Width + cChunkDef::Width - 1);
+ NOISE_DATATYPE Workspace[16 * 16];
+ NOISE_DATATYPE Noise[16 * 16];
+ NOISE_DATATYPE PerlinNoise[16 * 16];
+ m_Noise.Generate2D(Noise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ m_Perlin.Generate2D(PerlinNoise, 16, 16, StartX, EndX, StartZ, EndZ, Workspace);
+ for (int z = 0; z < cChunkDef::Width; z++)
+ {
+ int IdxZ = z * cChunkDef::Width;
+ for (int x = 0; x < cChunkDef::Width; x++)
+ {
+ int idx = IdxZ + x;
+ int hei = 100 - (int)((Noise[idx] + PerlinNoise[idx]) * 15);
+ if (hei < 10)
+ {
+ hei = 10;
+ }
+ if (hei > 250)
+ {
+ hei = 250;
+ }
+ cChunkDef::SetHeight(a_HeightMap, x , z, hei);
+ } // for x
+ } // for z
+}
+
+
+
+
+
+void cHeiGenMountains::InitializeHeightGen(cIniFile & a_IniFile)
+{
+ // TODO: Read the params from an INI file
+ m_Noise.AddOctave(0.1f, 0.1f);
+ m_Noise.AddOctave(0.05f, 0.5f);
+ m_Noise.AddOctave(0.02f, 1.5f);
+
+ m_Perlin.AddOctave(0.01f, 1.5f);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cHeiGenBiomal:
const cHeiGenBiomal::sGenParam cHeiGenBiomal::m_GenParam[256] =