Spinning Topp Logo BlackTopp Studios
inc
viewport.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 _graphicsviewport_h
41 #define _graphicsviewport_h
42 
43 #include "vector2.h"
44 #include "enumerations.h"
45 
46 namespace Ogre
47 {
48  class Viewport;
49 }
50 
51 namespace Mezzanine
52 {
53  namespace Graphics
54  {
55  class GameWindow;
56  class CameraProxy;
57  ///////////////////////////////////////////////////////////////////////////////
58  /// @class Viewport
59  /// @headerfile viewport.h
60  /// @brief This class is for creating and managing viewports within a game window.
61  /// @details A game window can contain several veiwports, and veiwports can overlap. This is
62  /// useful for editors mostly, but can be of use in games as well. Be careful about positioning
63  /// Veiwports in a game window.
64  ///////////////////////////////////////
66  {
67  protected:
68  /// @internal
69  /// @brief A pointer to the internal viewport providing this classes functionality.
70  Ogre::Viewport* OgreViewport;
71  /// @internal
72  /// @brief A pointer to the window that created this viewport.
74  /// @internal
75  /// @brief A pointer to the camera being used to render this viewport, or NULL if one isn't set.
77  public:
78  /// @brief Class constructor.
79  /// @param ViewportCamera The CameraProxy that is to be attached to this veiwport.
80  /// @param ZOrder The render order of this viewport relative to other viewports in the game window.
81  /// @param ParentWindow The game window this viewport belongs to.
82  Viewport(CameraProxy* ViewportCamera, const Integer& ZOrder, GameWindow* ParentWindow);
83  /// @brief XML constructor.
84  /// @param XMLNode The node of the xml document to construct from.
85  /// @param ParentWindow The game window this viewport belongs to.
86  Viewport(const XML::Node& XMLNode, GameWindow* ParentWindow);
87  /// @brief Class destructor.
88  ~Viewport();
89 
90  ///////////////////////////////////////////////////////////////////////////////
91  // Camera and parent Management
92 
93  /// @brief Sets which CameraProxy is bound to this viewport.
94  /// @param ViewportCamera Pointer to the CameraProxy to be bount to this viewport, or NULL to simply unbind a CameraProxy.
95  void SetCamera(CameraProxy* ViewportCamera);
96  /// @brief Gets the CameraProxy associated with this viewport.
97  /// @return Returns a pointer to the CameraProxy using this viewport.
98  CameraProxy* GetCamera() const;
99  /// @brief Gets the game window this viewport belongs to.
100  /// @return Returns a pointer to the game window that created this viewport.
101  GameWindow* GetParentWindow() const;
102 
103  ///////////////////////////////////////////////////////////////////////////////
104  // Utility
105 
106  /// @brief Gets the Zorder assigned to this viewport.
107  /// @return Returns an integer that represents this viewports rendering order in it's parent GameWindow.
108  Integer GetZOrder() const;
109  /// @brief Gets the current Orientation of the viewport.
110  /// @return Returns an enum representing the current orientation of the viewport.
111  Mezzanine::OrientationMode GetOrientationMode() const;
112 
113  ///////////////////////////////////////////////////////////////////////////////
114  // Viewport Metrics Management
115 
116  /// @brief Sets the position and size of this viewport within the game window.
117  /// @param Position Vector2 of relative values(range: 0-1) representing the top left corner of the viewport.
118  /// Values are relative to the game window this viewport belongs to.
119  /// @param Size Vector2 of relative values(range: 0-1) representing the width and height of the viewport.
120  /// Values are relative to the game window this viewport belongs to.
121  void SetDimensions(const Vector2& Position, const Vector2& Size);
122  /// @brief Sets the position and size of this viewport within the game window.
123  /// @param Left A relative value(range: 0-1) representing the leftmost position of the viewport.
124  /// @param Top A relative value(range: 0-1) representing the topmost position of the viewport.
125  /// @param Width A relative value(range: 0-1) representing the width of the viewport.
126  /// @param Height A relative value(range: 0-1) representing the height of the viewport.
127  void SetDimensions(const Real& Left, const Real& Top, const Real& Width, const Real& Height);
128 
129  /// @brief Gets the position of this viewport in it's parent GameWindow in relative units.
130  /// @return Returns a Vector2 containing the relative position of this viewport within the GameWindow.
131  Vector2 GetPosition() const;
132  /// @brief Gets the size of this viewport relative to it's parent GameWindow.
133  /// @return Returns a Vector2 containing the relative size of this viewport.
134  Vector2 GetSize() const;
135 
136  /// @brief Gets the relative left position of the viewport.
137  /// @return Returns a real representing the relative left position of this veiwport.
138  Real GetLeft() const;
139  /// @brief Gets the relative top position of the viewport.
140  /// @return Returns a real representing the relative top position of this veiwport.
141  Real GetTop() const;
142  /// @brief Gets the relative width of the viewport.
143  /// @return Returns a real representing the relative width of this veiwport.
144  Real GetWidth() const;
145  /// @brief Gets the relative height of the viewport.
146  /// @return Returns a real representing the relative height of this veiwport.
147  Real GetHeight() const;
148 
149  /// @brief Gets the position of this viewport in it's parent GameWindow in pixels.
150  /// @return Returns a Vector2 containing the pixel position of this viewport within the GameWindow.
151  Vector2 GetActualPosition() const;
152  /// @brief Gets the size of this viewport in pixels.
153  /// @return Returns a Vector2 containing the pixel size of this viewport.
154  Vector2 GetActualSize() const;
155 
156  /// @brief Gets the left position of the viewport in pixels.
157  /// @return Returns a whole representing the left position of this veiwport in pixels.
158  Whole GetActualLeft() const;
159  /// @brief Gets the top position of the viewport in pixels.
160  /// @return Returns a whole representing the top position of this veiwport in pixels.
161  Whole GetActualTop() const;
162  /// @brief Gets the width of the viewport in pixels.
163  /// @return Returns a whole representing the width of this veiwport in pixels.
164  Whole GetActualWidth() const;
165  /// @brief Gets the height of the viewport in pixels.
166  /// @return Returns a whole representing the height of this veiwport in pixels.
167  Whole GetActualHeight() const;
168 
169  ///////////////////////////////////////////////////////////////////////////////
170  // Serialization
171 
172  /// @brief Convert this class to an XML::Node ready for serialization.
173  /// @param ParentNode The point in the XML hierarchy that all this Viewport should be appended to.
174  void ProtoSerialize(XML::Node& ParentNode) const;
175  /// @brief Take the data stored in an XML Node and overwrite this object with it.
176  /// @param SelfRoot An XML::Node containing the data to populate this class with.
177  void ProtoDeSerialize(const XML::Node& SelfRoot);
178  /// @brief Get the name of the the XML tag the Renderable class will leave behind as its instances are serialized.
179  /// @return A string containing the name of this class.
180  static String GetSerializableName();
181 
182  ///////////////////////////////////////////////////////////////////////////////
183  // Internal Methods
184 
185  /// @internal
186  /// @brief Gets the internal Ogre Viewport.
187  /// @return Returns a pointer to the Ogre Viewport this class is based on.
188  Ogre::Viewport* _GetOgreViewport() const;
189  };//Viewport
190  }//Graphics
191 }//Mezzanine
192 
193 #endif
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
Any global enumerations shared between multiple classes is to be declared here.
GameWindow * Parent
A pointer to the window that created this viewport.
Definition: viewport.h:73
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
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
CameraProxy * ViewportCam
A pointer to the camera being used to render this viewport, or NULL if one isn't set.
Definition: viewport.h:76
This is the proxy class for placing and manipulating a camera in the scene.
Definition: cameraproxy.h:65
Ogre::Viewport * OgreViewport
A pointer to the internal viewport providing this classes functionality.
Definition: viewport.h:70
#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
OrientationMode
Simple enum for communicating the orientation the UI and Camera have relative to the world it is rend...
Definition: enumerations.h:66
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Definition: datatypes.h:151
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
This class is for creating and managing game windows.
Definition: gamewindow.h:63