Cuberite
A lightweight, fast and extensible game server for Minecraft
RidgedNoise.h
Go to the documentation of this file.
1 
2 // RidgedNoise.h
3 
4 // Implements the cRidgedNoise template class that generates ridged noise based on another noise provider.
5 
6 
7 
8 
9 
10 #pragma once
11 
12 
13 
14 
15 
16 template <typename N>
18 {
19 public:
21  cRidgedNoise(void):
22  m_Noise(0)
23  {
24  }
25 
26 
28  cRidgedNoise(int a_Seed):
29  m_Noise(a_Seed)
30  {
31  }
32 
33 
35  void SetSeed(int a_Seed)
36  {
37  m_Noise.SetSeed(a_Seed);
38  }
39 
40 
42  void Generate2D(
43  NOISE_DATATYPE * a_Array,
44  int a_SizeX, int a_SizeY,
45  NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX,
46  NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY
47  ) const
48  {
49  int ArrayCount = a_SizeX * a_SizeY;
50  m_Noise.Generate2D(
51  a_Array, a_SizeX, a_SizeY,
52  a_StartX, a_EndX,
53  a_StartY, a_EndY
54  );
55  for (int i = 0; i < ArrayCount; i++)
56  {
57  a_Array[i] = std::abs(a_Array[i]);
58  }
59  }
60 
61 
63  void Generate3D(
64  NOISE_DATATYPE * a_Array,
65  int a_SizeX, int a_SizeY, int a_SizeZ,
66  NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX,
67  NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY,
68  NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ
69  ) const
70  {
71  int ArrayCount = a_SizeX * a_SizeY * a_SizeZ;
72  m_Noise.Generate2D(
73  a_Array, a_SizeX, a_SizeY, a_SizeZ,
74  a_StartX, a_EndX,
75  a_StartY, a_EndY,
76  a_StartZ, a_EndZ
77  );
78  for (int i = 0; i < ArrayCount; i++)
79  {
80  a_Array[i] = std::abs(a_Array[i]);
81  }
82  }
83 
84 protected:
86 } ;
87 
88 
89 
90 
91 
float NOISE_DATATYPE
The datatype used by all the noise generators.
Definition: Noise.h:9
void SetSeed(int a_Seed)
Sets the seed for the underlying noise.
Definition: RidgedNoise.h:35
cRidgedNoise(void)
Creates a new instance with the seed set to 0.
Definition: RidgedNoise.h:21
void Generate2D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY) const
Fills a 2D array with the values of the noise.
Definition: RidgedNoise.h:42
cRidgedNoise(int a_Seed)
Creates a new instance with the specified seed.
Definition: RidgedNoise.h:28
void Generate3D(NOISE_DATATYPE *a_Array, int a_SizeX, int a_SizeY, int a_SizeZ, NOISE_DATATYPE a_StartX, NOISE_DATATYPE a_EndX, NOISE_DATATYPE a_StartY, NOISE_DATATYPE a_EndY, NOISE_DATATYPE a_StartZ, NOISE_DATATYPE a_EndZ) const
Fills a 3D array with the values of the noise.
Definition: RidgedNoise.h:63