MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cameramanager.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 #ifndef _graphicscameramanager_h
41 #define _graphicscameramanager_h
42 
43 #include "datatypes.h"
44 #include "worldmanager.h"
45 #include "managerfactory.h"
46 #include "singleton.h"
47 #include "quaternion.h"
48 #include "ray.h"
49 #include "vector3.h"
50 
51 namespace Ogre
52 {
53  class Camera;
54  class SceneNode;
55  class Viewport;
56 }
57 
58 namespace Mezzanine
59 {
60  class CameraController;
61  namespace Graphics
62  {
63  class CameraProxy;
64  class GraphicsManager;
65  class SceneManager;
66  class SceneManagerData;
67  ///////////////////////////////////////////////////////////////////////////////
68  /// @class CameraManager
69  /// @headerfile cameramanager.h
70  /// @brief This is the manager class for all camera functions.
71  /// @details This class contains all the functionality of the use and manipulation of the camera. @n
72  /// All functions that manipulate the camera will default to the default camera, so if you only use
73  /// one camera you should never have to name the camera you want to use. @n
74  /// This class should only be created after the SceneManager has been created.
75  ///////////////////////////////////////////////////////////////////////////////
77  {
78  public:
79  /// @brief Basic container type for @ref CameraProxy storage by this class.
80  typedef std::vector< CameraProxy* > CameraContainer;
81  /// @brief Iterator type for @ref Camera instances stored by this class.
82  typedef CameraContainer::iterator CameraIterator;
83  /// @brief Const Iterator type for @ref Camera instances stored by this class.
84  typedef CameraContainer::const_iterator ConstCameraIterator;
85  /// @brief Basic container type for @ref CameraController storage by this class.
86  typedef std::map< CameraProxy*, CameraController* > CameraControllerContainer;
87  /// @brief Iterator type for @ref CameraController instances stored by this class.
88  typedef CameraControllerContainer::iterator CameraControllerIterator;
89  /// @brief Const Iterator type for @ref CameraController instances stored by this class.
90  typedef CameraControllerContainer::const_iterator ConstCameraControllerIterator;
91  protected:
92  /// @internal
93  /// @brief Container storing all of the Camera instances created by this manager.
95  /// @internal
96  /// @brief Container storing all of the CameraController instances created by this manager.
98  /// @internal
99  /// @brief Used to reference the appropriate scene
101  public:
102  /// @brief Class Constructor.
103  CameraManager();
104  /// @brief XML constructor.
105  /// @param XMLNode The node of the xml document to construct from.
106  CameraManager(XML::Node& XMLNode);
107  /// @brief Class Destructor.
108  virtual ~CameraManager();
109 
110  ///////////////////////////////////////////////////////////////////////////////
111  // Camera Management
112 
113  /// @brief Creates a camera.
114  /// @remarks This function will autogenerate the name for the camera.
115  /// @return Returns a pointer to the created camera.
116  CameraProxy* CreateCamera();
117  /// @brief Creates a camera.
118  /// @param Name The name to be assigned to the created camera.
119  /// @return Returns a pointer to the created camera.
120  CameraProxy* CreateCamera(const String& Name);
121  /// @brief Gets an already created camera by name.
122  /// @return Returns a pointer to the camera of the specified name.
123  CameraProxy* GetCamera(const String& Name);
124  /// @brief Gets an already created camera by index.
125  /// @return Returns a pointer to the camera at the specified index.
126  CameraProxy* GetCamera(const Whole& Index);
127  /// @brief Gets the number of cameras created and stored in this manager.
128  /// @return Returns the number of cameras this manager is storing.
129  Whole GetNumCameras();
130  /// @brief Destroy's all stored camera's.
131  void DestroyAllCameras();
132 
133  ///////////////////////////////////////////////////////////////////////////////
134  // Camera Controller Management
135 
136  /// @brief Gets a camera controller if it exists, otherwise creates it.
137  /// @param Controlled The camera that will be controlled by the controller returned.
138  /// @return Returns a pointer to the created or retrieved camera controller for the camera.
139  CameraController* GetOrCreateCameraController(CameraProxy* Controlled);
140  /// @brief Destroys a cameracontroller.
141  /// @param ToBeDestroyed Pointer to the cameracontrolled you want destroyed.
142  void DestroyCameraController(CameraController* ToBeDestroyed);
143  /// @brief Destroys a cameracontroller by camera.
144  /// @param ControlledCam The camera who's controller will be destroyed. This doesn't do anything to the camera.
145  void DestroyCameraController(CameraProxy* ControlledCam);
146  /// @brief Destroys all camera controllers being stored in this manager.
147  void DestroyAllCameraControllers();
148 
149  ///////////////////////////////////////////////////////////////////////////////
150  // Utility
151 
152  /// @copydoc WorldManager::Pause(const UInt32)
153  virtual void Pause(const UInt32 PL);
154 
155  /// @copydoc ManagerBase::Initialize()
156  virtual void Initialize();
157  /// @copydoc ManagerBase::Deinitialize()
158  virtual void Deinitialize();
159 
160  /// @brief Gets the SceneManager this Camera Manager is working with.
161  /// @return Returns a pointer to the SceneManager all cameras made with this manager belong to.
162  SceneManager* GetScene() const;
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  };// ©ameraManager
172 
173  ///////////////////////////////////////////////////////////////////////////////
174  /// @class DefaultCameraManagerFactory
175  /// @headerfile cameramanager.h
176  /// @brief A factory responsible for the creation and destruction of the default cameramanager.
177  ///////////////////////////////////////
179  {
180  public:
181  /// @brief Class constructor.
183  /// @brief Class destructor.
184  virtual ~DefaultCameraManagerFactory();
185 
186  /// @copydoc ManagerFactory::GetManagerTypeName()
187  String GetManagerTypeName() const;
188 
189  /// @copydoc ManagerFactory::CreateManager(NameValuePairList&)
190  ManagerBase* CreateManager(NameValuePairList& Params);
191  /// @copydoc ManagerFactory::CreateManager(XML::Node&)
192  ManagerBase* CreateManager(XML::Node& XMLNode);
193  /// @copydoc ManagerFactory::DestroyManager(ManagerBase*)
194  void DestroyManager(ManagerBase* ToBeDestroyed);
195  };//DefaultCameraManagerFactory
196  }//Graphics
197 }//Mezzanine
198 #endif