29 lines
942 B
C++
29 lines
942 B
C++
/**
|
|
* Perlin Noise implementation for the ground (header file)
|
|
**/
|
|
#pragma once
|
|
#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);
|
|
double fBm(double x, double y, double z, int octaves, double
|
|
lacunarity, double gain) const;
|
|
|
|
virtual Point location_hint() const;
|
|
Point location_hint(double x, double z) const;
|
|
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;
|
|
};
|