fixed terrain rendering - visualized normals
[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         friend class Terrain;
14 };
15
16 /* parameters needed in terrain generation */
17
18 struct TerrainParams {
19         float xsz; /* terrain size in x axis */
20         float ysz; /* terrain size in y axis */
21         float max_height; /* max height of the heightfield */
22         int xtiles; /* number of tiles in x axis */
23         int ytiles; /* number of tiles in y axis */
24         int tile_usub;
25         int tile_vsub;
26         int num_octaves; /* Perlin noise sums */
27         float noise_freq; /* Perlin noise scaling factor */
28         Image *coarse_heightmap; /* mask for low detail heightmap */
29 };
30
31 class Terrain {
32 private:
33         TerrainParams params;
34         mutable Scene *vis_scene; /* set of visible tiles returned by get_visible */
35
36         std::vector<TerrainTile> tiles;
37         
38 public:
39         Material material;
40
41         Terrain();
42         ~Terrain();
43
44         bool init();
45         void destroy();
46
47         bool generate(const TerrainParams &params);
48         Scene *get_visible(const Camera *camera) const;
49 };
50
51 #endif // TERRAIN_H_