Spinning Topp Logo BlackTopp Studios
inc
lightproxy.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 _graphicslightproxy_h
41 #define _graphicslightproxy_h
42 
43 /// @file
44 /// @brief This file contains the declaration for the World proxy wrapping light functionality.
45 
47 #include "Graphics/graphicsenumerations.h"
48 #include "colourvalue.h"
49 
50 namespace Ogre
51 {
52  class Light;
53 }
54 
55 namespace Mezzanine
56 {
57  namespace Graphics
58  {
59  ///////////////////////////////////////////////////////////////////////////////
60  /// @brief This is the proxy class for placing and manipulating lighting in the scene.
61  /// @details
62  ///////////////////////////////////////
64  {
65  protected:
66  /// @internal
67  /// @brief A pointer to the internal Light this proxy is based on.
68  Ogre::Light* GraphicsLight;
69 
70  /// @internal
71  /// @brief Creates an internal light to be used by the calling instance.
72  virtual void CreateLight();
73  /// @internal
74  /// @brief Destroys the internal light in use by this proxy.
75  virtual void DestroyLight();
76  public:
77  /// @brief Blank constructor.
78  /// @param ID The unique ID assigned to this LightProxy.
79  /// @param Creator A pointer to the manager that created this proxy.
80  LightProxy(const UInt32 ID, SceneManager* Creator);
81  /// @brief Type constructor.
82  /// @remarks The type provided here can be changed later.
83  /// @param ID The unique ID assigned to this LightProxy.
84  /// @param Type The type of light this light is to be constructed as.
85  /// @param Creator A pointer to the manager that created this proxy.
86  LightProxy(const UInt32 ID, const Graphics::LightType Type, SceneManager* Creator);
87  /// @brief XML constructor.
88  /// @param SelfRoot An XML::Node containing the data to populate this class with.
89  /// @param Creator A pointer to the manager that created this proxy.
90  LightProxy(const XML::Node& SelfRoot, SceneManager* Creator);
91  /// @brief Class destructor.
92  virtual ~LightProxy();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Utility
96 
97  /// @copydoc WorldProxy::GetProxyType() const
98  virtual Mezzanine::ProxyType GetProxyType() const;
99 
100  /// @brief Sets the direction the light will be emitted from this source.
101  /// @note The direction is not used if this is a point light.
102  /// @param Dir A Vector3 representing the direction the light will travel from this source.
103  virtual void SetDirection(const Vector3& Dir);
104  /// @brief Gets the direction the light from this source is being emitted.
105  /// @note The direction is not used if this is a point light.
106  /// @return Returns a Vector3 representing the direction this proxy is emitting light.
107  virtual Vector3 GetDirection() const;
108 
109  ///////////////////////////////////////////////////////////////////////////////
110  // Light Properties
111 
112  /// @brief Sets the colour for the Diffuse light from this source.
113  /// @param Diffuse ColourValue representing the color of the Diffuse light to be set.
114  virtual void SetDiffuseColour(const ColourValue& Diffuse);
115  /// @brief Gets the current colour of Diffuse light being emitted by this proxy.
116  /// @return Returns a colourvalue representing the currently set Diffuse light colour.
117  virtual ColourValue GetDiffuseColour() const;
118  /// @brief Sets the colour for the Specular light from this source.
119  /// @param Specular ColourValue representing the color of the Specular light to be set.
120  virtual void SetSpecularColour(const ColourValue& Specular);
121  /// @brief Gets the current colour of Specular light being emitted by this proxy.
122  /// @return Returns a colourvalue representing the currently set Specular light colour.
123  virtual ColourValue GetSpecularColour() const;
124 
125  /// @brief Sets the type of light this light is.
126  /// @param Type The enum value representing the type of light this will become.
127  virtual void SetType(const Graphics::LightType Type);
128  /// @brief Gets the type of light that this light is.
129  /// @return Returns an enum value representing this lights type.
130  virtual Graphics::LightType GetType() const;
131  /// @brief Sets the factors for the attenuation formula applied to this light.
132  /// @param Range The absolute range of the light in world units. Objects beyond this range will not be influenced by this light.
133  /// @param Constant The constant of the attenuation, ranging from 0.0 to 1.0. 1.0 means never attenuate, 0.0 is complete attenuation.
134  /// @param Linear The linear factor of the attentuation, ranging from 0.0 to 1.0. 1.0 means attenuate evenly over the distance.
135  /// @param Quadratic The Quadratic factor of the attenuation. This value adds curvature to the attenuation.
136  virtual void SetAttenuation(const Real Range, const Real Constant, const Real Linear, const Real Quadratic);
137  /// @brief Gets the absolute range of attenuation in world units.
138  /// @return Returns a real representing the absolute range of attenuation.
139  virtual Real GetAttenuationRange() const;
140  /// @brief Gets the constant factor of the attenuation.
141  /// @return Returns a real representing the constant factor of attenuation.
142  virtual Real GetAttenuationConstant() const;
143  /// @brief Gets the linear factor of the attentuation.
144  /// @return Returns a real representing the linear factor of attenuation.
145  virtual Real GetAttenuationLinear() const;
146  /// @brief Gets the quadric factor of the attenuation.
147  /// @return Returns a real representing the quadric factor of attenuation.
148  virtual Real GetAttenuationQuadratic() const;
149  /// @brief Sets the power scale of this light, which indicates it's relative power.
150  /// @note The power scale is useful when accessed by shaders in HDR rendering.
151  /// @param Scale The power scale to set for this light.
152  virtual void SetPowerScale(const Real Scale);
153  /// @brief Gets the power scale of this light, which indicates it's relative power.
154  /// @note The power scale is useful when accessed by shaders in HDR rendering.
155  /// @return Returns a Real representing this lights current power scale.
156  virtual Real GetPowerScale() const;
157 
158  /// @brief Defines the cone of light emitted by a spotlight.
159  /// @note These values are only used if this lights type is set to "Spotlight".
160  /// @remarks InnerAngle and OuterAngle should be input as Radians.
161  /// @param InnerAngle Angle of the inner cone in radians.
162  /// @param OuterAngle Angle of the outer cone in radions.
163  /// @param Falloff The rate of falloff between the inner and outer cones. 1.0 means linear falloff. Less means slower falloff and higher means faster falloff.
164  virtual void SetSpotlightRange(const Real InnerAngle, const Real OuterAngle, const Real Falloff = 1.0);
165  /// @brief Sets the Inner angle of the cone of light emitted by a spotlight.
166  /// @note These values are only used if this lights type is set to "Spotlight".
167  /// @param Angle The angle of the inner cone in radians.
168  virtual void SetSpotlightInnerAngle(const Real Angle);
169  /// @brief Gets the Inner angle of the cone of light emitted by this spotlight.
170  /// @note These values are only used if this lights type is set to "Spotlight".
171  /// @return Returns a real representing the inner angle of this spotlight, in radians.
172  virtual Real GetSpotlightInnerAngle() const;
173  /// @brief Sets the Outer angle of the cone of light emitted by a spotlight.
174  /// @note These values are only used if this lights type is set to "Spotlight".
175  /// @param Angle The angle of the outer cone in radians.
176  virtual void SetSpotlightOuterAngle(const Real Angle);
177  /// @brief Gets the Outer angle of the cone of light emitted by this spotlight.
178  /// @note These values are only used if this lights type is set to "Spotlight".
179  /// @return Returns a real representing the outer angle of this spotlight, in radians.
180  virtual Real GetSpotlightOuterAngle() const;
181  /// @brief Sets the rate of falloff of the cone of light emitted by a spotlight.
182  /// @note These values are only used if this lights type is set to "Spotlight".
183  /// @param Falloff The rate of falloff between the inner and outer cones. 1.0 means linear falloff. Less means slower falloff and higher means faster falloff.
184  virtual void SetSpotlightFalloff(const Real Falloff);
185  /// @brief Gets the rate of falloff of the cone of light emitted by this spotlight.
186  /// @note These values are only used if this lights type is set to "Spotlight".
187  /// @return Returns a real representing the falloff of the cone of light.
188  virtual Real GetSpotlightFalloff() const;
189  /// @brief Sets the near clip plane distance to be used by spotlights that use light clipping.
190  /// @param NearClip A Real representing the near clip distance used by spotlights.
191  virtual void SetSpotlightNearClipDistance(const Real NearClip);
192  /// @brief Gets the near clip plane distance to be used by spotlights that use light clipping.
193  /// @return Returns the near clip distance used by spotlights.
194  virtual Real GetSpotlightNearClipDistance() const;
195 
196  ///////////////////////////////////////////////////////////////////////////////
197  // Serialization
198 
199  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
200  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
201  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
202  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
203 
204  /// @copydoc WorldProxy::GetDerivedSerializableName() const
205  virtual String GetDerivedSerializableName() const;
206  /// @copydoc WorldProxy::GetSerializableName()
207  static String GetSerializableName();
208 
209  ///////////////////////////////////////////////////////////////////////////////
210  // Internal Methods
211 
212  /// @internal
213  /// @brief Accessor for the internal light.
214  /// @return Returns a pointer to the internal light this proxy is based on.
215  virtual Ogre::Light* _GetGraphicsObject() const;
216  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
217  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
218  };//LightProxy
219  }//Graphics
220 }//Mezzanine
221 
222 #endif
LightType
This is used by LightProxies to describe how light is emitted from the proxy source.
This class contains utilities and functions to allow the manipulation of the Graphical scene...
Definition: scenemanager.h:85
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...
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
Definition: colourvalue.h:64
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
Ogre::Light * GraphicsLight
A pointer to the internal Light this proxy is based on.
Definition: lightproxy.h:68
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
This is the proxy class for placing and manipulating lighting in the scene.
Definition: lightproxy.h:63
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159