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 
257  void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
258 
261  const Radian& getSpotlightInnerAngle(void) const;
262 
265  const Radian& getSpotlightOuterAngle(void) const;
266 
269  Real getSpotlightFalloff(void) const;
270 
273  void setSpotlightInnerAngle(const Radian& val);
274 
277  void setSpotlightOuterAngle(const Radian& val);
278 
281  void setSpotlightFalloff(Real val);
282 
289  void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; }
290 
294  Real getSpotlightNearClipDistance() const { return mSpotNearClip; }
295 
304  void setPowerScale(Real power);
305 
309  Real getPowerScale(void) const;
310 
312  void _notifyAttached(Node* parent, bool isTagPoint = false);
313 
315  void _notifyMoved(void);
316 
318  const AxisAlignedBox& getBoundingBox(void) const;
319 
321  void _updateRenderQueue(RenderQueue* queue);
322 
324  const String& getMovableType(void) const;
325 
329  const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const;
330 
332  const Vector3& getDerivedDirection(void) const;
333 
339  void setVisible(bool visible);
340 
342  Real getBoundingRadius(void) const { return 0; /* not visible */ }
343 
354  Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const;
355 
366  virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const;
367 
375  virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const;
376 
378  uint32 getTypeFlags(void) const;
379 
381  AnimableValuePtr createAnimableValue(const String& valueName);
382 
389  void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup);
390 
394  void resetCustomShadowCameraSetup(void);
395 
397  const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const;
398 
400  void visitRenderables(Renderable::Visitor* visitor,
401  bool debugRenderables = false);
402 
411  size_t _getIndexInFrame() const { return mIndexInFrame; }
412  void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; }
413 
429  void setShadowFarDistance(Real distance);
432  void resetShadowFarDistance(void);
436  Real getShadowFarDistance(void) const;
437  Real getShadowFarDistanceSquared(void) const;
438 
444  void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; }
445 
452  Real getShadowNearClipDistance() const { return mShadowNearClipDist; }
453 
457  Real _deriveShadowNearClipDistance(const Camera* maincam) const;
458 
468  void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; }
469 
476  Real getShadowFarClipDistance() const { return mShadowFarClipDist; }
477 
481  Real _deriveShadowFarClipDistance(const Camera* maincam) const;
482 
484  void _setCameraRelative(Camera* cam);
485 
503  void setCustomParameter(uint16 index, const Vector4& value);
504 
508  const Vector4& getCustomParameter(uint16 index) const;
509 
535  virtual void _updateCustomGpuParameter(uint16 paramIndex,
536  const GpuProgramParameters::AutoConstantEntry& constantEntry,
537  GpuProgramParameters* params) const;
538 
544  bool isInLightRange(const Ogre::Sphere& sphere) const;
545 
551  bool isInLightRange(const Ogre::AxisAlignedBox& container) const;
552 
553  protected:
555  virtual void update(void) const;
556 
558  const String& getAnimableDictionaryName(void) const;
560  void initialiseAnimableDictionary(StringVector& vec) const;
561 
566 
568 
582 
585 
586 
589  // Slightly hacky but unless we separate observed light render state from main Light...
593 
596 
601 
604 
608  };
609 
612  {
613  protected:
614  MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
615  public:
618 
620 
621  const String& getType(void) const;
622  void destroyInstance(MovableObject* obj);
623 
624  };
628 #include "OgreHeaderPrefix.h"
629 
630 } // namespace Ogre
631 #endif // _LIGHT_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:42