Spinning Topp Logo BlackTopp Studios
inc
billboardsetproxy.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 _graphicsbillboardsetproxy_h
41 #define _graphicsbillboardsetproxy_h
42 
43 /// @file
44 /// @brief This file contains the declaration for the World proxy wrapping billboard functionality.
45 
47 #include "Graphics/graphicsenumerations.h"
48 #include "colourvalue.h"
49 
50 namespace Ogre
51 {
52  class BillboardSet;
53 }
54 
55 namespace Mezzanine
56 {
57  namespace Graphics
58  {
59  class Billboard;
60  ///////////////////////////////////////////////////////////////////////////////
61  /// @brief This is the proxy class for placing and manipulating a set of 2D billboards in the scene.
62  /// @details
63  ///////////////////////////////////////
65  {
66  public:
67  /// @brief Basic container type for Billboard storage by this class.
68  typedef std::list<Billboard*> BillboardContainer;
69  /// @brief Iterator type for Billboard instances stored by this class.
70  typedef BillboardContainer::iterator BillboardIterator;
71  /// @brief Const Iterator type for Billboard instances stored by this class.
72  typedef BillboardContainer::const_iterator ConstBillboardIterator;
73  protected:
74  /// @internal
75  /// @brief Container storing all of the Billboard instances created by this proxy.
76  BillboardContainer Billboards;
77  /// @internal
78  /// @brief A pointer to the internal BillboardSet this proxy is based on.
79  Ogre::BillboardSet* GraphicsBillboardSet;
80 
81  /// @copydoc WorldProxy::ProtoSerializeImpl(XML::Node&) const
82  virtual void ProtoSerializeImpl(XML::Node& SelfRoot) const;
83  /// @copydoc WorldProxy::ProtoDeSerializeImpl(const XML::Node&)
84  virtual void ProtoDeSerializeImpl(const XML::Node& SelfRoot);
85  /// @internal
86  /// @param InitialPoolSize The number of billboards to reserve space for.
87  /// @brief Creates an internal BillboardSet to be used by the calling instance.
88  virtual void CreateBillboardSet(const UInt32 InitialPoolSize);
89  /// @internal
90  /// @brief Destroys the internal BillboardSet in use by this proxy.
91  virtual void DestroyBillboardSet();
92  public:
93  /// @brief Class constructor.
94  /// @param ID The unique ID assigned to this BillboardSetProxy.
95  /// @param InitialPoolSize The number of billboards to reserve space for.
96  /// @param Creator A pointer to the manager that created this proxy.
97  BillboardSetProxy(const UInt32 ID, const UInt32 InitialPoolSize, SceneManager* Creator);
98  /// @brief XML constructor.
99  /// @param SelfRoot An XML::Node containing the data to populate this class with.
100  /// @param Creator A pointer to the manager that created this proxy.
101  BillboardSetProxy(const XML::Node& SelfRoot, SceneManager* Creator);
102  /// @brief Class destructor.
103  virtual ~BillboardSetProxy();
104 
105  ///////////////////////////////////////////////////////////////////////////////
106  // Utility
107 
108  /// @copydoc WorldProxy::GetProxyType() const
109  virtual Mezzanine::ProxyType GetProxyType() const;
110 
111  ///////////////////////////////////////////////////////////////////////////////
112  // Billboard Management
113 
114  /// @brief Creates a new Billboard for this set.
115  /// @note In most situations you will want the colour to stay white. The material will still render normally without modification if it is left white.
116  /// @param Location The position relative to the center of the set where this billboard will be placed.
117  /// @param Colour The base colour to give to the created billboard.
118  /// @return Returns a pointer to the created billboard, or NULL if this set has reached it's max billboards and autoextend is disabled.
119  virtual Billboard* CreateBillboard(const Vector3& Location, const ColourValue& Colour = ColourValue::White());
120  /// @brief Gets a Billboard instance by index.
121  /// @param Index The index of the Billboard to be retrieved.
122  /// @return Returns a pointer to the Billboard at the specified index.
123  virtual Billboard* GetBillboard(UInt32 Index);
124  /// @brief Gets the number of Billboard instances in this set.
125  /// @return Returns a UInt32 representing the number of Billboard instances contained in this set.
126  virtual UInt32 GetNumBillboards() const;
127  /// @brief Deletes a Billboard.
128  /// @param ToBeDestroyed A pointer to the Billboard you want deleted.
129  virtual void DestroyBillboard(Billboard* ToBeDestroyed);
130  /// @brief Deletes all stored Billboard instances.
131  virtual void DestroyAllBillboards();
132 
133  ///////////////////////////////////////////////////////////////////////////////
134  // BillboardSet Properties
135 
136  /// @brief Sets whether or not this BillboardSetProxy will increase the size of it's billboard pool automatically when it's limit is reached.
137  /// @param AutoExtend A Boole indicating whether or not this proxy is allowed to resize it's own billboard pool.
138  virtual void SetAutoExtend(const Boole AutoExtend);
139  /// @brief Gets whether or not this BillboardSetProxy will increase the size of it's billboard pool automatically when it's limit is reached.
140  /// @return Returns true if the billboard pool will automatically be resized when it reaches it's limit, false otherwise.
141  virtual Boole GetAutoExtend() const;
142  /// @brief Sets whether direction vectors will be calculated using a more expensive but more accurate algorithm.
143  /// @param AccFace True to increase accuracy of billboard directions, false for the more efficient method.
144  virtual void SetAccurateFacing(const Boole AccFace);
145  /// @brief Gets whether direction vectors are being calculated using a more expensive but more accurate algorithm.
146  /// @return Returns true if this BillboardSetProxy is using the more accurate and more expensive method for directional vectors, false otherwise.
147  virtual Boole GetAccurateFacing() const;
148  /// @brief Sets a new size of the billboard pool in this set.
149  /// @param Size The size the billboard pool in this set should be resized to.
150  virtual void SetPoolSize(const UInt32 Size);
151  /// @brief Gets the current size of the billboard pool in this set.
152  /// @return Returns a UInt32 representing the current size of the billboard pool in this set.
153  virtual UInt32 GetPoolSize() const;
154 
155  /// @brief Sets the part of the billboard that will be treated as the origin for all children of this set.
156  /// @param Origin A BillboardOrigin enum value expressing which part of the billboard will be considered the origin for all billboards in this set.
157  virtual void SetBillboardOrigin(const Graphics::BillboardOrigin Origin);
158  /// @brief Gets the part of the billboard that is currently being treated as the origin for all children of this set.
159  /// @return Returns a BillboardOrigin enum value expressing which part of the billboard is being treated as the origin.
160  virtual Graphics::BillboardOrigin GetBillboardOrigin() const;
161  /// @brief Sets the type of rotation to apply when a rotation is made to a billboard.
162  /// @param Rotation A BillboardRotation enum value expressing the underlying method for rotation in billboards belonging to this set.
163  virtual void SetBillboardRotation(const Graphics::BillboardRotation Rotation);
164  /// @brief Gets the type of rotation to apply when a rotation is made to a billboard.
165  /// @return Returns a BillboardRotation enum value expressing how billboards in this set are to be rotated.
166  virtual Graphics::BillboardRotation GetBillboardRotation() const;
167  /// @brief Sets the type of BillboardSetProxy this is.
168  /// @param Type A BillboardType enum value expressing how billboards in this set are to be oriented.
169  virtual void SetBillboardType(const Graphics::BillboardType Type);
170  /// @brief Gets the type of BillboardSetProxy this is.
171  /// @return Returns a BillboardType enum value expressing how billboards in this set are being oriented.
172  virtual Graphics::BillboardType GetBillboardType() const;
173 
174  /// @brief Sets the default width and height all billboards in this set are to be configured with when constructed.
175  /// @param Width The default width in world units.
176  /// @param Height The default height in world units.
177  virtual void SetDefaultDimensions(const Real Width, const Real Height);
178  /// @brief Sets the default width all billboards in this set are to be configured with when constructed.
179  /// @param Width The default width in world units.
180  virtual void SetDefaultWidth(const Real Width);
181  /// @brief Gets the default width all billboards in this set are constructed with.
182  /// @return Returns a Real representing the default width of all billboards in this set in world units.
183  virtual Real GetDefaultWidth() const;
184  /// @brief Sets the default height all billboards in this set are to be configured with when constructed.
185  /// @param Height The default height in world units.
186  virtual void SetDefaultHeight(const Real Height);
187  /// @brief Gets the default height all billboards in this set are constructed with.
188  /// @return Returns a Real representing the default height of all billboards in this set in world units.
189  virtual Real GetDefaultHeight() const;
190 
191  /// @brief Sets the common facing direction for all billboards in this set.
192  /// @remarks This only needs to be set if this billboard type is set to "BBT_Oriented_Common" or "BBT_Perpendicular_Common".
193  /// @param Dir The facing axis for all billboards in this set.
194  virtual void SetCommonDirection(const Vector3& Dir);
195  /// @brief Gets the common facing direction for all billboards in this set.
196  /// @return Returns a Vector3 representing the forward axis of billboards in this set.
197  virtual Vector3 GetCommonDirection() const;
198  /// @brief Sets the common up direction for all billboards in this set.
199  /// @remarks This only needs to be set if this billboard type is set to "BBT_Perpendicular_Common" or "BBT_Perpendicular_Self".
200  /// @param UpDir The up axis for all billboards in this set.
201  virtual void SetCommonUpVector(const Vector3& UpDir);
202  /// @brief Gets the common up direction for all billboards in this set.
203  /// @return Returns a Vector3 representing the up axis of billboards in this set.
204  virtual Vector3 GetCommonUpVector() const;
205 
206  /// @brief Sets a material for this set by name.
207  /// @todo These by-name methods should be removed when we have a working material wrapper.
208  /// @param MatName The name of the material to apply.
209  virtual void SetMaterialName(const String& MatName);
210  /// @brief Gets the name of the material being used by this set.
211  /// @todo These by-name methods should be removed when we have a working material wrapper.
212  /// @return Returns a string containing the name of the material being used to render this BillboardSetProxy.
213  virtual String GetMaterialName() const;
214 
215  ///////////////////////////////////////////////////////////////////////////////
216  // Serialization
217 
218  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
219  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
220  /// @brief Convert the Billboards of this class to an XML::Node ready for serialization.
221  /// @param SelfRoot The root node containing all the serialized data for this instance.
222  virtual void ProtoSerializeBillboards(XML::Node& SelfRoot) const;
223 
224  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
225  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
226  /// @brief Take the data stored in an XML Node and overwrite the Billboards of this object with it.
227  /// @param SelfRoot An XML::Node containing the data to populate this class with.
228  virtual void ProtoDeSerializeBillboards(const XML::Node& SelfRoot);
229 
230  /// @copydoc WorldProxy::GetDerivedSerializableName() const
231  virtual String GetDerivedSerializableName() const;
232  /// @copydoc WorldProxy::GetSerializableName()
233  static String GetSerializableName();
234 
235  ///////////////////////////////////////////////////////////////////////////////
236  // Internal Methods
237 
238  /// @internal
239  /// @brief Accessor for the internal billboard set.
240  /// @return Returns a pointer to the internal billboard set this proxy is based on.
241  virtual Ogre::BillboardSet* _GetGraphicsObject() const;
242  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
243  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
244  };//BillboardSetProxy
245  }//Graphics
246 }//Mezzanine
247 
248 #endif
BillboardContainer::const_iterator ConstBillboardIterator
Const Iterator type for Billboard instances stored by this class.
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Definition: scenemanager.h:85
This is the proxy class for placing and manipulating a set of 2D billboards in the scene...
Definition: billboard.h:62
std::list< Billboard * > BillboardContainer
Basic container type for Billboard storage by this class.
This file contains the declaration for the base class from which graphics proxies inherit...
static ColourValue White()
Creates a ColourValue representing the colour White.
BillboardContainer::iterator BillboardIterator
Iterator type for Billboard instances stored by this class.
Ogre::BillboardSet * GraphicsBillboardSet
A pointer to the internal BillboardSet this proxy is based on.
This is the base proxy class for world proxies wrapping functionality of the graphics subsystem...
BillboardContainer Billboards
Container storing all of the Billboard instances created by this proxy.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
This is the proxy class for placing and manipulating a set of 2D billboards in the scene...
BillboardOrigin
This is used by the BillboardSetProxy to describe which part of the billboard will be treated as the ...
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
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
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
BillboardType
This is used by BillboardSetProxies to describe how the billboards are to be oriented.
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159
BillboardRotation
This is used by the BillboardSetProxy to decide how billboards should be rotated when they are reques...