123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <Random.h>
- #include <stdlib.h>
- #include "RandNoise.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;
- }
|