OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 
41 namespace Ogre {
42 
43 
73  {
74  public:
78  void _calcTempSquareDist(const Vector3& worldPos);
79 
82  {
84  LT_POINT = 0,
86  LT_DIRECTIONAL = 1,
88  LT_SPOTLIGHT = 2
89  };
90 
93  Light();
94 
97  Light(const String& name);
98 
101  ~Light();
102 
105  void setType(LightTypes type);
106 
109  LightTypes getType(void) const;
110 
120  void setDiffuseColour(Real red, Real green, Real blue);
121 
131  void setDiffuseColour(const ColourValue& colour);
132 
135  const ColourValue& getDiffuseColour(void) const;
136 
146  void setSpecularColour(Real red, Real green, Real blue);
147 
157  void setSpecularColour(const ColourValue& colour);
158 
161  const ColourValue& getSpecularColour(void) const;
162 
182  void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
183 
186  Real getAttenuationRange(void) const;
187 
190  Real getAttenuationConstant(void) const;
191 
194  Real getAttenuationLinear(void) const;
195 
198  Real getAttenuationQuadric(void) const;
199 
206  void setPosition(Real x, Real y, Real z);
207 
214  void setPosition(const Vector3& vec);
215 
220  const Vector3& getPosition(void) const;
221 
228  void setDirection(Real x, Real y, Real z);
229 
236  void setDirection(const Vector3& vec);
237 
242  const Vector3& getDirection(void) const;
243 
254  void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
255 
258  const Radian& getSpotlightInnerAngle(void) const;
259 
262  const Radian& getSpotlightOuterAngle(void) const;
263 
266  Real getSpotlightFalloff(void) const;
267 
270  void setSpotlightInnerAngle(const Radian& val);
271 
274  void setSpotlightOuterAngle(const Radian& val);
275 
278  void setSpotlightFalloff(Real val);
279 
287  void setPowerScale(Real power);
288 
292  Real getPowerScale(void) const;
293 
295  void _notifyAttached(Node* parent, bool isTagPoint = false);
296 
298  void _notifyMoved(void);
299 
301  const AxisAlignedBox& getBoundingBox(void) const;
302 
304  void _updateRenderQueue(RenderQueue* queue);
305 
307  const String& getMovableType(void) const;
308 
312  const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const;
313 
315  const Vector3& getDerivedDirection(void) const;
316 
322  void setVisible(bool visible);
323 
325  Real getBoundingRadius(void) const { return 0; /* not visible */ }
326 
336  Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const;
337 
347  virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const;
348 
355  virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const;
356 
358  uint32 getTypeFlags(void) const;
359 
361  AnimableValuePtr createAnimableValue(const String& valueName);
362 
369  void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup);
370 
374  void resetCustomShadowCameraSetup(void);
375 
377  const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const;
378 
380  void visitRenderables(Renderable::Visitor* visitor,
381  bool debugRenderables = false);
382 
391  size_t _getIndexInFrame() const { return mIndexInFrame; }
392  void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; }
393 
409  void setShadowFarDistance(Real distance);
412  void resetShadowFarDistance(void);
416  Real getShadowFarDistance(void) const;
417  Real getShadowFarDistanceSquared(void) const;
418 
423  void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; }
424 
430  Real getShadowNearClipDistance() const { return mShadowNearClipDist; }
431 
435  Real _deriveShadowNearClipDistance(const Camera* maincam) const;
436 
444  void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; }
445 
451  Real getShadowFarClipDistance() const { return mShadowFarClipDist; }
452 
456  Real _deriveShadowFarClipDistance(const Camera* maincam) const;
457 
459  void _setCameraRelative(Camera* cam);
460 
476  void setCustomParameter(uint16 index, const Vector4& value);
477 
482  const Vector4& getCustomParameter(uint16 index) const;
483 
506  virtual void _updateCustomGpuParameter(uint16 paramIndex,
507  const GpuProgramParameters::AutoConstantEntry& constantEntry,
508  GpuProgramParameters* params) const;
509  protected:
511  virtual void update(void) const;
512 
514  const String& getAnimableDictionaryName(void) const;
516  void initialiseAnimableDictionary(StringVector& vec) const;
517 
522 
524 
537 
540 
541 
544  // Slightly hacky but unless we separate observed light render state from main Light...
548 
551 
556 
559 
563  };
564 
567  {
568  protected:
569  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
570  public:
573 
575 
576  const String& getType(void) const;
577  void destroyInstance( MovableObject* obj);
578 
579  };
583 } // Namespace
584 #endif
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
bool mDerivedTransformDirty
Is the derived transform dirty?
Definition: OgreLight.h:555
float Real
Software floating point type.
unsigned int uint32
Definition: OgrePlatform.h:246
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:451
#define _OgreExport
Definition: OgrePlatform.h:203
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:524
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:423
Real mShadowFarDistSquared
Definition: OgreLight.h:536
Class representing colour.
Vector3 mDirection
Definition: OgreLight.h:523
LightTypes
Defines the type of light.
Definition: OgreLight.h:81
A 3D box aligned with the x/y/z axes.
Camera * mCameraToBeRelativeTo
Definition: OgreLight.h:547
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:444
Real mAttenuationConst
Definition: OgreLight.h:529
Vector3 mPosition
Definition: OgreLight.h:519
bool mOwnShadowFarDist
Definition: OgreLight.h:534
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:546
size_t _getIndexInFrame() const
Gets the index at which this light is in the current render.
Definition: OgreLight.h:391
static String FACTORY_TYPE_NAME
Definition: OgreLight.h:574
Real mAttenuationQuad
Definition: OgreLight.h:531
Abstract class defining a movable object in a scene.
Vector3 mDerivedPosition
Definition: OgreLight.h:542
Real mRange
Definition: OgreLight.h:528
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:72
Structure recording the use of an automatic parameter.
ColourValue mDiffuse
Definition: OgreLight.h:520
PlaneBoundedVolumeList mFrustumClipVolumes
Definition: OgreLight.h:553
Real mSpotFalloff
Definition: OgreLight.h:527
ColourValue mSpecular
Definition: OgreLight.h:521
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:430
void _notifyIndexInFrame(size_t i)
Definition: OgreLight.h:392
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreLight.h:550
Real mShadowFarClipDist
Definition: OgreLight.h:539
ShadowCameraSetupPtr mCustomShadowCameraSetup
Pointer to a custom shadow camera setup.
Definition: OgreLight.h:558
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:552
Represents a convex volume bounded by planes.
Real mAttenuationLinear
Definition: OgreLight.h:530
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:46
Real mShadowNearClipDist
Definition: OgreLight.h:538
Class to manage the scene object rendering queue.
size_t mIndexInFrame
Definition: OgreLight.h:533
_StringBase String
Vector3 mDerivedCamRelativePosition
Definition: OgreLight.h:545
Real mPowerScale
Definition: OgreLight.h:532
Vector3 mDerivedDirection
Definition: OgreLight.h:543
unsigned short uint16
Definition: OgrePlatform.h:247
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Real mShadowFarDist
Definition: OgreLight.h:535
Real tempSquareDist
Temp tag used for sorting.
Definition: OgreLight.h:76
map< uint16, Vector4 >::type CustomParameterMap
Definition: OgreLight.h:560
Real getBoundingRadius(void) const
Overridden from MovableObject.
Definition: OgreLight.h:325
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:62
Radian mSpotInner
Definition: OgreLight.h:526
CustomParameterMap mCustomParameters
Stores the custom parameters for the light.
Definition: OgreLight.h:562
Factory object for creating Light instances.
Definition: OgreLight.h:566
Radian mSpotOuter
Definition: OgreLight.h:525
LightTypes mLightType
Definition: OgreLight.h:518