2018-02-12 17:40:00 +01:00
|
|
|
/**
|
|
|
|
* Perlin Noise implementation for the ground (header file)
|
|
|
|
**/
|
2018-02-13 17:05:49 +01:00
|
|
|
#pragma once
|
2018-02-12 17:40:00 +01:00
|
|
|
#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);
|
2018-02-13 18:42:15 +01:00
|
|
|
|
|
|
|
virtual Point location_hint() const;
|
|
|
|
Point location_hint(double x, double z) const;
|
2018-02-12 17:40:00 +01:00
|
|
|
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;
|
|
|
|
};
|