From 41c2d41746582db5439dc51a3c35b60384ea1e4a Mon Sep 17 00:00:00 2001 From: miguel Date: Sat, 23 Sep 2017 23:13:25 +0200 Subject: integrated perlin noise map into game as minimap --- PerlinNoise.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 PerlinNoise.h (limited to 'PerlinNoise.h') diff --git a/PerlinNoise.h b/PerlinNoise.h new file mode 100644 index 0000000..9ef109b --- /dev/null +++ b/PerlinNoise.h @@ -0,0 +1,28 @@ +#include + +// THIS CLASS IS A TRANSLATION TO C++11 FROM THE REFERENCE +// JAVA IMPLEMENTATION OF THE IMPROVED PERLIN FUNCTION (see http://mrl.nyu.edu/~perlin/noise/) +// THE ORIGINAL JAVA IMPLEMENTATION IS COPYRIGHT 2002 KEN PERLIN + +// I ADDED AN EXTRA METHOD THAT GENERATES A NEW PERMUTATION VECTOR (THIS IS NOT PRESENT IN THE ORIGINAL IMPLEMENTATION) + +#ifndef PERLINNOISE_H +#define PERLINNOISE_H + +class PerlinNoise { + // The permutation vector + std::vector p; +public: + // Initialize with the reference values for the permutation vector + PerlinNoise(); + // Generate a new permutation vector based on the value of seed + PerlinNoise(unsigned int seed); + // Get a noise value, for 2D images z can have any value + double noise(double x, double y, double z); +private: + double fade(double t); + double lerp(double t, double a, double b); + double grad(int hash, double x, double y, double z); +}; + +#endif -- cgit v1.2.3