stratgame
diff 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 diff
1.1 --- a/level/src/terrain.h Fri May 25 05:28:20 2012 +0300 1.2 +++ b/level/src/terrain.h Sun May 27 07:00:48 2012 +0300 1.3 @@ -3,6 +3,7 @@ 1.4 1.5 #include <string> 1.6 #include <map> 1.7 +#include "tinyxml2.h" 1.8 1.9 class TerrainNode; 1.10 1.11 @@ -10,17 +11,26 @@ 1.12 private: 1.13 TerrainNode *root; 1.14 1.15 + float size; 1.16 + 1.17 public: 1.18 Terrain(); 1.19 ~Terrain(); 1.20 1.21 + bool load(tinyxml2::XMLElement *xelem); 1.22 + 1.23 + void set_size(float sz); 1.24 float get_height(float x, float y) const; 1.25 + 1.26 + void draw() const; 1.27 }; 1.28 1.29 1.30 class TerrainNode { 1.31 private: 1.32 - unsigned char *height; 1.33 + int map_xsz, map_ysz; 1.34 + float map_scale; 1.35 + unsigned char *hmap; 1.36 1.37 public: 1.38 TerrainNode *child[4]; 1.39 @@ -28,10 +38,17 @@ 1.40 TerrainNode(); 1.41 ~TerrainNode(); 1.42 1.43 + bool load(tinyxml2::XMLElement *xelem); 1.44 + bool load_heightmap(const char *fname); 1.45 + 1.46 + bool is_leaf() const; 1.47 + 1.48 TerrainNode *get_child(float x, float y); 1.49 const TerrainNode *get_child(float x, float y) const; 1.50 1.51 float get_height(float x, float y) const; 1.52 + 1.53 + void draw(float x, float y, float width, float height) const; 1.54 }; 1.55 1.56 #endif // TERRAIN_H_