stratgame

view level/src/terrain.h @ 5:2e38715de41b

terrain
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 27 May 2012 07:00:48 +0300
parents cd12944a8ea8
children
line source
1 #ifndef TERRAIN_H_
2 #define TERRAIN_H_
4 #include <string>
5 #include <map>
6 #include "tinyxml2.h"
8 class TerrainNode;
10 class Terrain {
11 private:
12 TerrainNode *root;
14 float size;
16 public:
17 Terrain();
18 ~Terrain();
20 bool load(tinyxml2::XMLElement *xelem);
22 void set_size(float sz);
23 float get_height(float x, float y) const;
25 void draw() const;
26 };
29 class TerrainNode {
30 private:
31 int map_xsz, map_ysz;
32 float map_scale;
33 unsigned char *hmap;
35 public:
36 TerrainNode *child[4];
38 TerrainNode();
39 ~TerrainNode();
41 bool load(tinyxml2::XMLElement *xelem);
42 bool load_heightmap(const char *fname);
44 bool is_leaf() const;
46 TerrainNode *get_child(float x, float y);
47 const TerrainNode *get_child(float x, float y) const;
49 float get_height(float x, float y) const;
51 void draw(float x, float y, float width, float height) const;
52 };
54 #endif // TERRAIN_H_