Eris
1.3.21
|
00001 // 00002 // C++ Interface: TerrainMod 00003 // 00004 // Description: The purpose of this class is to handle the bulk of the work 00005 // involved with using Mercator::TerrainMods. It handles parsing 00006 // the Atlas data and storing all the information needed by 00007 // TerrainGenerator to add and remove them from the Terrain. 00008 // 00009 // TerrainGenerator listens for changes in the modifier and 00010 // updates or removes the modifiers from the terrain as needed. 00011 // 00012 // 00013 // Author: Tamas Bates <rhymer@gmail.com>, (C) 2008 00014 // Author: Erik Hjortsberg <erik.hjortsberg@iteam.se>, (C) 2008 00015 // 00016 // This program is free software; you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation; either version 2 of the License, or 00019 // (at your option) any later version. 00020 // 00021 // This program is distributed in the hope that it will be useful, 00022 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 // GNU General Public License for more details. 00025 // 00026 // You should have received a copy of the GNU General Public License 00027 // along with this program; if not, write to the Free Software 00028 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.// 00029 // 00030 #ifndef ERIS_TERRAINMOD_H 00031 #define ERIS_TERRAINMOD_H 00032 00033 #include <Atlas/Message/Element.h> 00034 00035 #include <wfmath/point.h> 00036 00037 namespace Mercator { 00038 class TerrainMod; 00039 } 00040 00041 namespace Eris { 00042 00048 class TerrainModTranslator 00049 { 00050 protected: 00051 template <template <int> class Shape> 00052 bool parseStuff(const WFMath::Point<3> & pos, 00053 const WFMath::Quaternion & orientation, 00054 const Atlas::Message::MapType& modElement, 00055 const std::string & typeName, 00056 Shape<2> & shape, 00057 const Atlas::Message::Element & shapeElement); 00058 00059 public: 00060 00061 bool parseData(const WFMath::Point<3> & pos, 00062 const WFMath::Quaternion &, 00063 const Atlas::Message::MapType &); 00064 00070 Mercator::TerrainMod* getModifier(); 00071 00072 TerrainModTranslator(); 00073 00074 protected: 00075 00076 static float parsePosition(const WFMath::Point<3> & pos, const Atlas::Message::MapType& modElement); 00077 00078 template <template <int> class Shape> 00079 static bool parseShape(const Atlas::Message::Element& shapeElement, 00080 const WFMath::Point<3>& pos, 00081 const WFMath::Quaternion& orientation, 00082 Shape<2> & shape); 00083 00084 template <template <template <int> class Shape> class Mod, 00085 template <int> class Shape> 00086 bool createInstance(Shape<2> & shape, 00087 const WFMath::Point<3>& pos, 00088 const Atlas::Message::MapType &, 00089 float, 00090 float); 00091 00092 template <template <template <int> class Shape> class Mod, 00093 template <int> class Shape> 00094 bool createInstance(Shape<2> & shape, 00095 const WFMath::Point<3>& pos, 00096 const Atlas::Message::MapType &); 00097 00098 Mercator::TerrainMod * m_mod; 00099 }; 00100 00101 } 00102 00103 #endif