OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreLight.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __LIGHT_H__
29 #define __LIGHT_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreColourValue.h"
34 #include "OgreVector4.h"
35 #include "OgreMovableObject.h"
36 #include "OgrePlaneBoundedVolume.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre {
40 
41 
71  {
72  public:
76  void _calcTempSquareDist(const Vector3& worldPos);
77 
80  {
82  LT_POINT = 0,
84  LT_DIRECTIONAL = 1,
86  LT_SPOTLIGHT = 2
87  };
88 
91  Light( IdType id, ObjectMemoryManager *objectMemoryManager );
92 
95  ~Light();
96 
99  void setType(LightTypes type);
100 
103  LightTypes getType(void) const { return mLightType; }
104 
106  void setSpotAabb(void);
107 
117  inline void setDiffuseColour(Real red, Real green, Real blue);
118 
128  inline void setDiffuseColour(const ColourValue& colour);
129 
132  const ColourValue& getDiffuseColour(void) const { return mDiffuse; }
133 
143  inline void setSpecularColour(Real red, Real green, Real blue);
144 
154  inline void setSpecularColour(const ColourValue& colour);
155 
158  const ColourValue& getSpecularColour(void) const { return mSpecular; }
159 
185  void setAttenuationBasedOnRadius(Real radius, Real lumThreshold);
186 
206  void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
207 
210  Real getAttenuationRange(void) const { return mRange; }
211 
214  Real getAttenuationConstant(void) const { return mAttenuationConst; }
215 
218  Real getAttenuationLinear(void) const { return mAttenuationLinear; }
219 
222  Real getAttenuationQuadric(void) const { return mAttenuationQuad; }
223 
230  void setDirection(const Vector3& vec);
231 
237  Vector3 getDirection(void) const;
238 
251  void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
252 
255  const Radian& getSpotlightInnerAngle(void) const { return mSpotInner; }
256 
259  const Radian& getSpotlightOuterAngle(void) const { return mSpotOuter; }
260 
263  Real getSpotlightFalloff(void) const { return mSpotFalloff; }
264 
267  void setSpotlightInnerAngle(const Radian& val);
268 
271  void setSpotlightOuterAngle(const Radian& val);
272 
275  inline void setSpotlightFalloff(Real val);
276 
283  void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; }
284 
288  Real getSpotlightNearClipDistance() const { return mSpotNearClip; }
289 
298  void setPowerScale(Real power);
299 
303  Real getPowerScale(void) const { return mPowerScale; }
304 
306  virtual void _updateRenderQueue(RenderQueue* queue, Camera *camera, const Camera *lodCamera) {}
307 
309  const String& getMovableType(void) const;
310 
312  Vector3 getDerivedDirection(void) const;
313  Vector3 getDerivedDirectionUpdated(void) const;
314 
320  //void setVisible(bool visible);
321 
330  Vector4 getAs4DVector(void) const;
331 
333  uint32 getTypeFlags(void) const;
334 
336  AnimableValuePtr createAnimableValue(const String& valueName);
337 
339  virtual void visitRenderables(Renderable::Visitor* visitor,
340  bool debugRenderables = false) {}
341 
357  void setShadowFarDistance(Real distance);
360  void resetShadowFarDistance(void);
364  Real getShadowFarDistance(void) const;
365  Real getShadowFarDistanceSquared(void) const;
366 
372  void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; }
373 
380  Real getShadowNearClipDistance() const { return mShadowNearClipDist; }
381 
385  Real _deriveShadowNearClipDistance(const Camera* maincam) const;
386 
396  void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; }
397 
404  Real getShadowFarClipDistance() const { return mShadowFarClipDist; }
405 
409  Real _deriveShadowFarClipDistance(const Camera* maincam) const;
410 
428  void setCustomParameter(uint16 index, const Vector4& value);
429 
434  const Vector4& getCustomParameter(uint16 index) const;
435 
461  virtual void _updateCustomGpuParameter(uint16 paramIndex,
462  const GpuProgramParameters::AutoConstantEntry& constantEntry,
463  GpuProgramParameters* params) const;
464 
470  bool isInLightRange(const Ogre::Sphere& sphere) const;
471 
477  bool isInLightRange(const Ogre::AxisAlignedBox& container) const;
478 
479  protected:
480 
484 
497 
500 
503 
507  };
508 
511  {
512  protected:
513  virtual MovableObject* createInstanceImpl( IdType id, ObjectMemoryManager *objectMemoryManager,
514  const NameValuePairList* params = 0 );
515  public:
518 
520 
521  const String& getType(void) const;
522  void destroyInstance(MovableObject* obj);
523 
524  };
528 } // namespace Ogre
529 
530 #include "OgreLight.inl"
531 
532 #include "OgreHeaderPrefix.h"
533 
534 #endif // __LIGHT_H__
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:420
Real getShadowFarClipDistance() const
Get the far clip plane distance to be used by the shadow camera, if this light casts texture shadows...
Definition: OgreLight.h:404
Real getAttenuationLinear(void) const
Returns the linear factor in the attenuation formula.
Definition: OgreLight.h:218
#define _OgreExport
Definition: OgrePlatform.h:255
Real getAttenuationRange(void) const
Returns the absolute upper range of the light.
Definition: OgreLight.h:210
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:580
const ColourValue & getDiffuseColour(void) const
Returns the colour of the diffuse light given off by this light source (see setDiffuseColour for more...
Definition: OgreLight.h:132
void setShadowNearClipDistance(Real nearClip)
Set the near clip plane distance to be used by the shadow camera, if this light casts texture shadows...
Definition: OgreLight.h:372
Real mShadowFarDistSquared
Definition: OgreLight.h:496
Class representing colour.
LightTypes
Defines the type of light.
Definition: OgreLight.h:79
Real getPowerScale(void) const
Set the scaling factor which indicates the relative power of a light.
Definition: OgreLight.h:303
A 3D box aligned with the x/y/z axes.
Real getSpotlightFalloff(void) const
Returns the falloff between the inner and outer cones of the spotlight.
Definition: OgreLight.h:263
void setShadowFarClipDistance(Real farClip)
Set the far clip plane distance to be used by the shadow camera, if this light casts texture shadows...
Definition: OgreLight.h:396
Real mAttenuationConst
Definition: OgreLight.h:490
bool mOwnShadowFarDist
Definition: OgreLight.h:494
Interface definition for a factory class which produces a certain kind of MovableObject, and can be registered with Root in order to allow all clients to produce new instances of this object, integrated with the standard Ogre processing.
Wrap-around class that contains multiple ArrayMemoryManager, one per render queue.
static String FACTORY_TYPE_NAME
Definition: OgreLight.h:519
Real mAttenuationQuad
Definition: OgreLight.h:492
Abstract class defining a movable object in a scene.
Real mRange
Definition: OgreLight.h:489
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:70
Structure recording the use of an automatic parameter.
ColourValue mDiffuse
Definition: OgreLight.h:482
Real mSpotFalloff
Definition: OgreLight.h:487
ColourValue mSpecular
Definition: OgreLight.h:483
Real getShadowNearClipDistance() const
Get the near clip plane distance to be used by the shadow camera, if this light casts texture shadows...
Definition: OgreLight.h:380
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreLight.h:502
Real mShadowFarClipDist
Definition: OgreLight.h:499
Ogre::uint32 IdType
Big projects with lots, lots of units for very long periods of time (MMORPGs?) may want to define thi...
Definition: OgreId.h:36
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Collects together the program parameters used for a GpuProgram.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
virtual void _updateRenderQueue(RenderQueue *queue, Camera *camera, const Camera *lodCamera)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
Definition: OgreLight.h:306
const Radian & getSpotlightInnerAngle(void) const
Returns the angle covered by the spotlights inner cone.
Definition: OgreLight.h:255
Real mSpotNearClip
Definition: OgreLight.h:488
LightTypes getType(void) const
Returns the light type.
Definition: OgreLight.h:103
void setSpotlightNearClipDistance(Real nearClip)
Set the near clip plane distance to be used by spotlights that use light clipping, allowing you to render spots as if they start from further down their frustum.
Definition: OgreLight.h:283
Real mAttenuationLinear
Definition: OgreLight.h:491
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:49
Real mShadowNearClipDist
Definition: OgreLight.h:498
Class to manage the scene object rendering queue.
Real getAttenuationQuadric(void) const
Returns the quadric factor in the attenuation formula.
Definition: OgreLight.h:222
_StringBase String
Definition: OgreCommon.h:53
Real getAttenuationConstant(void) const
Returns the constant factor in the attenuation formula.
Definition: OgreLight.h:214
Real mPowerScale
Definition: OgreLight.h:493
unsigned short uint16
Definition: OgrePlatform.h:421
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Real mShadowFarDist
Definition: OgreLight.h:495
const ColourValue & getSpecularColour(void) const
Returns the colour of specular light given off by this light source.
Definition: OgreLight.h:158
Real tempSquareDist
Temp tag used for sorting.
Definition: OgreLight.h:74
map< uint16, Vector4 >::type CustomParameterMap
Definition: OgreLight.h:504
Real getSpotlightNearClipDistance() const
Get the near clip plane distance to be used by spotlights that use light clipping.
Definition: OgreLight.h:288
virtual void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
Definition: OgreLight.h:339
Radian mSpotInner
Definition: OgreLight.h:486
const Radian & getSpotlightOuterAngle(void) const
Returns the angle covered by the spotlights outer cone.
Definition: OgreLight.h:259
CustomParameterMap mCustomParameters
Stores the custom parameters for the light.
Definition: OgreLight.h:506
Factory object for creating Light instances.
Definition: OgreLight.h:510
Radian mSpotOuter
Definition: OgreLight.h:485
LightTypes mLightType
Definition: OgreLight.h:481