added function that procedurally generates heightfield
[demo] / src / terrain.h
1 #ifndef TERRAIN_H_
2 #define TERRAIN_H_
3
4 class Camera;
5 class Image;
6 class Scene;
7
8 // terrain 8a ftiaxnei skini k taisma renderer
9 class TerrainTile {
10 private:
11         Mesh *mesh;
12
13 };
14
15 /* parameters needed in terrain generation */
16
17 struct TerrainParams {
18         float xsz; /* terrain size in x axis */
19         float ysz; /* terrain size in y axis */
20         float max_height; /* max height of the heightfield */
21         int xtiles; /* number of tiles in x axis */
22         int ytiles; /* number of tiles in y axis */
23         int tile_usub;
24         int tile_vsub;
25         int num_octaves; /* Perlin noise sums */
26         Image *coarse_heightmap; /* mask for low detail heightmap */
27 };
28
29 class Terrain {
30 private:
31         TerrainParams params;
32         mutable Scene *vis_scene; /* set of visible tiles returned by get_visible */
33
34         std::vector<TerrainTile> tiles;
35         
36 public:
37         Terrain();
38         ~Terrain();
39
40         bool generate(const TerrainParams &params);
41         Scene *get_visible(const Camera *camera) const;
42 };
43
44 #endif // TERRAIN_H_