Spinning Topp Logo BlackTopp Studios
inc
cameraproxy.h
Go to the documentation of this file.
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 _graphicscameraproxy_h
41 #define _graphicscameraproxy_h
42 
43 /// @file
44 /// @brief This file contains the declaration for the World proxy wrapping camera functionality.
45 
47 #include "Graphics/graphicsenumerations.h"
48 #include "colourvalue.h"
49 #include "ray.h"
50 
51 namespace Ogre
52 {
53  class Camera;
54 }
55 
56 namespace Mezzanine
57 {
58  namespace Graphics
59  {
60  class Viewport;
61  ///////////////////////////////////////////////////////////////////////////////
62  /// @brief This is the proxy class for placing and manipulating a camera in the scene.
63  /// @details
64  ///////////////////////////////////////
66  {
67  protected:
68  friend class Viewport;
69 
70  /// @internal
71  /// @brief A vector3 representing the fixed axis on which this camera will always Yaw/rotate.
73  /// @internal
74  /// @brief A pointer to the internal Camera this proxy is based on.
75  Ogre::Camera* GraphicsCamera;
76  /// @internal
77  /// @brief This is a pointer to the Viewport this camera is attached to, if any.
79  /// @internal
80  /// @brief A Boole storing whether or not the FixedYawAxis is being used.
82 
83  /// @internal
84  /// @brief Creates an internal Camera to be used by the calling instance.
85  virtual void CreateCamera();
86  /// @internal
87  /// @brief Destroys the internal Camera in use by this proxy.
88  virtual void DestroyCamera();
89  /// @internal
90  /// @brief Generates a name for this Camera to placate the internal system.
91  /// @note This will no longer be necessary in after the switch to Ogre 2.0.
92  /// @return Returns a string containing the auto-generated name of this Camera.
93  static String GenerateName();
94  public:
95  /// @brief Class constructor.
96  /// @param ID The unique ID assigned to this CameraProxy.
97  /// @param Creator A pointer to the manager that created this proxy.
98  CameraProxy(const UInt32 ID, SceneManager* Creator);
99  /// @brief XML constructor.
100  /// @param SelfRoot An XML::Node containing the data to populate this class with.
101  /// @param Creator A pointer to the manager that created this proxy.
102  CameraProxy(const XML::Node& SelfRoot, SceneManager* Creator);
103  /// @brief Class destructor.
104  virtual ~CameraProxy();
105 
106  /// @todo Wrap LOD related methods (Camera/Bias).
107  /// @todo Wrap reflection methods?
108 
109  ///////////////////////////////////////////////////////////////////////////////
110  // Utility
111 
112  /// @copydoc WorldProxy::GetProxyType() const
113  virtual Mezzanine::ProxyType GetProxyType() const;
114  /// @brief Gets the Viewport this camera is attached to, if any.
115  /// @return Returns a pointer to the Viewport this camera is rendering to, or NULL if not attached.
116  virtual Viewport* GetViewport() const;
117 
118  /// @brief Gets whether this cameras Yaw rotation is based on a fixed axis.
119  /// @return Returns true if a fixed Yaw axis is enabled and in use, false otherwise.
120  virtual Boole IsFixedYawEnabled() const;
121 
122  /// @brief Sets the direction the camera faces based on a 3D point.
123  /// @param TargetLoc The location in the world to look at.
124  virtual void LookAt(const Vector3& TargetLoc);
125  /// @brief Moves the camera through local space.
126  /// @param ToMove The local space vector to move the camera by.
127  virtual void MoveRelative(const Vector3& ToMove);
128  /// @brief Sets the direction the light will be emitted from this source.
129  /// @note The direction is not used if this is a point light.
130  /// @param Dir A Vector3 representing the direction the light will travel from this source.
131  virtual void SetDirection(const Vector3& Dir);
132  /// @brief Gets the direction the light from this source is being emitted.
133  /// @note The direction is not used if this is a point light.
134  /// @return Returns a Vector3 representing the direction this proxy is emitting light.
135  virtual Vector3 GetDirection() const;
136 
137  /// @brief Gets a Ray from the camera to the viewport.
138  /// @param ScreenX A Real representing the relative location on screen, on the x axis(0.0 - 1.0).
139  /// @param ScreenY A Real representing the relative location on screen, on the y axis(0.0 - 1.0).
140  virtual Ray GetCameraToViewportRay(const Real ScreenX, const Real ScreenY) const;
141 
142  ///////////////////////////////////////////////////////////////////////////////
143  // Camera Properties
144 
145  /// @brief Sets the debug rendering mode for this camera.
146  /// @param PolyMode A CameraPolyMode enum value expressing the mode to be set.
147  virtual void SetPolygonMode(const Graphics::CameraPolyMode PolyMode);
148  /// @brief Gets the debug rendering mode for this camera.
149  /// @return Returns a CameraPolyMode enum value representing the current mode of this camera.
150  virtual Graphics::CameraPolyMode GetPolygonMode() const;
151  /// @brief Sets the type of projection to be used with this camera.
152  /// @remarks By default, all cameras are enabled with Perspective projection. This is the standard 3-dimentional
153  /// view anyone would expect in a 3D world. Orthographic projection is useful when displaying 2D worlds, or only
154  /// 2 dimentions of a 3D world. It enables you to see the entire side of an object without regard for camera perspective.
155  /// Perspective can be thought of as a pyramid, with the camera at the top of the cone. Orthographic would instead be a cube.
156  /// @param ProjType A ProjectionType enum value that expresses the type of projection to be used.
157  virtual void SetProjectionType(const Graphics::ProjectionType ProjType);
158  /// @brief Get the type of projection used by the camera.
159  /// @return A ProjectionType enum value that will identify the kind of projection this camera uses.
160  virtual Graphics::ProjectionType GetProjectionType() const;
161  /// @brief Sets the orientation mode of this cameras frustrum.
162  /// @param OriMode An OrientationMode enum value that expresses the type of orientation this cameras frustrum will use.
163  virtual void SetOrientationMode(const Graphics::OrientationMode OriMode);
164  /// @brief Gets the orientation mode of this cameras frustrum.
165  /// @return An OrientationMode enum value that will identify the kind of orientation this cameras frustrum uses.
166  virtual Graphics::OrientationMode GetOrientationMode() const;
167 
168  /// @brief Defines the size of the Orthographic projection window in world units.
169  /// @remarks This function can change the aspect ratio of the screen, determined by the values passed in. To set the
170  /// window size without changing the aspect ratio, call either the SetOrthoWindowHeight, or SetOrthoWindowWidth functions.
171  /// @param Width The new width of the projection window.
172  /// @param Height The new height of the projection window.
173  virtual void SetOrthoWindow(const Real Width, const Real Height);
174  /// @brief Defines the size of the Orthographic projection window in world units.
175  /// @remarks This function will not change the aspect ratio of the screen, unlike SetOrthoWindow. The aspect ratio will be
176  /// preserved and the Height of the screen automatically recalculated based on the Width passed in.
177  /// @param Width The new width of the projection window.
178  virtual void SetOrthoWindowWidth(const Real Width);
179  /// @brief Gets the current width of the Orthographic projection window in world units.
180  /// @return Returns a Real represnting the world unit width of the projection window when Orthographic projection is enabled.
181  virtual Real GetOrthoWindowWidth() const;
182  /// @brief Defines the size of the Orthographic projection window in world units.
183  /// @remarks This function will not change the aspect ratio of the screen, unlike SetOrthoWindow. The aspect ratio will be
184  /// preserved and the Width of the screen automatically recalculated based on the Height passed in.
185  /// @param Height The new height of the projection window.
186  virtual void SetOrthoWindowHeight(const Real Height);
187  /// @brief Gets the current height of the Orthographic projection window in world units.
188  /// @return Returns a Real represnting the world unit height of the projection window when Orthographic projection is enabled.
189  virtual Real GetOrthoWindowHeight() const;
190 
191  /// @brief Sets the distance in world units at which objects are considered too close to render.
192  /// @param NearDist A Real representing the distance.
193  virtual void SetNearClipDistance(const Real NearDist);
194  /// @brief Gets the distance in world units at which objects are considered too close to render.
195  /// @return Returns a Real representing the distance from the camera to the near clipping plane.
196  virtual Real GetNearClipDistance() const;
197  /// @brief Sets the distance in world units at which objects are considered too far to render.
198  /// @param FarDist A Real representing the distance.
199  virtual void SetFarClipDistance(const Real FarDist);
200  /// @brief Gets the distance in world units at which objects are considered too far to render.
201  /// @return Returns a Real representing the distance from the camera to the far clipping plane.
202  virtual Real GetFarClipDistance() const;
203 
204  /// @brief Sets the vertical field of view of the camera frustrum.
205  /// @remarks Higher values (90+ degrees, 1.57079633+ radians) result in wide-angle, fish-eye views. Low values (30- degrees, 0.523598776- radians)
206  /// result in telescopic views. Normal values are between 45 degrees(0.785398163 radians) and 60 degrees(1.04719755 radians).
207  /// @param FOV The field of view in radians.
208  virtual void SetFieldOfViewY(const Real FOV);
209  /// @brief Gets the vertical field of view of the camera frustrum.
210  /// @return Returns a Real representing the current vertical field of view of this camera in radians.
211  virtual Real GetFieldOfViewY() const;
212 
213  /// @brief Sets the aspect ratio of the cameras veiw.
214  /// @param Ratio A Real that represents the camera frustrum viewport aspect ratio, where Ratio = width / height.
215  virtual void SetAspectRatio(const Real Ratio);
216  /// @brief Gets the aspect ratio of the cameras veiw.
217  /// @return Returns a Real representing the aspect ratio for the camera frustrum viewport.
218  virtual Real GetAspectRatio() const;
219 
220  /// @brief Sets whether or not to lock rotation around the Y axis.
221  /// @remarks This function is automatically called on by the camera constructor.
222  /// @param UseFixed Enable or disable the locking of the axis.
223  /// @param Axis The axis to lock, defaults to the Y axis.
224  virtual void SetFixedYawAxis(const Boole UseFixed, const Vector3& Axis = Vector3::Unit_Y());
225  /// @brief If fixed yaw is enabled, on which axis is yawing disabled.
226  /// @return Returns a Vector3 of 0s if disable, otherwise this return the Fixed Yaw Axis.
227  virtual Vector3 GetFixedYawAxis() const;
228 
229  ///////////////////////////////////////////////////////////////////////////////
230  // Serialization
231 
232  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
233  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
234  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
235  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
236 
237  /// @copydoc WorldProxy::GetDerivedSerializableName() const
238  virtual String GetDerivedSerializableName() const;
239  /// @copydoc WorldProxy::GetSerializableName()
240  static String GetSerializableName();
241 
242  ///////////////////////////////////////////////////////////////////////////////
243  // Internal Methods
244 
245  /// @internal
246  /// @brief Accessor for the internal camera.
247  /// @return Returns a pointer to the internal camera this proxy is based on.
248  virtual Ogre::Camera* _GetGraphicsObject() const;
249  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
250  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
251  };// CameraProxy
252  }//Graphics
253 }//Mezzanine
254 
255 #endif
Ogre::Camera * GraphicsCamera
A pointer to the internal Camera this proxy is based on.
Definition: cameraproxy.h:75
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
ProjectionType
Values for storing how perspective should be interpretted.
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Definition: scenemanager.h:85
Vector3 FixedYawAxis
A vector3 representing the fixed axis on which this camera will always Yaw/rotate.
Definition: cameraproxy.h:72
This file contains the declaration for the base class from which graphics proxies inherit...
This is the base proxy class for world proxies wrapping functionality of the graphics subsystem...
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
This class is for creating and managing viewports within a game window.
Definition: viewport.h:65
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
ProxyType
Used by all World proxies to describe what their derived types are.
Definition: enumerations.h:91
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
static Vector3 Unit_Y()
Gets a vector representing the Y unit of a Vector3.
Definition: vector3.cpp:134
Boole UseFixedYaw
A Boole storing whether or not the FixedYawAxis is being used.
Definition: cameraproxy.h:81
This is the proxy class for placing and manipulating a camera in the scene.
Definition: cameraproxy.h:65
Viewport * CameraVP
This is a pointer to the Viewport this camera is attached to, if any.
Definition: cameraproxy.h:78
CameraPolyMode
This is used by CameraProxies to quickly set a different render mode that is useful for debugging gra...
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
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This represents a line placed in 3D space and is used with spacial queries.
Definition: ray.h:67
OrientationMode
This is used by CameraProxies to determine the orientation of the camera frustrum.