Spinning Topp Logo BlackTopp Studios
inc
terrainmanager.h
1 // © Copyright 2010 - 2016 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 "worldmanagerfactory.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 
70  /// @brief A String containing the name of this manager implementation.
71  static const String ImplementationName;
72  /// @brief A ManagerType enum value used to describe the type of interface/functionality this manager provides.
74  protected:
75  /// @internal
76  /// @brief A container of all terrain instances.
77  TerrainContainer Terrains;
78  public:
79  /// @brief Class constructor.
80  TerrainManager(World* Creator);
81  /// @brief XML constructor.
82  /// @param XMLNode The node of the xml document to construct from.
83  TerrainManager(World* Creator, const XML::Node& XMLNode);
84  /// @brief Class destructor.
85  virtual ~TerrainManager();
86 
87  ///////////////////////////////////////////////////////////////////////////////
88  // Managing all terrains
89 
90  /// @brief Retrieves a MeshTerrain from the list of terrains.
91  /// @param index Index of desired terrain in MeshTerrains.
92  /// @return Returns a pointer to the MeshTerrain at the given index.
93  virtual TerrainBase* GetTerrainByIndex(const Whole& Index);
94  /// @brief Retrieves a Meshterrain from the list of terrains.
95  /// @param name The name of the terrain.
96  /// @return Returns a pointer to the named MeshTerrain, or NULL if no MeshTerrain exists with given name.
97  virtual TerrainBase* GetTerrainByName(const String& Name);
98  /// @brief Gets the number of terrains being stored in this manager.
99  /// @return Returns a whole representing the number of terrains in this manager.
100  virtual Whole GetNumTerrains() const;
101  /// @brief Adds a pre-made terrain to the world and the manager.
102  /// @param Terrain The terrain to be added.
103  virtual void AddTerrain(TerrainBase* Terrain);
104  /// @brief Removes a terrain from the world and this manager by index.
105  /// @param Index The index at which to remove the terrain.
106  virtual void RemoveTerrain(const Whole& Index);
107  /// @brief Removes a terrain from the world and this manager.
108  /// @param ToBeRemoved The terrain to be removed.
109  virtual void RemoveTerrain(TerrainBase* ToBeRemoved);
110  /// @brief Removes all terrains currently in this manager from the world and the manager.
111  virtual void RemoveAllTerrains();
112  /// @brief Destroys a terrain and removes it from world.
113  /// @param Index Index of desired terrain in MeshTerrains.
114  virtual void DestroyTerrain(const Whole& Index);
115  /// @brief Destroys a terrain and removes it from world.
116  /// @param Name name of desired terrain in MeshTerrains.
117  virtual void DestroyTerrain(TerrainBase* ToBeDestroyed);
118  /// @brief Removes and deletes all terrains currently in this manager from the world and the manager.
119  virtual void DestroyAllTerrains();
120 
121  ///////////////////////////////////////////////////////////////////////////////
122  // MeshTerrain Management
123 
124  /// @brief Creates a terrain based on a given mesh.
125  /// @details This method creates a terrain object and handles adding it to the world.
126  /// @param InitPosition The location of the terrain.
127  /// @param name The name of the terrain.
128  /// @param file The 3d mesh file that contains the 3d model the actor will use.
129  /// @param group The resource group where the 3d mesh and other related files can be found.
130  /// @return Returns a pointer to the created MeshTerrain object.
131  virtual MeshTerrain* CreateMeshTerrain(const Vector3& InitPosition, const String& name, const String& file, const String& group);
132 
133  ///////////////////////////////////////////////////////////////////////////////
134  // HeightfieldTerrain Management
135 
136  ///////////////////////////////////////////////////////////////////////////////
137  // VectorfieldTerrain Management
138 
139  ///////////////////////////////////////////////////////////////////////////////
140  // VoxelTerrain Management
141 
142  ///////////////////////////////////////////////////////////////////////////////
143  // Utility
144 
145  /// @copydoc WorldManager::Pause(const UInt32)
146  virtual void Pause(const UInt32 PL);
147 
148  /// @copydoc WorldManager::Initialize()
149  virtual void Initialize();
150  /// @copydoc ManagerBase::Deinitialize()
151  virtual void Deinitialize();
152 
153  ///////////////////////////////////////////////////////////////////////////////
154  // Type Identifier Methods
155 
156  /// @copydoc ManagerBase::GetInterfaceType()
157  virtual ManagerType GetInterfaceType() const;
158  /// @copydoc ManagerBase::GetImplementationTypeName()
159  virtual String GetImplementationTypeName() const;
160  };//TerrainManager
161 
162  ///////////////////////////////////////////////////////////////////////////////
163  /// @class DefaultTerrainManagerFactory
164  /// @brief A factory responsible for the creation and destruction of the default terrainmanager.
165  ///////////////////////////////////////
167  {
168  public:
169  /// @brief Class constructor.
171  /// @brief Class destructor.
172  virtual ~DefaultTerrainManagerFactory();
173 
174  /// @copydoc ManagerFactory::GetManagerImplName()
175  String GetManagerImplName() const;
176  /// @copydoc ManagerFactory::GetManagerType() const
177  ManagerBase::ManagerType GetManagerType() const;
178 
179  /// @copydoc WorldManagerFactory::CreateManager(World*, const NameValuePairList&)
180  WorldManager* CreateManager(World* Creator, const NameValuePairList& Params);
181  /// @copydoc WorldManagerFactory::CreateManager(World*, const XML::Node&)
182  WorldManager* CreateManager(World* Creator, const XML::Node& XMLNode);
183  /// @copydoc WorldManagerFactory::DestroyManager(WorldManager*)
184  void DestroyManager(WorldManager* ToBeDestroyed);
185  };//DefaultTerrainManagerFactory
186 }//Mezzanine
187 
188 #endif // _terrainmanager_h
TerrainContainer Terrains
A container of all terrain instances.
ManagerType
A listing of Manager Types.
Definition: managerbase.h:65
static const String ImplementationName
A String containing the name of this manager implementation.
All the definitions for datatypes as well as some basic conversion functions are defined here...
A factory responsible for the creation and destruction of the default terrainmanager.
static const ManagerBase::ManagerType InterfaceType
A ManagerType enum value used to describe the type of interface/functionality this manager provides...
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
This is manager for terrains and their functions.
This is the base class from which all the terrains inherit.
Definition: terrainbase.h:57
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
std::vector< TerrainBase * > TerrainContainer
Basic container type for TerrainBase storage by this class.
TerrainContainer::iterator TerrainIterator
Iterator type for TerrainBase instances stored by this class.
std::list< NameValuePair > NameValuePairList
This is a datatype mostly used for describing settings or parameters that can't be declared in advanc...
Definition: datatypes.h:206
This is the base class for all managers that belong to a single world instance.
Definition: worldmanager.h:55
TerrainContainer::const_iterator ConstTerrainIterator
Const Iterator type for TerrainBase instances stored by this class.
This is used to represent a point in space, or a vector through space.
Definition: vector3.h:77
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
This class represents a world for objects to interact within.
Definition: world.h:74
This is a base class for factories that construct managers used by the World class.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159