12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "GrasslandBiom.h"
- #include "BlockType.h"
- #include "BasicBlocks.h"
- #include "FastNoiseLite.h"
- #include "FastNoiseWrapper.h"
- #include "TreeTemplate.h"
- GrasslandBiom::GrasslandBiom()
- : BiomGenerator()
- {
- addTemplateGenerator(new TreeTemplate(0.02f, BirchBlockType::INSTANCE, LeavesBlockType::INSTANCE, 8, 15));
- addTemplateGenerator(new TreeTemplate(0.01f, BeechBlockType::INSTANCE, LeavesBlockType::INSTANCE, 8, 13));
- addTemplateGenerator(new TreeTemplate(0.005f, OakBlockType::INSTANCE, LeavesBlockType::INSTANCE, 10, 15));
- 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;
- }
- 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;
- }
|