24 lines
711 B
C++
24 lines
711 B
C++
|
/**
|
||
|
* Perlin Noise implementation for the ground (header file)
|
||
|
**/
|
||
|
#include "Implicit.hpp"
|
||
|
#include <cmath>
|
||
|
#include <random>
|
||
|
#include <vector>
|
||
|
#include <algorithm>
|
||
|
|
||
|
class PerlinNoise : public ImplicitSurface {
|
||
|
std::vector<int> p;
|
||
|
public:
|
||
|
PerlinNoise();
|
||
|
PerlinNoise(unsigned int seed);
|
||
|
double operator() (double _x, double _y, double _z) const;
|
||
|
double noise(double x, double y) const;
|
||
|
Point normal_vector(double x, double y);
|
||
|
private:
|
||
|
double noise(double x, double y, double z) const;
|
||
|
double fade(double t) const;
|
||
|
double lerp(double t, double a, double b) const;
|
||
|
double grad(int hash, double x, double y, double z) const;
|
||
|
};
|