OGRE  1.8
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-2013 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 "OgreVector3.h"
35 #include "OgreVector4.h"
36 #include "OgreString.h"
37 #include "OgreMovableObject.h"
38 #include "OgrePlaneBoundedVolume.h"
39 #include "OgreShadowCameraSetup.h"
40 #include "OgreHeaderPrefix.h"
41 
42 namespace Ogre {
43 
44 
74  {
75  public:
79  void _calcTempSquareDist(const Vector3& worldPos);
80 
83  {
85  LT_POINT = 0,
87  LT_DIRECTIONAL = 1,
89  LT_SPOTLIGHT = 2
90  };
91 
94  Light();
95 
98  Light(const String& name);
99 
102  ~Light();
103 
106  void setType(LightTypes type);
107 
110  LightTypes getType(void) const;
111 
121  void setDiffuseColour(Real red, Real green, Real blue);
122 
132  void setDiffuseColour(const ColourValue& colour);
133 
136  const ColourValue& getDiffuseColour(void) const;
137 
147  void setSpecularColour(Real red, Real green, Real blue);
148 
158  void setSpecularColour(const ColourValue& colour);
159 
162  const ColourValue& getSpecularColour(void) const;
163 
183  void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
184 
187  Real getAttenuationRange(void) const;
188 
191  Real getAttenuationConstant(void) const;
192 
195  Real getAttenuationLinear(void) const;
196 
199  Real getAttenuationQuadric(void) const;
200 
207  void setPosition(Real x, Real y, Real z);
208 
215  void setPosition(const Vector3& vec);
216 
221  const Vector3& getPosition(void) const;
222 
229  void setDirection(Real x, Real y, Real z);
230 
237  void setDirection(const Vector3& vec);
238 
243  const Vector3& getDirection(void) const;
244 
255  void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
256 
259  const Radian& getSpotlightInnerAngle(void) const;
260 
263  const Radian& getSpotlightOuterAngle(void) const;
264 
267  Real getSpotlightFalloff(void) const;
268 
271  void setSpotlightInnerAngle(const Radian& val);
272 
275  void setSpotlightOuterAngle(const Radian& val);
276 
279  void setSpotlightFalloff(Real val);
280 
286  void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; }
287 
291  Real getSpotlightNearClipDistance() const { return mSpotNearClip; }
292 
300  void setPowerScale(Real power);
301 
305  Real getPowerScale(void) const;
306 
308  void _notifyAttached(Node* parent, bool isTagPoint = false);
309 
311  void _notifyMoved(void);
312 
314  const AxisAlignedBox& getBoundingBox(void) const;
315 
317  void _updateRenderQueue(RenderQueue* queue);
318 
320  const String& getMovableType(void) const;
321 
325  const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const;
326 
328  const Vector3& getDerivedDirection(void) const;
329 
335  void setVisible(bool visible);
336 
338  Real getBoundingRadius(void) const { return 0; /* not visible */ }
339 
349  Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const;
350 
360  virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const;
361 
368  virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const;
369 
371  uint32 getTypeFlags(void) const;
372 
374  AnimableValuePtr createAnimableValue(const String& valueName);
375 
382  void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup);
383 
387  void resetCustomShadowCameraSetup(void);
388 
390  const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const;
391 
393  void visitRenderables(Renderable::Visitor* visitor,
394  bool debugRenderables = false);
395 
404  size_t _getIndexInFrame() const { return mIndexInFrame; }
405  void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; }
406 
422  void setShadowFarDistance(Real distance);
425  void resetShadowFarDistance(void);
429  Real getShadowFarDistance(void) const;
430  Real getShadowFarDistanceSquared(void) const;
431 
436  void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; }
437 
443  Real getShadowNearClipDistance() const { return mShadowNearClipDist; }
444 
448  Real _deriveShadowNearClipDistance(const Camera* maincam) const;
449 
457  void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; }
458 
464  Real getShadowFarClipDistance() const { return mShadowFarClipDist; }
465 
469  Real _deriveShadowFarClipDistance(const Camera* maincam) const;
470 
472  void _setCameraRelative(Camera* cam);
473 
489  void setCustomParameter(uint16 index, const Vector4& value);
490 
495  const Vector4& getCustomParameter(uint16 index) const;
496 
519  virtual void _updateCustomGpuParameter(uint16 paramIndex,
520  const GpuProgramParameters::AutoConstantEntry& constantEntry,
521  GpuProgramParameters* params) const;
522  protected:
524  virtual void update(void) const;
525 
527  const String& getAnimableDictionaryName(void) const;
529  void initialiseAnimableDictionary(StringVector& vec) const;
530 
535 
537 
551 
554 
555 
558  // Slightly hacky but unless we separate observed light render state from main Light...
562 
565 
570 
573 
577  };
578 
581  {
582  protected:
583  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
584  public:
587 
589 
590  const String& getType(void) const;
591  void destroyInstance( MovableObject* obj);
592 
593  };
597 } // Namespace
598 
599 #include "OgreHeaderPrefix.h"
600 
601 #endif
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
bool mDerivedTransformDirty
Is the derived transform dirty?
Definition: OgreLight.h:569
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:270
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:464
#define _OgreExport
Definition: OgrePlatform.h:233
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:553
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:436
Real mShadowFarDistSquared
Definition: OgreLight.h:550
Class representing colour.
Vector3 mDirection
Definition: OgreLight.h:536
LightTypes
Defines the type of light.
Definition: OgreLight.h:82
A 3D box aligned with the x/y/z axes.
Camera * mCameraToBeRelativeTo
Definition: OgreLight.h:561
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:457
Real mAttenuationConst
Definition: OgreLight.h:543
Vector3 mPosition
Definition: OgreLight.h:532
bool mOwnShadowFarDist
Definition: OgreLight.h:548
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.
bool mDerivedCamRelativeDirty
Definition: OgreLight.h:560
size_t _getIndexInFrame() const
Gets the index at which this light is in the current render.
Definition: OgreLight.h:404
static String FACTORY_TYPE_NAME
Definition: OgreLight.h:588
Real mAttenuationQuad
Definition: OgreLight.h:545
Abstract class defining a movable object in a scene.
Vector3 mDerivedPosition
Definition: OgreLight.h:556
Real mRange
Definition: OgreLight.h:542
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Structure recording the use of an automatic parameter.
ColourValue mDiffuse
Definition: OgreLight.h:533
PlaneBoundedVolumeList mFrustumClipVolumes
Definition: OgreLight.h:567
Real mSpotFalloff
Definition: OgreLight.h:540
ColourValue mSpecular
Definition: OgreLight.h:534
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:443
void _notifyIndexInFrame(size_t i)
Definition: OgreLight.h:405
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreLight.h:564
Real mShadowFarClipDist
Definition: OgreLight.h:553
ShadowCameraSetupPtr mCustomShadowCameraSetup
Pointer to a custom shadow camera setup.
Definition: OgreLight.h:572
Collects together the program parameters used for a GpuProgram.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
vector< String >::type StringVector
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
PlaneBoundedVolume mNearClipVolume
Definition: OgreLight.h:566
Represents a convex volume bounded by planes.
Real mSpotNearClip
Definition: OgreLight.h:541
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:286
Real mAttenuationLinear
Definition: OgreLight.h:544
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:46
Real mShadowNearClipDist
Definition: OgreLight.h:552
Class to manage the scene object rendering queue.
size_t mIndexInFrame
Definition: OgreLight.h:547
_StringBase String
Vector3 mDerivedCamRelativePosition
Definition: OgreLight.h:559
Real mPowerScale
Definition: OgreLight.h:546
Vector3 mDerivedDirection
Definition: OgreLight.h:557
unsigned short uint16
Definition: OgrePlatform.h:271
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Real mShadowFarDist
Definition: OgreLight.h:549
Real tempSquareDist
Temp tag used for sorting.
Definition: OgreLight.h:77
map< uint16, Vector4 >::type CustomParameterMap
Definition: OgreLight.h:574
Real getBoundingRadius(void) const
Overridden from MovableObject.
Definition: OgreLight.h:338
Real getSpotlightNearClipDistance() const
Get the near clip plane distance to be used by spotlights that use light clipping.
Definition: OgreLight.h:291
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:63
Radian mSpotInner
Definition: OgreLight.h:539
CustomParameterMap mCustomParameters
Stores the custom parameters for the light.
Definition: OgreLight.h:576
Factory object for creating Light instances.
Definition: OgreLight.h:580
Radian mSpotOuter
Definition: OgreLight.h:538
LightTypes mLightType
Definition: OgreLight.h:531