File: Sm3Map.h

package info (click to toggle)
spring 0.81.2.1%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,496 kB
  • ctags: 37,096
  • sloc: cpp: 238,659; ansic: 13,784; java: 12,175; awk: 3,428; python: 1,159; xml: 738; perl: 405; sh: 297; makefile: 267; pascal: 228; objc: 192
file content (84 lines) | stat: -rw-r--r-- 2,375 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef SM3_MAP_H
#define SM3_MAP_H

#include <map>
#include "Map/ReadMap.h"
#include "terrain/TerrainBase.h"
#include "terrain/Terrain.h"
#include "Rendering/Textures/Bitmap.h"
#include "Frustum.h"

class CSm3GroundDrawer;


class CSm3ReadMap : public CReadMap
{
public:
	CR_DECLARE(CSm3ReadMap);

	CSm3ReadMap();
	~CSm3ReadMap();
	void Initialize(const char* mapname); // throws std::runtime_exception on errors
	void ConfigNotify(const std::string& key, const std::string& value);

	CBaseGroundDrawer* GetGroundDrawer();
	void UpdateHeightmapUnsynced(int x1, int y1, int x2, int y2);
	inline const float* GetHeightmap() const { return renderer->GetHeightmap(); }

	inline void SetHeight(const int& idx, const float& h) {
		renderer->GetHeightmap()[idx] = h;
		currMinHeight = std::min(h, currMinHeight);
		currMaxHeight = std::max(h, currMaxHeight);
	}
	inline void AddHeight(const int& idx, const float& a) {
		renderer->GetHeightmap()[idx] += a;
		currMinHeight = std::min(renderer->GetHeightmap()[idx], currMinHeight);
		currMaxHeight = std::max(renderer->GetHeightmap()[idx], currMaxHeight);
	}

	void Update();
	void Explosion(float x, float y, float strength);
	GLuint GetShadingTexture() const; // a texture with RGB for shading and A for height
	void DrawMinimap() const; // draw the minimap in a quad (with extends: (0,0)-(1,1))

	// Feature creation
	int GetNumFeatures();
	int GetNumFeatureTypes();
	void GetFeatureInfo(MapFeatureInfo* f); // returns MapFeatureInfo[GetNumFeatures()]
	const char* GetFeatureTypeName(int typeID);

	// Bitmaps (such as metal map, grass map, ...), handling them with a string as type seems flexible...
	// Some map types:
	//   "metal"  -  metalmap
	//   "grass"  -  grassmap
	unsigned char *GetInfoMap (const std::string& name, MapBitmapInfo* bm);
	void FreeInfoMap(const std::string& name, unsigned char *data);

	void GridVisibility(CCamera *cam, int quadSize, float maxdist, IQuadDrawer *cb, int extraSize);

protected:
	CSm3GroundDrawer *groundDrawer;
	terrain::Terrain *renderer;

	struct InfoMap {
		InfoMap ();
		~InfoMap ();
		int w,h;
		unsigned char *data;
	};

	GLuint minimapTexture;

	std::map<std::string, InfoMap> infoMaps;
	friend class CSm3GroundDrawer;

	std::vector<std::string*> featureTypes;
	MapFeatureInfo *featureInfo;
	unsigned int numFeatures;
	void LoadFeatureData();

	Frustum tmpFrustum;
};


#endif