MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
terrainmanager.h
1 // © Copyright 2010 - 2014 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _terrainmanager_h
42 #define _terrainmanager_h
43 
44 #include "datatypes.h"
45 #include "vector3.h"
46 #include "worldmanager.h"
47 #include "managerfactory.h"
48 
49 namespace Mezzanine
50 {
51  class MeshTerrain;
52  class TerrainBase;
53 
54  ///////////////////////////////////////////////////////////////////////////////
55  /// @class TerrainManager
56  /// @headerfile terrainmanager.h
57  /// @brief This is manager for terrains and their functions.
58  /// @details
59  ///////////////////////////////////////
61  {
62  public:
63  /// @brief Basic container type for @ref TerrainBase storage by this class.
64  typedef std::vector< TerrainBase* > TerrainContainer;
65  /// @brief Iterator type for @ref TerrainBase instances stored by this class.
66  typedef TerrainContainer::iterator TerrainIterator;
67  /// @brief Const Iterator type for @ref TerrainBase instances stored by this class.
68  typedef TerrainContainer::const_iterator ConstTerrainIterator;
69  protected:
70  /// @brief A container of all terrain instances.
72  public:
73  /// @brief Class constructor.
75  /// @brief XML constructor.
76  /// @param XMLNode The node of the xml document to construct from.
77  TerrainManager(XML::Node& XMLNode);
78  /// @brief Class destructor.
79  virtual ~TerrainManager();
80 
81  ///////////////////////////////////////////////////////////////////////////////
82  // Managing all terrains
83 
84  /// @brief Retrieves a MeshTerrain from the list of terrains.
85  /// @param index Index of desired terrain in MeshTerrains.
86  /// @return Returns a pointer to the MeshTerrain at the given index.
87  virtual TerrainBase* GetTerrainByIndex(const Whole& Index);
88  /// @brief Retrieves a Meshterrain from the list of terrains.
89  /// @param name The name of the terrain.
90  /// @return Returns a pointer to the named MeshTerrain, or NULL if no MeshTerrain exists with given name.
91  virtual TerrainBase* GetTerrainByName(const String& Name);
92  /// @brief Gets the number of terrains being stored in this manager.
93  /// @return Returns a whole representing the number of terrains in this manager.
94  virtual Whole GetNumTerrains() const;
95  /// @brief Adds a pre-made terrain to the world and the manager.
96  /// @param Terrain The terrain to be added.
97  virtual void AddTerrain(TerrainBase* Terrain);
98  /// @brief Removes a terrain from the world and this manager by index.
99  /// @param Index The index at which to remove the terrain.
100  virtual void RemoveTerrain(const Whole& Index);
101  /// @brief Removes a terrain from the world and this manager.
102  /// @param ToBeRemoved The terrain to be removed.
103  virtual void RemoveTerrain(TerrainBase* ToBeRemoved);
104  /// @brief Removes all terrains currently in this manager from the world and the manager.
105  virtual void RemoveAllTerrains();
106  /// @brief Destroys a terrain and removes it from world.
107  /// @param Index Index of desired terrain in MeshTerrains.
108  virtual void DestroyTerrain(const Whole& Index);
109  /// @brief Destroys a terrain and removes it from world.
110  /// @param Name name of desired terrain in MeshTerrains.
111  virtual void DestroyTerrain(TerrainBase* ToBeDestroyed);
112  /// @brief Removes and deletes all terrains currently in this manager from the world and the manager.
113  virtual void DestroyAllTerrains();
114 
115  ///////////////////////////////////////////////////////////////////////////////
116  // MeshTerrain Management
117 
118  /// @brief Creates a terrain based on a given mesh.
119  /// @details This method creates a terrain object and handles adding it to the world.
120  /// @param InitPosition The location of the terrain.
121  /// @param name The name of the terrain.
122  /// @param file The 3d mesh file that contains the 3d model the actor will use.
123  /// @param group The resource group where the 3d mesh and other related files can be found.
124  /// @return Returns a pointer to the created MeshTerrain object.
125  virtual MeshTerrain* CreateMeshTerrain(const Vector3& InitPosition, const String& name, const String& file, const String& group);
126 
127  ///////////////////////////////////////////////////////////////////////////////
128  // HeightfieldTerrain Management
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // VectorfieldTerrain Management
132 
133  ///////////////////////////////////////////////////////////////////////////////
134  // VoxelTerrain Management
135 
136  ///////////////////////////////////////////////////////////////////////////////
137  // Utility
138 
139  /// @copydoc WorldManager::Pause(const UInt32)
140  virtual void Pause(const UInt32 PL);
141 
142  /// @copydoc WorldManager::Initialize()
143  virtual void Initialize();
144  /// @copydoc ManagerBase::Deinitialize()
145  virtual void Deinitialize();
146 
147  ///////////////////////////////////////////////////////////////////////////////
148  // Type Identifier Methods
149 
150  /// @copydoc ManagerBase::GetInterfaceType()
151  virtual ManagerType GetInterfaceType() const;
152  /// @copydoc ManagerBase::GetImplementationTypeName()
153  virtual String GetImplementationTypeName() const;
154  };//TerrainManager
155 
156  ///////////////////////////////////////////////////////////////////////////////
157  /// @class DefaultTerrainManagerFactory
158  /// @headerfile terrainmanager.h
159  /// @brief A factory responsible for the creation and destruction of the default terrainmanager.
160  ///////////////////////////////////////
162  {
163  public:
164  /// @brief Class constructor.
166  /// @brief Class destructor.
167  virtual ~DefaultTerrainManagerFactory();
168 
169  /// @copydoc ManagerFactory::GetManagerTypeName()
170  String GetManagerTypeName() const;
171 
172  /// @copydoc ManagerFactory::CreateManager(NameValuePairList&)
173  ManagerBase* CreateManager(NameValuePairList& Params);
174  /// @copydoc ManagerFactory::CreateManager(XML::Node&)
175  ManagerBase* CreateManager(XML::Node& XMLNode);
176  /// @copydoc ManagerFactory::DestroyManager(ManagerBase*)
177  void DestroyManager(ManagerBase* ToBeDestroyed);
178  };//DefaultTerrainManagerFactory
179 }//Mezzanine
180 
181 #endif // _terrainmanager_h