Added an experimental height generator, Mountains.
This commit is contained in:
parent
bead36f5ed
commit
9ff0ef87d4
@ -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);
|
||||
@ -300,6 +304,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:
|
||||
|
||||
|
@ -106,6 +106,27 @@ protected:
|
||||
|
||||
|
||||
|
||||
class cHeiGenMountains :
|
||||
public cTerrainHeightGen
|
||||
{
|
||||
public:
|
||||
cHeiGenMountains(int a_Seed);
|
||||
|
||||
protected:
|
||||
|
||||
int m_Seed;
|
||||
cRidgedMultiNoise m_Noise;
|
||||
cPerlinNoise m_Perlin;
|
||||
|
||||
// cTerrainHeightGen overrides:
|
||||
virtual void GenHeightMap(int a_ChunkX, int a_ChunkZ, cChunkDef::HeightMap & a_HeightMap) override;
|
||||
virtual void InitializeHeightGen(cIniFile & a_IniFile) override;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class cHeiGenBiomal :
|
||||
public cTerrainHeightGen
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user