DistortedVoronoi biome generator

git-svn-id: http://mc-server.googlecode.com/svn/trunk@532 0a769ca7-a7f5-676a-18bf-c427514a06d6
master
madmaxoft@gmail.com 2012-05-31 20:34:58 +00:00
parent c95b11b83a
commit e8c905f078
3 changed files with 67 additions and 36 deletions

View File

@ -25,23 +25,6 @@ void cBioGenConstant::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBioGenDistortedVoronoi:
void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{
// TODO: Replace this placeholder
ASSERT(!"Not implemented yet");
for (int i = 0; i < ARRAYCOUNT(a_BiomeMap); i++)
{
a_BiomeMap[i] = (EMCSBiome)(a_ChunkX + a_ChunkZ);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBiomeGenList: // cBiomeGenList:
@ -177,3 +160,44 @@ EMCSBiome cBioGenVoronoi::VoronoiBiome(int a_BlockX, int a_BlockZ)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// cBioGenDistortedVoronoi:
void cBioGenDistortedVoronoi::GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap)
{
int BaseZ = cChunkDef::Width * a_ChunkZ;
int BaseX = cChunkDef::Width * a_ChunkX;
for (int z = 0; z < cChunkDef::Width; z++)
{
int AbsoluteZ = BaseZ + z;
for (int x = 0; x < cChunkDef::Width; x++)
{
int DistX, DistZ;
Distort(BaseX + x, AbsoluteZ, DistX, DistZ);
cChunkDef::SetBiome(a_BiomeMap, x, z, VoronoiBiome(DistX, DistZ));
} // for x
} // for z
}
void cBioGenDistortedVoronoi::Distort(int a_BlockX, int a_BlockZ, int & a_DistortedX, int & a_DistortedZ)
{
double NoiseX = m_Noise.CubicNoise3D((float)a_BlockX / m_CellSize, (float)a_BlockZ / m_CellSize, 1000);
NoiseX += 0.5 * m_Noise.CubicNoise3D(2 * (float)a_BlockX / m_CellSize, 2 * (float)a_BlockZ / m_CellSize, 2000);
NoiseX += 0.08 * m_Noise.CubicNoise3D(16 * (float)a_BlockX / m_CellSize, 16 * (float)a_BlockZ / m_CellSize, 3000);
double NoiseZ = m_Noise.CubicNoise3D((float)a_BlockX / m_CellSize, (float)a_BlockZ / m_CellSize, 4000);
NoiseZ += 0.5 * m_Noise.CubicNoise3D(2 * (float)a_BlockX / m_CellSize, 2 * (float)a_BlockZ / m_CellSize, 5000);
NoiseZ += 0.08 * m_Noise.CubicNoise3D(16 * (float)a_BlockX / m_CellSize, 16 * (float)a_BlockZ / m_CellSize, 6000);
a_DistortedX = a_BlockX + (int)(m_CellSize * 0.5 * NoiseX);
a_DistortedZ = a_BlockZ + (int)(m_CellSize * 0.5 * NoiseZ);
}

View File

@ -39,24 +39,6 @@ protected:
class cBioGenDistortedVoronoi :
public cBiomeGen
{
public:
cBioGenDistortedVoronoi(int a_Seed) : m_Seed(a_Seed) {}
protected:
int m_Seed;
// cBiomeGen override:
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
} ;
/// Base class for generators that use a list of available biomes. This class takes care of the list. /// Base class for generators that use a list of available biomes. This class takes care of the list.
class cBiomeGenList : class cBiomeGenList :
public cBiomeGen public cBiomeGen
@ -128,3 +110,26 @@ protected:
class cBioGenDistortedVoronoi :
public cBioGenVoronoi
{
public:
cBioGenDistortedVoronoi(int a_Seed, int a_CellSize, const AString & a_Biomes) :
cBioGenVoronoi(a_Seed, a_CellSize, a_Biomes)
{
}
protected:
// cBiomeGen override:
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
/// Distorts the coords using a Perlin-like noise
void Distort(int a_BlockX, int a_BlockZ, int & a_DistortedX, int & a_DistortedZ);
} ;

View File

@ -139,7 +139,9 @@ void cChunkGenerator::InitBiomeGen(cIniFile & a_IniFile)
{ {
LOGWARNING("Unknown BiomeGen \"%s\", using \"distortedvoronoi\" instead.", BiomeGenName.c_str()); LOGWARNING("Unknown BiomeGen \"%s\", using \"distortedvoronoi\" instead.", BiomeGenName.c_str());
} }
m_BiomeGen = new cBioGenDistortedVoronoi(m_Seed); int CellSize = a_IniFile.GetValueI("Generator", "DistortedVoronoiCellSize", 96);
AString Biomes = a_IniFile.GetValue("Generator", "DistortedVoronoiBiomes", "");
m_BiomeGen = new cBioGenDistortedVoronoi(m_Seed, CellSize, Biomes);
} }
} }