MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
entityproxy.h
Go to the documentation of this file.
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 _graphicsentityproxy_h
41 #define _graphicsentityproxy_h
42 
43 /// @file
44 /// @brief This file contains the declaration for the World proxy wrapping basic entity(mesh) functionality.
45 
47 
48 namespace Ogre
49 {
50  class Entity;
51 }
52 
53 namespace Mezzanine
54 {
55  namespace Graphics
56  {
57  class Mesh;
58  ///////////////////////////////////////////////////////////////////////////////
59  /// @brief This is the proxy class for placing and manipulating a mesh in the scene.
60  /// @details
61  ///////////////////////////////////////
63  {
64  protected:
65  // We want to be able to preserve all our settings and set a mesh seemlessly, but the underlying implementation doesn't support that.
66  // So we need a cache of all the settings we can access. Our base class already handles two such settings, so we can skip those.
67 
68  /// @internal
69  /// @brief A pointer to the internal Entity this proxy is based on.
70  Ogre::Entity* GraphicsEntity;
71  /// @internal
72  /// @brief A pointer to the mesh being used by this proxy.
74 
75  /// @internal
76  /// @brief Stores the maximum distance this object can be from the camera before it is clipped/culled.
78  /// @internal
79  /// @brief A bitmask which will be compared against to determine which lights apply to this object.
81  /// @internal
82  /// @brief Stores whether or not this object should be rendered, regardless of other criteria.
83  Boolean SceneVisible;
84  /// @internal
85  /// @brief Stores whether or not this object can cast shadows on other objects.
86  Boolean CanCastShadows;
87 
88  /// @internal
89  /// @brief Creates an internal entity based on the provided mesh.
90  /// @param ObjectMesh A pointer to the mesh to be applied to this proxy.
91  virtual void CreateEntity(Mesh* ObjectMesh);
92  /// @internal
93  /// @brief Creates an internal entity based on the provided mesh.
94  /// @param MeshName The name of the mesh to be loaded and applied to this proxy.
95  /// @param GroupName The resource group name where the mesh can be found.
96  virtual void CreateEntity(const String& MeshName, const String& GroupName);
97  /// @internal
98  /// @brief Destroys the internal entity in use by this proxy.
99  virtual void DestroyEntity();
100  public:
101  /// @brief Blank constructor.
102  /// @param Creator A pointer to the manager that created this proxy.
103  EntityProxy(SceneManager* Creator);
104  /// @brief Loaded Mesh constructor.
105  /// @param TheMesh A pointer to the mesh to be applied to this proxy.
106  /// @param Creator A pointer to the manager that created this proxy.
107  EntityProxy(Mesh* TheMesh, SceneManager* Creator);
108  /// @brief Standard constructor.
109  /// @param MeshName The name of the mesh to be loaded and applied to this proxy.
110  /// @param GroupName The resource group name where the mesh can be found.
111  /// @param Creator A pointer to the manager that created this proxy.
112  EntityProxy(const String& MeshName, const String& GroupName, SceneManager* Creator);
113  /// @brief XML constructor.
114  /// @param SelfRoot An XML::Node containing the data to populate this class with.
115  /// @param Creator A pointer to the manager that created this proxy.
116  EntityProxy(const XML::Node& SelfRoot, SceneManager* Creator);
117  /// @brief Class destructor.
118  virtual ~EntityProxy();
119 
120  /// @todo Create sub-entity access methods on this class.
121  /// @todo Create minor material manipulation methods on this class.
122  /// @todo Create Animation state and Skeleton access methods on this class.
123 
124  ///////////////////////////////////////////////////////////////////////////////
125  // Utility
126 
127  /// @copydoc WorldProxy::GetProxyType() const
128  virtual Mezzanine::ProxyType GetProxyType() const;
129 
130  /// @copydoc WorldProxy::AddToWorld()
131  virtual void AddToWorld();
132  /// @copydoc WorldProxy::RemoveFromWorld()
133  virtual void RemoveFromWorld();
134 
135  ///////////////////////////////////////////////////////////////////////////////
136  // Mesh Management
137 
138  /// @brief Sets the mesh to be used by this proxy.
139  /// @param MeshName The name of the mesh to apply to this proxy.
140  /// @param Group The resource group to which the mesh belongs.
141  virtual void SetMesh(const String& MeshName, const String& Group);
142  /// @brief Sets the mesh to be used by this proxy.
143  /// @param ObjectMesh The mesh to apply to this proxy.
144  virtual void SetMesh(Mesh* ObjectMesh);
145  /// @brief Gets the mesh currently being used by this proxy.
146  /// @return Returns a pointer to the mesh currently being used by this proxy.
147  virtual Mesh* GetMesh() const;
148 
149  ///////////////////////////////////////////////////////////////////////////////
150  // RenderableProxy Properties
151 
152  /// @copydoc RenderableProxy::SetVisible(const Bool)
153  virtual void SetVisible(const Boolean Visible);
154  /// @copydoc RenderableProxy::GetVisible() const
155  virtual Boolean GetVisible() const;
156  /// @copydoc RenderableProxy::SetCastShadows(const Bool)
157  virtual void SetCastShadows(const Boolean CastShadows);
158  /// @copydoc RenderableProxy::GetCastShadows() const
159  virtual Boolean GetCastShadows() const;
160  /// @copydoc RenderableProxy::GetReceiveShadows() const
161  virtual Boolean GetReceiveShadows() const;
162 
163  /// @copydoc RenderableProxy::SetLightMask(const UInt32)
164  virtual void SetLightMask(const UInt32 Mask);
165  /// @copydoc RenderableProxy::GetLightMask() const
166  virtual UInt32 GetLightMask() const;
167  /// @copydoc RenderableProxy::SetVisibilityMask(const UInt32)
168  virtual void SetVisibilityMask(const UInt32 Mask);
169  /// @copydoc RenderableProxy::GetVisibilityMask() const
170  virtual UInt32 GetVisibilityMask() const;
171  /// @copydoc RenderableProxy::SetQueryMask(const UInt32)
172  virtual void SetQueryMask(const UInt32 Mask);
173  /// @copydoc RenderableProxy::GetQueryMask() const
174  virtual UInt32 GetQueryMask() const;
175 
176  /// @copydoc RenderableProxy::SetRenderDistance(const Real)
177  virtual void SetRenderDistance(const Real Distance);
178  /// @copydoc RenderableProxy::GetRenderDistance() const
179  virtual Real GetRenderDistance() const;
180 
181  ///////////////////////////////////////////////////////////////////////////////
182  // Entity Properties
183 
184  ///////////////////////////////////////////////////////////////////////////////
185  // Serialization
186 
187  /// @copydoc WorldProxy::ProtoSerialize(XML::Node&) const
188  virtual void ProtoSerialize(XML::Node& ParentNode) const;
189  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
190  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
191  /// @brief Convert the mesh of this class to an XML::Node ready for serialization.
192  /// @param SelfRoot The root node containing all the serialized data for this instance.
193  virtual void ProtoSerializeMesh(XML::Node& SelfRoot) const;
194 
195  /// @copydoc WorldProxy::ProtoDeSerialize(const XML::Node&)
196  virtual void ProtoDeSerialize(const XML::Node& SelfRoot);
197  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
198  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
199  /// @brief Take the data stored in an XML Node and overwrite the mesh of this object with it.
200  /// @param SelfRoot An XML::Node containing the data to populate this class with.
201  virtual void ProtoDeSerializeMesh(const XML::Node& SelfRoot);
202 
203  /// @copydoc WorldProxy::GetDerivedSerializableName() const
204  virtual String GetDerivedSerializableName() const;
205  /// @copydoc WorldProxy::GetSerializableName()
206  static String GetSerializableName();
207 
208  ///////////////////////////////////////////////////////////////////////////////
209  // Internal Methods
210 
211  /// @internal
212  /// @brief Accessor for the internal entity.
213  /// @return Returns a pointer to the internal entity this proxy is based on.
214  virtual Ogre::Entity* _GetGraphicsObject() const;
215  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
216  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
217  };//EntityProxy
218  }//Graphics
219 }//Mezzanine
220 
221 #endif