Spinning Topp Logo BlackTopp Studios
inc
meshmanager.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 #ifndef _graphicsmeshmanager_h
41 #define _graphicsmeshmanager_h
42 
43 #include "vector3.h"
44 #include "colourvalue.h"
45 #include "entresolmanager.h"
46 #include "entresolmanagerfactory.h"
47 #include "singleton.h"
48 
49 namespace Ogre
50 {
51  class Mesh;
52  template<typename T> class SharedPtr;
53  typedef SharedPtr<Mesh> MeshPtr;
54  class MeshManager;
55 }
56 
57 namespace Mezzanine
58 {
59  namespace Physics
60  {
61  class CollisionShape;
62  }
63  namespace Graphics
64  {
65  class Mesh;
66  // Used by the scripting language binder to help create bindgings for this class. SWIG does know to creation template instances
67  #ifdef SWIG
68  %template(SingletonMeshManager) Singleton<MeshManager>;
69  #endif
70 
71  ///////////////////////////////////////////////////////////////////////////////
72  /// @class MeshManager
73  /// @brief This manager handles the storage, generation, and query of of Graphics Meshes.
74  /// @details
75  ///////////////////////////////////////
77  {
78  public:
79  /// @brief Basic container type for Mesh storage in this class.
80  typedef std::map< String, Mesh* > MeshContainer;
81  /// @brief Iterator type for Mesh instances stored in this class.
82  typedef MeshContainer::iterator MeshIterator;
83  /// @brief Const Iterator type for Mesh instances stored in this class.
84  typedef MeshContainer::const_iterator ConstMeshIterator;
85 
86  /// @brief A String containing the name of this manager implementation.
87  static const String ImplementationName;
88  /// @brief A ManagerType enum value used to describe the type of interface/functionality this manager provides.
90  protected:
91  /// @internal
92  /// @brief Container storing all of the currently loaded Meshes.
93  MeshContainer Meshes;
94 
95  /// @internal
96  /// @brief Adds a Mesh to this manager.
97  /// @exception If the name of the Mesh being added is not unique a II_DUPLICATE_IDENTITY_EXCEPTION will be thrown.
98  /// @param ToAdd The Mesh to be added.
99  virtual void AddMesh(Mesh* ToAdd);
100  public:
101  /// @brief Class constructor.
102  MeshManager();
103  /// @brief XML constructor.
104  /// @param XMLNode The node of the xml document to construct from.
105  MeshManager(const XML::Node& XMLNode);
106  /// @brief Class destructor.
107  virtual ~MeshManager();
108 
109  ///////////////////////////////////////////////////////////////////////////////
110  // Mesh Management
111 
112  /// @brief Loads a Mesh file from an asset group and prepares it for use.
113  /// @param ResourceName The name of the Mesh file to be loaded.
114  /// @param ResourceGroup The resource group from which the Mesh file should be loaded.
115  /// @return Returns a pointer to the loaded Mesh.
116  Mesh* LoadMesh(const String& ResourceName, const String& ResourceGroup);
117  /// @brief Loads a Mesh file from disk and prepares it for use.
118  /// @param FilePathAndName The full path and filename of the Mesh to be read.
119  /// @return Returns a pointer to the loaded Mesh.
120  Mesh* LoadMesh(const String& FilePathAndName);
121 
122  /// @brief Loads an Mesh from an input stream.
123  /// @param Stream A pointer to the stream to load the Mesh from.
124  /// @return Returns a pointer to the loaded Mesh.
125  Mesh* LoadMesh(std::istream* Stream);
126 
127  /// @brief Unloads a Mesh from memory.
128  /// @param MeshName The name of the Mesh to be unloaded.
129  void UnloadMesh(const String& MeshName);
130  /// @brief Unloads every Mesh that is currently loaded.
131  void UnloadAllMeshes();
132 
133  /// @brief Writes a Mesh to the asset group.
134  /// @param ToSave The Mesh to be saved.
135  /// @param FileName The name of the file to save the Mesh as.
136  /// @param GroupName The name of the asset group to save the Mesh to.
137  void SaveMesh(Mesh* ToSave, const String& FileName, const String& GroupName);
138  /// @brief Writes a Mesh to the disk.
139  /// @param ToSave The Mesh to be saved.
140  /// @param FilePathAndName The full path and filename of the Mesh to be written.
141  void SaveMesh(Mesh* ToSave, const String& FilePathAndName);
142 
143  /// @brief Writes a Mesh in a final serializable form to an output stream.
144  /// @param ToSave The Mesh to be saved.
145  /// @param Stream A pointer to the stream to save the Mesh to.
146  void SaveMesh(Mesh* ToSave, std::ostream* Stream);
147 
148  /// @brief Gets a Mesh stored in this manager.
149  /// @param MeshName The name of the Mesh to retrieve.
150  /// @return Returns a pointer to the requested Mesh.
151  Mesh* GetMesh(const String& MeshName);
152  /// @brief Gets the number of currently loaded meshes.
153  /// @return Returns a Whole representing the number of meshes currently loaded.
154  Whole GetNumMeshes();
155 
156  ///////////////////////////////////////////////////////////////////////////////
157  // Utility
158 
159  /// @copydoc ManagerBase::Initialize()
160  virtual void Initialize();
161  /// @copydoc ManagerBase::Deinitialize()
162  virtual void Deinitialize();
163 
164  ///////////////////////////////////////////////////////////////////////////////
165  // Type Identifier Methods
166 
167  /// @copydoc ManagerBase::GetInterfaceType()
168  virtual ManagerType GetInterfaceType() const;
169  /// @copydoc ManagerBase::GetImplementationTypeName()
170  virtual String GetImplementationTypeName() const;
171 
172  ///////////////////////////////////////////////////////////////////////////////
173  // Internal Methods
174 
175  /// @internal
176  /// @brief Wraps and stores an Ogre Mesh instance.
177  /// @param ToWrap The Ogre Mesh to get wrapped.
178  /// @return Returns a pointer to the wrapped Mesh.
179  Mesh* _WrapInternalMesh(Ogre::MeshPtr ToWrap);
180  /// @internal
181  /// @brief Gets the internal MeshManager.
182  /// @return Returns a pointer to the internal MeshManager.
183  Ogre::MeshManager* _GetInternalManager() const;
184  };//MeshManager
185 
186  ///////////////////////////////////////////////////////////////////////////////
187  /// @class DefaultMeshManagerFactory
188  /// @brief A factory responsible for the creation and destruction of the default MeshManager.
189  ///////////////////////////////////////
191  {
192  public:
193  /// @brief Class constructor.
195  /// @brief Class destructor.
196  virtual ~DefaultMeshManagerFactory();
197 
198  /// @copydoc ManagerFactory::GetManagerImplName()
199  String GetManagerImplName() const;
200  /// @copydoc ManagerFactory::GetManagerType() const
201  ManagerBase::ManagerType GetManagerType() const;
202 
203  /// @copydoc EntresolManagerFactory::CreateManager(const NameValuePairList&)
204  EntresolManager* CreateManager(const NameValuePairList& Params);
205  /// @copydoc EntresolManagerFactory::CreateManager(const XML::Node&)
206  EntresolManager* CreateManager(const XML::Node& XMLNode);
207  /// @copydoc EntresolManagerFactory::DestroyManager(EntresolManager*)
208  void DestroyManager(EntresolManager* ToBeDestroyed);
209  };//DefaultMeshManagerFactory
210  }//Graphics
211 }//Mezzanine
212 
213 #endif
static const ManagerBase::ManagerType InterfaceType
A ManagerType enum value used to describe the type of interface/functionality this manager provides...
Definition: meshmanager.h:89
ManagerType
A listing of Manager Types.
Definition: managerbase.h:65
This is a base class for factories that construct managers used by the Entresol class.
This class is used to check and modify the properties of a graphics mesh.
Definition: mesh.h:63
A factory responsible for the creation and destruction of the default MeshManager.
Definition: meshmanager.h:190
MeshContainer Meshes
Container storing all of the currently loaded Meshes.
Definition: meshmanager.h:93
static const String ImplementationName
A String containing the name of this manager implementation.
Definition: meshmanager.h:87
MeshContainer::const_iterator ConstMeshIterator
Const Iterator type for Mesh instances stored in this class.
Definition: meshmanager.h:84
This is the base class for all managers that do no describe properties of a single world...
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
MeshContainer::iterator MeshIterator
Iterator type for Mesh instances stored in this class.
Definition: meshmanager.h:82
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
#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 manager handles the storage, generation, and query of of Graphics Meshes.
Definition: meshmanager.h:76
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
std::map< String, Mesh * > MeshContainer
Basic container type for Mesh storage in this class.
Definition: meshmanager.h:80