MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lightproxy.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 _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 Creator A pointer to the manager that created this proxy.
79  LightProxy(SceneManager* Creator);
80  /// @brief Type constructor.
81  /// @remarks The type provided here can be changed later.
82  /// @param Type The type of light this light is to be constructed as.
83  /// @param Creator A pointer to the manager that created this proxy.
84  LightProxy(const Graphics::LightType Type, SceneManager* Creator);
85  /// @brief XML constructor.
86  /// @param SelfRoot An XML::Node containing the data to populate this class with.
87  /// @param Creator A pointer to the manager that created this proxy.
88  LightProxy(const XML::Node& SelfRoot, SceneManager* Creator);
89  /// @brief Class destructor.
90  virtual ~LightProxy();
91 
92  ///////////////////////////////////////////////////////////////////////////////
93  // Utility
94 
95  /// @copydoc WorldProxy::GetProxyType() const
96  virtual Mezzanine::ProxyType GetProxyType() const;
97 
98  /// @brief Sets the direction the light will be emitted from this source.
99  /// @note The direction is not used if this is a point light.
100  /// @param Dir A Vector3 representing the direction the light will travel from this source.
101  virtual void SetDirection(const Vector3& Dir);
102  /// @brief Gets the direction the light from this source is being emitted.
103  /// @note The direction is not used if this is a point light.
104  /// @return Returns a Vector3 representing the direction this proxy is emitting light.
105  virtual Vector3 GetDirection() const;
106 
107  ///////////////////////////////////////////////////////////////////////////////
108  // Light Properties
109 
110  /// @brief Sets the colour for the Diffuse light from this source.
111  /// @param Diffuse ColourValue representing the color of the Diffuse light to be set.
112  virtual void SetDiffuseColour(const ColourValue& Diffuse);
113  /// @brief Gets the current colour of Diffuse light being emitted by this proxy.
114  /// @return Returns a colourvalue representing the currently set Diffuse light colour.
115  virtual ColourValue GetDiffuseColour() const;
116  /// @brief Sets the colour for the Specular light from this source.
117  /// @param Specular ColourValue representing the color of the Specular light to be set.
118  virtual void SetSpecularColour(const ColourValue& Specular);
119  /// @brief Gets the current colour of Specular light being emitted by this proxy.
120  /// @return Returns a colourvalue representing the currently set Specular light colour.
121  virtual ColourValue GetSpecularColour() const;
122 
123  /// @brief Sets the type of light this light is.
124  /// @param Type The enum value representing the type of light this will become.
125  virtual void SetType(const Graphics::LightType Type);
126  /// @brief Gets the type of light that this light is.
127  /// @return Returns an enum value representing this lights type.
128  virtual Graphics::LightType GetType() const;
129  /// @brief Sets the factors for the attenuation formula applied to this light.
130  /// @param Range The absolute range of the light in world units. Objects beyond this range will not be influenced by this light.
131  /// @param Constant The constant of the attenuation, ranging from 0.0 to 1.0. 1.0 means never attenuate, 0.0 is complete attenuation.
132  /// @param Linear The linear factor of the attentuation, ranging from 0.0 to 1.0. 1.0 means attenuate evenly over the distance.
133  /// @param Quadratic The Quadratic factor of the attenuation. This value adds curvature to the attenuation.
134  virtual void SetAttenuation(const Real Range, const Real Constant, const Real Linear, const Real Quadratic);
135  /// @brief Gets the absolute range of attenuation in world units.
136  /// @return Returns a real representing the absolute range of attenuation.
137  virtual Real GetAttenuationRange() const;
138  /// @brief Gets the constant factor of the attenuation.
139  /// @return Returns a real representing the constant factor of attenuation.
140  virtual Real GetAttenuationConstant() const;
141  /// @brief Gets the linear factor of the attentuation.
142  /// @return Returns a real representing the linear factor of attenuation.
143  virtual Real GetAttenuationLinear() const;
144  /// @brief Gets the quadric factor of the attenuation.
145  /// @return Returns a real representing the quadric factor of attenuation.
146  virtual Real GetAttenuationQuadratic() const;
147  /// @brief Sets the power scale of this light, which indicates it's relative power.
148  /// @note The power scale is useful when accessed by shaders in HDR rendering.
149  /// @param Scale The power scale to set for this light.
150  virtual void SetPowerScale(const Real Scale);
151  /// @brief Gets the power scale of this light, which indicates it's relative power.
152  /// @note The power scale is useful when accessed by shaders in HDR rendering.
153  /// @return Returns a Real representing this lights current power scale.
154  virtual Real GetPowerScale() const;
155 
156  /// @brief Defines the cone of light emitted by a spotlight.
157  /// @note These values are only used if this lights type is set to "Spotlight".
158  /// @remarks InnerAngle and OuterAngle should be input as Radians.
159  /// @param InnerAngle Angle of the inner cone in radians.
160  /// @param OuterAngle Angle of the outer cone in radions.
161  /// @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.
162  virtual void SetSpotlightRange(const Real InnerAngle, const Real OuterAngle, const Real Falloff = 1.0);
163  /// @brief Sets the Inner angle of the cone of light emitted by a spotlight.
164  /// @note These values are only used if this lights type is set to "Spotlight".
165  /// @param Angle The angle of the inner cone in radians.
166  virtual void SetSpotlightInnerAngle(const Real Angle);
167  /// @brief Gets the Inner angle of the cone of light emitted by this spotlight.
168  /// @note These values are only used if this lights type is set to "Spotlight".
169  /// @return Returns a real representing the inner angle of this spotlight, in radians.
170  virtual Real GetSpotlightInnerAngle() const;
171  /// @brief Sets the Outer angle of the cone of light emitted by a spotlight.
172  /// @note These values are only used if this lights type is set to "Spotlight".
173  /// @param Angle The angle of the outer cone in radians.
174  virtual void SetSpotlightOuterAngle(const Real Angle);
175  /// @brief Gets the Outer angle of the cone of light emitted by this spotlight.
176  /// @note These values are only used if this lights type is set to "Spotlight".
177  /// @return Returns a real representing the outer angle of this spotlight, in radians.
178  virtual Real GetSpotlightOuterAngle() const;
179  /// @brief Sets the rate of falloff of the cone of light emitted by a spotlight.
180  /// @note These values are only used if this lights type is set to "Spotlight".
181  /// @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.
182  virtual void SetSpotlightFalloff(const Real Falloff);
183  /// @brief Gets the rate of falloff of the cone of light emitted by this spotlight.
184  /// @note These values are only used if this lights type is set to "Spotlight".
185  /// @return Returns a real representing the falloff of the cone of light.
186  virtual Real GetSpotlightFalloff() const;
187  /// @brief Sets the near clip plane distance to be used by spotlights that use light clipping.
188  /// @param NearClip A Real representing the near clip distance used by spotlights.
189  virtual void SetSpotlightNearClipDistance(const Real NearClip);
190  /// @brief Gets the near clip plane distance to be used by spotlights that use light clipping.
191  /// @return Returns the near clip distance used by spotlights.
192  virtual Real GetSpotlightNearClipDistance() const;
193 
194  ///////////////////////////////////////////////////////////////////////////////
195  // Serialization
196 
197  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node& SelfRoot) const
198  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
199  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node& SelfRoot)
200  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
201 
202  /// @copydoc WorldProxy::GetDerivedSerializableName() const
203  virtual String GetDerivedSerializableName() const;
204  /// @copydoc WorldProxy::GetSerializableName()
205  static String GetSerializableName();
206 
207  ///////////////////////////////////////////////////////////////////////////////
208  // Internal Methods
209 
210  /// @internal
211  /// @brief Accessor for the internal light.
212  /// @return Returns a pointer to the internal light this proxy is based on.
213  virtual Ogre::Light* _GetGraphicsObject() const;
214  /// @copydoc RenderableProxy::_GetBaseGraphicsObject() const
215  virtual Ogre::MovableObject* _GetBaseGraphicsObject() const;
216  };//LightProxy
217  }//Graphics
218 }//Mezzanine
219 
220 #endif