Mercator  0.4.0
HeightMap.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2003 Alistair Riddoch, Damien McGinnes
4 
5 #ifndef MERCATOR_HEIGHTMAP_H
6 #define MERCATOR_HEIGHTMAP_H
7 
8 #include "BasePoint.h"
9 #include "Buffer.h"
10 
11 #include <wfmath/vector.h>
12 
13 namespace WFMath {
14 class MTRand;
15 }
16 
17 namespace Mercator {
18 
21 class HeightMap : public Buffer<float> {
22  private:
24  const int m_res;
26  float m_max;
28  float m_min;
29 
30  public:
31  explicit HeightMap(unsigned int resolution);
32  virtual ~HeightMap() = default;
33 
35  int getResolution() const {
36  return m_res;
37  }
38 
40  float get(int x, int z) const {
41  return m_data[z * (m_res + 1) + x];
42  }
43 
44  void getHeightAndNormal(float x, float z, float &h,
45  WFMath::Vector<3> &normal) const;
46  void getHeight(float x, float z, float &h) const;
47 
49  float getMax() const { return m_max; }
51  float getMin() const { return m_min; }
52 
53  void fill2d(const BasePoint& p1, const BasePoint& p2,
54  const BasePoint& p3, const BasePoint& p4);
55 
56  void checkMaxMin(float h);
57 
58  private:
59 
60  void fill1d(const BasePoint& l, const BasePoint &h, float *array) const;
61 
62  float qRMD(WFMath::MTRand& rng, float nn, float fn, float ff, float nf,
63  float roughness, float falloff, float depth) const;
64 
65 };
66 
67 
68 } // namespace Mercator
69 
70 #endif // MERCATOR_HEIGHTMAP_H
Definition: HeightMap.h:13
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: HeightMap.h:21
Template for managing buffers of data for a segment.
Definition: Buffer.h:12
Definition: Area.cpp:20
int getResolution() const
Accessor for resolution of this segment.
Definition: HeightMap.h:35
float getMin() const
Accessor for the minimum height value in this Segment.
Definition: HeightMap.h:51
Point on the fundamental grid that is used as the basis for terrain.
Definition: BasePoint.h:19
float getMax() const
Accessor for the maximum height value in this Segment.
Definition: HeightMap.h:49