Eris 1.3.18
TerrainModTranslator.h
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 public:
00051     virtual ~TerrainModTranslator();
00052     
00053 protected:
00054     template <template <int> class Shape>
00055     bool parseStuff(const WFMath::Point<3> & pos,
00056                     const WFMath::Quaternion & orientation,
00057                     const Atlas::Message::MapType& modElement,
00058                     const std::string & typeName,
00059                     Shape<2> & shape,
00060                     const Atlas::Message::Element & shapeElement);
00061 
00062 public:
00063 
00064     bool parseData(const WFMath::Point<3> & pos,
00065                    const WFMath::Quaternion &,
00066                    const Atlas::Message::MapType &);
00067     
00073     Mercator::TerrainMod* getModifier();
00074 
00075     TerrainModTranslator();
00076     
00077 protected:
00078 
00079     static float parsePosition(const WFMath::Point<3> & pos, const Atlas::Message::MapType& modElement);
00080 
00081     template <template <int> class Shape>
00082     static bool parseShape(const Atlas::Message::Element& shapeElement,
00083                            const WFMath::Point<3>& pos,
00084                            const WFMath::Quaternion& orientation,
00085                            Shape<2> & shape);
00086 
00087     template <template <template <int> class Shape> class Mod,
00088               template <int> class Shape>
00089     bool createInstance(Shape<2> & shape,
00090                         const WFMath::Point<3>& pos,
00091                         const Atlas::Message::MapType &,
00092                         float,
00093                         float);
00094 
00095     template <template <template <int> class Shape> class Mod,
00096               template <int> class Shape>
00097     bool createInstance(Shape<2> & shape,
00098                         const WFMath::Point<3>& pos,
00099                         const Atlas::Message::MapType &);
00100 
00101     Mercator::TerrainMod * m_mod;
00102 };
00103 
00104 }
00105 
00106 #endif