12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "RandNoise.h"
- #include <Random.h>
- #include <stdlib.h>
- #include "Constants.h"
- #include "FastNoiseLite.h"
- #include "FastNoiseWrapper.h"
- RandNoise::RandNoise(int seed)
- : Noise(),
- seed(seed)
- {
- FastNoiseLite* n = new FastNoiseLite(seed);
- n->SetNoiseType(FastNoiseLite::NoiseType::NoiseType_OpenSimplex2S);
- n->SetRotationType3D(FastNoiseLite::RotationType3D::RotationType3D_None);
- n->SetFrequency(0.333f);
- n->SetFractalOctaves(1);
- n->SetFractalType(FastNoiseLite::FractalType::FractalType_None);
- n->SetDomainWarpAmp(30.f);
- noise = new FastNoiseWrapper(n, seed);
- }
- RandNoise::~RandNoise()
- {
- delete noise;
- }
- int RandNoise::getSeed() const
- {
- return seed;
- }
- double RandNoise::getNoise(double x, double y, double z)
- {
- double n = noise->getNoise(
- x * 4 + y + z * 7, 7 * x + 4 * y + z, x + 7 * y + 4 * z);
- assert(n >= 0 && n <= 1);
- return n;
- }
|