Arch Game Engine  0.2
PerlinNoise.h
1 //Found here: http://stackoverflow.com/questions/4753055/perlin-noise-generation-for-terrain
2 
3 #pragma once
4 
6 {
7 public:
8 
9  // Constructor
10  PerlinNoise();
11  PerlinNoise(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed);
12 
13  // Get Height
14  double GetHeight(double x, double y) const;
15 
16  // Get
17  double Persistence() const { return persistence; }
18  double Frequency() const { return frequency; }
19  double Amplitude() const { return amplitude; }
20  int Octaves() const { return octaves; }
21  int RandomSeed() const { return randomseed; }
22 
23  // Set
24  void Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed);
25 
26  void SetPersistence(double _persistence) { persistence = _persistence; }
27  void SetFrequency( double _frequency) { frequency = _frequency; }
28  void SetAmplitude( double _amplitude) { amplitude = _amplitude; }
29  void SetOctaves( int _octaves) { octaves = _octaves; }
30  void SetRandomSeed( int _randomseed) { randomseed = _randomseed; }
31 
32 private:
33 
34  double Total(double i, double j) const;
35  double GetValue(double x, double y) const;
36  double Interpolate(double x, double y, double a) const;
37  double Noise(int x, int y) const;
38 
39  double persistence, frequency, amplitude;
40  int octaves, randomseed;
41 };