12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "GrasslandBiom.h"
- #include "BasicBlocks.h"
- #include "BlockType.h"
- #include "FastNoiseLite.h"
- #include "FastNoiseWrapper.h"
- #include "NoBlock.h"
- #include "TreeTemplate.h"
- GrasslandBiom::GrasslandBiom()
- : BiomGenerator()
- {
- addTemplateGenerator(new TreeTemplate(0.02f,
- BlockTypeEnum::WOOD_BIRCH,
- BlockTypeEnum::LEAVES_WOOD_BIRCH,
- 8,
- 15));
- addTemplateGenerator(new TreeTemplate(0.01f,
- BlockTypeEnum::WOOD_BEECH,
- BlockTypeEnum::LEAVES_WOOD_BEECH,
- 8,
- 13));
- addTemplateGenerator(new TreeTemplate(0.005f,
- BlockTypeEnum::WOOD_OAK,
- BlockTypeEnum::LEAVES_WOOD_OAK,
- 10,
- 15));
- addTemplateGenerator(new TreeTemplate(0.0025f,
- BlockTypeEnum::WOOD_PINE,
- BlockTypeEnum::LEAVES_WOOD_PINE,
- 15,
- 24));
- heightNoise = 0;
- }
- GrasslandBiom::~GrasslandBiom()
- {
- if (heightNoise) heightNoise->release();
- }
- Framework::Either<Block*, int> GrasslandBiom::generateSurfaceBlock(
- int x, int y, int z)
- {
- if (((float)rand() / (float)RAND_MAX) < 0.05f) // TODO: use random noise
- return BlockTypeEnum::STONE_COBBLE;
- return BlockTypeEnum::DIRT;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateBelowSurfaceBlock(
- int x, int y, int z)
- {
- return BlockTypeEnum::STONE;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateCaveBlock(
- int x, int y, int z)
- {
- return BlockTypeEnum::AIR;
- }
- Noise* GrasslandBiom::zHeightMapNoise(int seed)
- {
- if (heightNoise) return heightNoise;
- FastNoiseLite* noise = new FastNoiseLite(seed);
- noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
- FastNoiseWrapper* wrapper = new FastNoiseWrapper(noise, seed);
- wrapper->setMultiplier(0.2f);
- heightNoise = wrapper;
- return heightNoise;
- }
|