00001 /*************************************************************************** 00002 ctilesurface.h - Bitmap data of a tile 00003 ------------------- 00004 begin : ma apr 13 2009 00005 copyright : (C) 2009 by CJP 00006 email : cornware-cjp@users.sourceforge.net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #ifndef LIBPROCTERCTILESURFACE_H 00018 #define LIBPROCTERCTILESURFACE_H 00019 00020 #include <string> 00021 #include <vector> 00022 00023 #include <libprocter/cgridposition.h> 00024 #include <libprocter/ctexture.h> 00025 #include <libprocter/cmap.h> 00026 00027 namespace libProcTer { 00028 00029 class CPlanet; 00030 00039 class CTileSurface{ 00040 public: 00051 CTileSurface(const CPlanet *planet, const CGridPosition &pos, CTileSurface **parents); 00053 virtual ~CTileSurface(); 00054 00060 enum eTextureType {eColor, eHeight, eTextureTypeMax}; 00061 00063 CTexture *getTexture(eTextureType type); 00064 00066 inline const CGridPosition &getPosition() const 00067 {return m_Position;} 00068 00070 CVector getTexCoords(CGridPosition pos) const; 00071 00085 double getAltAndSlope(const CGridPosition &pos, double &dzdx, double &dzdy) const; 00086 00087 00107 virtual CTileSurface *createChildSurface(const CGridPosition &pos, CTileSurface **parents) const; 00108 00109 00110 00126 virtual bool load()=0; 00127 00134 virtual std::string getClassName() const=0; 00135 00147 virtual const CMapBase *getInternalMap(const std::string &name) const; 00148 00157 const CMapBase *getInternalMap(eTextureType type) const; 00158 00159 protected: 00165 void updateTextures(); 00166 00168 inline double getTileSize() const 00169 {return m_TileSize;} 00170 00172 inline const CPlanet *getPlanet() const 00173 {return m_Planet;} 00174 00176 inline const CTileSurface * const *getParents() const 00177 {return m_Parents;} 00178 00179 //Protected, as they need to be modified by derived classes 00181 CMap<int> m_HeightMap; 00183 CMap<SColor> m_ColorMap; 00184 00186 void checkHeightmapValues() const; 00187 00188 private: 00189 const CPlanet *m_Planet; 00190 CGridPosition m_Position; 00191 CTileSurface *m_Parents[4]; 00192 00193 //Number should correspond with eTextureType 00194 CTexture *m_Textures[eTextureTypeMax]; 00195 00196 double m_TileSize; //cached: can be derived from radius and m_Position 00197 }; 00198 00199 } 00200 00201 #endif