My Project
TerrainRegions.h
1 #pragma once
2 #include <map>
3 
4 namespace ParaTerrain
5 {
8  {
9  public:
10  CRegionLayer();
11  ~CRegionLayer();
12 
17  void LoadFromFile(const char* filename, int nBytesPerPixel = 0);
18 
20  DWORD GetPixelValue(int x, int y);
21 
23  inline int GetHeight() {return m_nHeight;}
24 
26  inline int GetWidth() {return m_nWidth;}
27 
29  const string& GetFileName(){return m_filename;};
30 
32  void SetFileName(const string& filename);
33  private:
35  int m_nHeight;
37  int m_nWidth;
39  char * m_pData;
40 
42  int m_nBytesPerRow;
43 
45  string m_filename;
46 
48  int m_nSize;
50  int m_nBytesPerPixel;
51  int m_dwTextureFormat;
52  };
53 
58  {
59  public:
61  ~CTerrainRegions();
62 
63  public:
64  typedef std::map<string, CRegionLayer*> RegionLayer_Map_Type;
66  void SetSize(float fWidth, float fHeight);
67 
69  DWORD GetValue(const string& sLayerName, float x, float y);
70 
72  DWORD GetValue(CRegionLayer* pLayer, float x, float y);
73 
75  void LoadRegion(const string& sLayerName, const char* filename);
76 
80  CRegionLayer* GetRegion(const string& sLayerName);
81 
83  RegionLayer_Map_Type& GetLayers() {return m_layers;}
84 
85  public:
86  // below are all accessor functions
87 
89  int GetNumOfRegions();
90 
93  void SetCurrentRegionIndex(int nRegion);
97  int GetCurrentRegionIndex();
98 
102  void SetCurrentRegionName(const string& name);
103 
105  const string& GetCurrentRegionName();
106 
108  void SetCurrentRegionFilepath(const string& filename);
109 
111  const string& GetCurrentRegionFilepath();
112 
113  private:
114  float m_fHeight;
115  float m_fWidth;
116 
117  // currently selected region index for accessor functions. -1 if invalid.
118  int m_nCurRegionIndex;
119 
120  // currently selected region name for accessor functions.
121  string m_sCurRegionName;
122 
124  RegionLayer_Map_Type m_layers;
125  };
126 }
Definition: SceneObject.h:15
void SetFileName(const string &filename)
set the file name.
Definition: TerrainRegions.cpp:140
const string & GetFileName()
get texture file path.
Definition: TerrainRegions.h:29
DWORD GetPixelValue(int x, int y)
get the value in image.
Definition: TerrainRegions.cpp:118
int GetHeight()
pixels columns
Definition: TerrainRegions.h:23
RegionLayer_Map_Type & GetLayers()
get the layers map.
Definition: TerrainRegions.h:83
void LoadFromFile(const char *filename, int nBytesPerPixel=0)
load from an image file.
Definition: TerrainRegions.cpp:44
a single region layer
Definition: TerrainRegions.h:7
the editable terrain regions associated with a terrain tile.
Definition: TerrainRegions.h:57
int GetWidth()
pixels rows
Definition: TerrainRegions.h:26