2012-05-25 03:18:52 -04:00
|
|
|
|
|
|
|
// BioGen.h
|
|
|
|
|
|
|
|
/*
|
|
|
|
Interfaces to the various biome generators:
|
|
|
|
- cBioGenConstant
|
|
|
|
- cBioGenCheckerboard
|
|
|
|
- cBioGenDistortedVoronoi
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cChunkGenerator.h"
|
2012-05-27 10:17:47 -04:00
|
|
|
#include "cNoise.h"
|
2012-05-25 03:18:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBioGenConstant :
|
|
|
|
public cBiomeGen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBioGenConstant(EMCSBiome a_Biome) : m_Biome(a_Biome) {}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
EMCSBiome m_Biome;
|
|
|
|
|
|
|
|
// cBiomeGen override:
|
|
|
|
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-27 07:07:23 -04:00
|
|
|
/// Base class for generators that use a list of available biomes. This class takes care of the list.
|
|
|
|
class cBiomeGenList :
|
2012-05-25 03:18:52 -04:00
|
|
|
public cBiomeGen
|
|
|
|
{
|
2012-05-27 07:07:23 -04:00
|
|
|
protected:
|
|
|
|
cBiomeGenList(const AString & a_Biomes)
|
2012-05-27 06:51:04 -04:00
|
|
|
{
|
|
|
|
InitializeBiomes(a_Biomes);
|
|
|
|
}
|
2012-05-25 03:18:52 -04:00
|
|
|
|
2012-05-27 06:51:04 -04:00
|
|
|
// List of biomes that the generator is allowed to generate:
|
|
|
|
typedef std::vector<EMCSBiome> EMCSBiomes;
|
|
|
|
EMCSBiomes m_Biomes;
|
2012-05-27 07:07:23 -04:00
|
|
|
int m_BiomesCount; // Pulled out of m_Biomes for faster access
|
2012-05-27 06:51:04 -04:00
|
|
|
|
|
|
|
void InitializeBiomes(const AString & a_Biomes);
|
|
|
|
|
2012-05-27 07:07:23 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBioGenCheckerboard :
|
|
|
|
public cBiomeGenList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBioGenCheckerboard(int a_BiomeSize, const AString & a_Biomes) :
|
|
|
|
cBiomeGenList(a_Biomes),
|
|
|
|
m_BiomeSize((a_BiomeSize < 8) ? 8 : a_BiomeSize)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
int m_BiomeSize;
|
|
|
|
|
2012-05-25 03:18:52 -04:00
|
|
|
// cBiomeGen override:
|
|
|
|
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-27 10:17:47 -04:00
|
|
|
|
|
|
|
class cBioGenVoronoi :
|
|
|
|
public cBiomeGenList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBioGenVoronoi(int a_Seed, int a_CellSize, const AString & a_Biomes) :
|
|
|
|
cBiomeGenList(a_Biomes),
|
2012-05-27 10:31:00 -04:00
|
|
|
m_CellSize((a_CellSize > 4) ? a_CellSize : 4),
|
2012-05-27 10:17:47 -04:00
|
|
|
m_Noise(a_Seed)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
int m_CellSize;
|
|
|
|
|
|
|
|
cNoise m_Noise;
|
|
|
|
|
|
|
|
// cBiomeGen override:
|
|
|
|
virtual void GenBiomes(int a_ChunkX, int a_ChunkZ, cChunkDef::BiomeMap & a_BiomeMap) override;
|
|
|
|
|
|
|
|
EMCSBiome VoronoiBiome(int a_BlockX, int a_BlockZ);
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-05-31 16:34:58 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|