1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include "GrasslandBiom.h"
- #include "BlockType.h"
- #include "BasicBlocks.h"
- #include "FastNoiseLite.h"
- #include "FastNoiseWrapper.h"
- #include "TreeTemplate.h"
- #include "NoBlock.h"
- GrasslandBiom::GrasslandBiom()
- : BiomGenerator()
- {
- addTemplateGenerator(new TreeTemplate(0.02f, BirchBlockType::INSTANCE, BirchLeavesBlockType::INSTANCE, 8, 15));
- addTemplateGenerator(new TreeTemplate(0.01f, BeechBlockType::INSTANCE, BeechLeavesBlockType::INSTANCE, 8, 13));
- addTemplateGenerator(new TreeTemplate(0.005f, OakBlockType::INSTANCE, OakLeavesBlockType::INSTANCE, 10, 15));
- addTemplateGenerator(new TreeTemplate(0.0025f, PineBlockType::INSTANCE, PineLeavesBlockType::INSTANCE, 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 CobbleBlockType::ID;
- return DirtBlockType::ID;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateBelowSurfaceBlock(int x, int y, int z)
- {
- return StoneBlockType::ID;
- }
- Framework::Either<Block*, int> GrasslandBiom::generateCaveBlock(int x, int y, int z)
- {
- return AirBlockBlockType::ID;
- }
- 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;
- }
|