123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #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.002f,
- BlockTypeEnum::WOOD_BIRCH,
- BlockTypeEnum::LEAVES_WOOD_BIRCH,
- 8,
- 15));
- addTemplateGenerator(new TreeTemplate(0.001f,
- BlockTypeEnum::WOOD_BEECH,
- BlockTypeEnum::LEAVES_WOOD_BEECH,
- 8,
- 13));
- addTemplateGenerator(new TreeTemplate(0.0005f,
- BlockTypeEnum::WOOD_OAK,
- BlockTypeEnum::LEAVES_WOOD_OAK,
- 10,
- 15));
- addTemplateGenerator(new TreeTemplate(0.00025f,
- BlockTypeEnum::WOOD_PINE,
- BlockTypeEnum::LEAVES_WOOD_PINE,
- 15,
- 24));
- heightNoise = 0;
- undergroundDirdNoise = 0;
- surfaceSandNoise = 0;
- undergroundGravelNoise = 0;
- }
- GrasslandBiom::~GrasslandBiom()
- {
- if (heightNoise) heightNoise->release();
- }
- Framework::Either<Block*, int> GrasslandBiom::generateSurfaceBlock(
- int x, int y, int z)
- {
- if (surfaceSandNoise->getNoise((double)x, (double)y, (double)z) < 0.35)
- {
- return BlockTypeEnum::SAND;
- }
- if (undergroundGravelNoise->getNoise((double)x, (double)y, (double)z)
- < 0.35)
- {
- return BlockTypeEnum::GRAVEL;
- }
- return BlockTypeEnum::DIRT;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateBelowSurfaceBlock(
- int x, int y, int z)
- {
- if (undergroundDirdNoise->getNoise((double)x, (double)y, (double)z)
- < 0.35)
- {
- return BlockTypeEnum::DIRT;
- }
- if (undergroundGravelNoise->getNoise((double)x, (double)y, (double)z)
- < 0.35)
- {
- return BlockTypeEnum::GRAVEL;
- }
- return BlockTypeEnum::STONE;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateCaveBlock(
- int x, int y, int z)
- {
- return BlockTypeEnum::AIR;
- }
- void GrasslandBiom::setSeed(int seed)
- {
- BiomGenerator::setSeed(seed);
- if (heightNoise) heightNoise->release();
- FastNoiseLite* noise = new FastNoiseLite(seed);
- noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
- FastNoiseWrapper* wrapper = new FastNoiseWrapper(noise, seed);
- wrapper->setMultiplier(0.2f);
- heightNoise = wrapper;
- noise = new FastNoiseLite(seed);
- noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
- noise->SetFrequency(0.15f);
- undergroundDirdNoise = new FastNoiseWrapper(noise, seed);
- noise = new FastNoiseLite(seed + 1);
- noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
- noise->SetFrequency(0.125f);
- undergroundGravelNoise = new FastNoiseWrapper(noise, seed + 1);
- noise = new FastNoiseLite(seed + 2);
- noise->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_ValueCubic);
- noise->SetFrequency(0.1f);
- surfaceSandNoise = new FastNoiseWrapper(noise, seed + 2);
- }
- Noise* GrasslandBiom::zHeightMapNoise()
- {
- return heightNoise;
- }
|