00001 00002 00003 #ifndef TERRAIN_H 00004 #define TERRAIN_H 00005 00006 00007 #include "MeshModel.h" 00008 00009 #include "Vector3f.h" 00010 00011 00012 namespace pge { 00013 00014 00015 class Image; 00016 class Texture; 00017 00018 00019 class HeightmapLoader { 00020 00021 public: 00022 //************************************************************************ 00023 // 00024 // Constructor 00025 // 00026 //************************************************************************ 00028 HeightmapLoader(const std::string &file); 00029 00030 00031 //************************************************************************ 00032 // 00033 // Destructor 00034 // 00035 //************************************************************************ 00037 virtual ~HeightmapLoader(void); 00038 00039 00040 //************************************************************************ 00041 // 00042 // Functions 00043 // 00044 //************************************************************************ 00045 Vector3f* generateTerrain(Vector3f startCorner, float mapScale, int vertexNumX, int vertexNumZ, float terrainWidth, float terrainDepth); 00046 00047 00048 private: 00049 //************************************************************************ 00050 // 00051 // Functions 00052 // 00053 //************************************************************************ 00054 bool loadHeightmap(const std::string &file); 00055 00056 00057 //************************************************************************ 00058 // 00059 // Variables 00060 // 00061 //************************************************************************ 00062 Image *m_heightmap; 00063 }; 00064 00065 00066 class Terrain : public MeshModel { 00067 00068 public: 00069 //************************************************************************ 00070 // 00071 // Constructor 00072 // 00073 //************************************************************************ 00075 Terrain(const std::string &heightmapFile, const std::string &textureFile, 00076 Vector3f startCorner, float mapScale, int vertexNumX, int vertexNumZ, 00077 float terrainWidth, float terrainDepth); 00078 00079 00080 //************************************************************************ 00081 // 00082 // Destructor 00083 // 00084 //************************************************************************ 00086 virtual ~Terrain(void); 00087 00088 00089 //************************************************************************ 00090 // 00091 // Functions 00092 // 00093 //************************************************************************ 00094 void createTerrain(Vector3f *vertices, int vertexNumX, int vertexNumZ); 00095 00096 00097 private: 00098 //************************************************************************ 00099 // 00100 // Variables 00101 // 00102 //************************************************************************ 00103 Texture *m_texture; 00104 }; 00105 }; 00106 00107 #endif