vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TerrainAlgorithm.h
Go to the documentation of this file.
1 
9 #ifndef VRECKO_NATURE_TERRAIN_TERRAINALGORITHM_H
10 #define VRECKO_NATURE_TERRAIN_TERRAINALGORITHM_H
11 
12 #include "../TerrainUtility.h"
13 #include <osg/Array>
14 
15 namespace APNature
16 {
18  {
19  protected:
20 
21  float *_terrain;
23 
24  public:
25 
31  // TODO: Add TerrainSurface and make TerrainAlgorithm abstract by inheriting from TerrainSurface. (?)
32  TerrainAlgorithm(int width, int height);
33 
35 
42  inline unsigned int PointIndex(int x, int y) const { return y * this->_width + x;}
43 
48  float GetLowestValue() const;
49 
54  float GetHighestValue() const;
55 
56  protected:
57 
64  float* Allocate(int width, int height);
65 
69  void Release();
70 
74  void Zero();
75 
80  void Flatten(float height);
81 
88  inline float GetPointHeight(int x, int y) const { return this->_terrain[PointIndex(x, y)]; }
89 
96  inline void SetPointHeight(int x, int y, float height) { this->_terrain[PointIndex(x, y)] = height;}
97 
98  };
99 }
100 
101 #endif