OgreLight.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef _LIGHT_H__
#define _LIGHT_H__
#include "OgrePrerequisites.h"
#include "OgreColourValue.h"
#include "OgreVector3.h"
#include "OgreVector4.h"
#include "OgreString.h"
#include "OgreMovableObject.h"
#include "OgrePlaneBoundedVolume.h"
#include "OgreShadowCameraSetup.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class _OgreExport Light : public MovableObject
{
public:
Real tempSquareDist;
void _calcTempSquareDist(const Vector3& worldPos);
enum LightTypes
{
LT_POINT = 0,
LT_DIRECTIONAL = 1,
LT_SPOTLIGHT = 2
};
Light();
Light(const String& name);
~Light();
void setType(LightTypes type);
LightTypes getType(void) const;
void setDiffuseColour(Real red, Real green, Real blue);
void setDiffuseColour(const ColourValue& colour);
const ColourValue& getDiffuseColour(void) const;
void setSpecularColour(Real red, Real green, Real blue);
void setSpecularColour(const ColourValue& colour);
const ColourValue& getSpecularColour(void) const;
void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
Real getAttenuationRange(void) const;
Real getAttenuationConstant(void) const;
Real getAttenuationLinear(void) const;
Real getAttenuationQuadric(void) const;
void setPosition(Real x, Real y, Real z);
void setPosition(const Vector3& vec);
const Vector3& getPosition(void) const;
void setDirection(Real x, Real y, Real z);
void setDirection(const Vector3& vec);
const Vector3& getDirection(void) const;
void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
const Radian& getSpotlightInnerAngle(void) const;
const Radian& getSpotlightOuterAngle(void) const;
Real getSpotlightFalloff(void) const;
void setSpotlightInnerAngle(const Radian& val);
void setSpotlightOuterAngle(const Radian& val);
void setSpotlightFalloff(Real val);
void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; }
Real getSpotlightNearClipDistance() const { return mSpotNearClip; }
void setPowerScale(Real power);
Real getPowerScale(void) const;
void _notifyAttached(Node* parent, bool isTagPoint = false);
void _notifyMoved(void);
const AxisAlignedBox& getBoundingBox(void) const;
void _updateRenderQueue(RenderQueue* queue);
const String& getMovableType(void) const;
const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const;
const Vector3& getDerivedDirection(void) const;
void setVisible(bool visible);
Real getBoundingRadius(void) const { return 0; /* not visible */ }
Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const;
virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const;
virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const;
uint32 getTypeFlags(void) const;
AnimableValuePtr createAnimableValue(const String& valueName);
void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup);
void resetCustomShadowCameraSetup(void);
const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const;
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
size_t _getIndexInFrame() const { return mIndexInFrame; }
void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; }
void setShadowFarDistance(Real distance);
void resetShadowFarDistance(void);
Real getShadowFarDistance(void) const;
Real getShadowFarDistanceSquared(void) const;
void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; }
Real getShadowNearClipDistance() const { return mShadowNearClipDist; }
Real _deriveShadowNearClipDistance(const Camera* maincam) const;
void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; }
Real getShadowFarClipDistance() const { return mShadowFarClipDist; }
Real _deriveShadowFarClipDistance(const Camera* maincam) const;
void _setCameraRelative(Camera* cam);
void setCustomParameter(uint16 index, const Vector4& value);
const Vector4& getCustomParameter(uint16 index) const;
virtual void _updateCustomGpuParameter(uint16 paramIndex,
const GpuProgramParameters::AutoConstantEntry& constantEntry,
GpuProgramParameters* params) const;
bool isInLightRange(const Ogre::Sphere& sphere) const;
bool isInLightRange(const Ogre::AxisAlignedBox& container) const;
protected:
virtual void update(void) const;
const String& getAnimableDictionaryName(void) const;
void initialiseAnimableDictionary(StringVector& vec) const;
LightTypes mLightType;
Vector3 mPosition;
ColourValue mDiffuse;
ColourValue mSpecular;
Vector3 mDirection;
Radian mSpotOuter;
Radian mSpotInner;
Real mSpotFalloff;
Real mSpotNearClip;
Real mRange;
Real mAttenuationConst;
Real mAttenuationLinear;
Real mAttenuationQuad;
Real mPowerScale;
size_t mIndexInFrame;
bool mOwnShadowFarDist;
Real mShadowFarDist;
Real mShadowFarDistSquared;
Real mShadowNearClipDist;
Real mShadowFarClipDist;
mutable Vector3 mDerivedPosition;
mutable Vector3 mDerivedDirection;
// Slightly hacky but unless we separate observed light render state from main Light...
mutable Vector3 mDerivedCamRelativePosition;
mutable bool mDerivedCamRelativeDirty;
Camera* mCameraToBeRelativeTo;
static String msMovableType;
mutable PlaneBoundedVolume mNearClipVolume;
mutable PlaneBoundedVolumeList mFrustumClipVolumes;
mutable bool mDerivedTransformDirty;
mutable ShadowCameraSetupPtr mCustomShadowCameraSetup;
typedef map<uint16, Vector4>::type CustomParameterMap;
CustomParameterMap mCustomParameters;
};
class _OgreExport LightFactory : public MovableObjectFactory
{
protected:
MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
public:
LightFactory() {}
~LightFactory() {}
static String FACTORY_TYPE_NAME;
const String& getType(void) const;
void destroyInstance(MovableObject* obj);
};
#include "OgreHeaderPrefix.h"
} // namespace Ogre
#endif // _LIGHT_H__
OgreVector4.h
Ogre::Light::mDirection
Vector3 mDirection
Definition: OgreLight.h:568
Ogre::LightFactory::FACTORY_TYPE_NAME
static String FACTORY_TYPE_NAME
Definition: OgreLight.h:620
Ogre::Light::setSpotlightNearClipDistance
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:289
OgreVector3.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Light::mDerivedPosition
Vector3 mDerivedPosition
Definition: OgreLight.h:588
Ogre::Light::mAttenuationQuad
Real mAttenuationQuad
Definition: OgreLight.h:577
Ogre::Light::mAttenuationConst
Real mAttenuationConst
Definition: OgreLight.h:575
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
OgreMovableObject.h
Ogre::Light::mSpotInner
Radian mSpotInner
Definition: OgreLight.h:571
Ogre::Light::mPowerScale
Real mPowerScale
Definition: OgreLight.h:578
Ogre::PlaneBoundedVolume
Represents a convex volume bounded by planes.
Definition: OgrePlaneBoundedVolume.h:49
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Ogre::Light::mShadowFarClipDist
Real mShadowFarClipDist
Definition: OgreLight.h:585
Ogre::Vector4
4-dimensional homogeneous vector.
Definition: OgreVector4.h:45
Ogre::Light::mCustomShadowCameraSetup
ShadowCameraSetupPtr mCustomShadowCameraSetup
Pointer to a custom shadow camera setup.
Definition: OgreLight.h:604
Ogre::Light::mAttenuationLinear
Real mAttenuationLinear
Definition: OgreLight.h:576
Ogre::Light::setShadowFarClipDistance
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:468
Ogre::ColourValue
Class representing colour.
Definition: OgreColourValue.h:57
Ogre::Light::mCustomParameters
CustomParameterMap mCustomParameters
Stores the custom parameters for the light.
Definition: OgreLight.h:608
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::Light::mIndexInFrame
size_t mIndexInFrame
Definition: OgreLight.h:579
Ogre::Light::mNearClipVolume
PlaneBoundedVolume mNearClipVolume
Definition: OgreLight.h:598
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
OgreString.h
Ogre::Light::mPosition
Vector3 mPosition
Definition: OgreLight.h:564
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
Ogre::Light::getBoundingRadius
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
Definition: OgreLight.h:342
Ogre::Light::mSpotFalloff
Real mSpotFalloff
Definition: OgreLight.h:572
Ogre::GpuProgramParameters::AutoConstantEntry
Structure recording the use of an automatic parameter.
Definition: OgreGpuProgramParams.h:1215
Ogre::Light::mSpecular
ColourValue mSpecular
Definition: OgreLight.h:566
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePlaneBoundedVolume.h
OgrePrerequisites.h
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::Node
Class representing a general-purpose node an articulated scene graph.
Definition: OgreNode.h:64
Ogre::Light::mDerivedTransformDirty
bool mDerivedTransformDirty
Is the derived transform dirty?
Definition: OgreLight.h:601
Ogre::Light::_getIndexInFrame
size_t _getIndexInFrame() const
Gets the index at which this light is in the current render.
Definition: OgreLight.h:411
Ogre::Light::msMovableType
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreLight.h:596
Ogre::PlaneBoundedVolumeList
vector< PlaneBoundedVolume >::type PlaneBoundedVolumeList
Definition: OgrePlaneBoundedVolume.h:128
Ogre::LightFactory::LightFactory
LightFactory()
Definition: OgreLight.h:617
Ogre::NameValuePairList
map< String, String >::type NameValuePairList
Name / value parameter pair (first = name, second = value)
Definition: OgreCommon.h:550
Ogre::Light::tempSquareDist
Real tempSquareDist
Temp tag used for sorting.
Definition: OgreLight.h:77
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Light::mSpotOuter
Radian mSpotOuter
Definition: OgreLight.h:570
Ogre::Light::mDiffuse
ColourValue mDiffuse
Definition: OgreLight.h:565
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Ogre::Light::mOwnShadowFarDist
bool mOwnShadowFarDist
Definition: OgreLight.h:580
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre::Light::mDerivedCamRelativeDirty
bool mDerivedCamRelativeDirty
Definition: OgreLight.h:592
Ogre::Light::mShadowFarDistSquared
Real mShadowFarDistSquared
Definition: OgreLight.h:582
Ogre::Light::mShadowFarDist
Real mShadowFarDist
Definition: OgreLight.h:581
Ogre::Light::_notifyIndexInFrame
void _notifyIndexInFrame(size_t i)
Definition: OgreLight.h:412
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::Light::mCameraToBeRelativeTo
Camera * mCameraToBeRelativeTo
Definition: OgreLight.h:593
Ogre::Light::getShadowNearClipDistance
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:452
Ogre::Light::getSpotlightNearClipDistance
Real getSpotlightNearClipDistance() const
Get the near clip plane distance to be used by spotlights that use light clipping.
Definition: OgreLight.h:294
OgreShadowCameraSetup.h
Ogre::Light::mSpotNearClip
Real mSpotNearClip
Definition: OgreLight.h:573
Ogre::Light::mLightType
LightTypes mLightType
Definition: OgreLight.h:563
Ogre::SharedPtr< AnimableValue >
Ogre::Light::LightTypes
LightTypes
Defines the type of light.
Definition: OgreLight.h:82
OgreColourValue.h
OgreHeaderPrefix.h
Ogre::Light::CustomParameterMap
map< uint16, Vector4 >::type CustomParameterMap
Definition: OgreLight.h:606
Ogre::Light::mDerivedCamRelativePosition
Vector3 mDerivedCamRelativePosition
Definition: OgreLight.h:591
Ogre::LightFactory
Factory object for creating Light instances.
Definition: OgreLight.h:612
Ogre::Light::setShadowNearClipDistance
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:444
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::MovableObjectFactory
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.
Definition: OgreMovableObject.h:578
Ogre::Light::mDerivedDirection
Vector3 mDerivedDirection
Definition: OgreLight.h:589
Ogre::Light::mFrustumClipVolumes
PlaneBoundedVolumeList mFrustumClipVolumes
Definition: OgreLight.h:599
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::Light::mRange
Real mRange
Definition: OgreLight.h:574
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Ogre::Light::getShadowFarClipDistance
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:476
Ogre::GpuProgramParameters
Collects together the program parameters used for a GpuProgram.
Definition: OgreGpuProgramParams.h:702
Ogre::LightFactory::~LightFactory
~LightFactory()
Definition: OgreLight.h:618
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47
Ogre::Light::mShadowNearClipDist
Real mShadowNearClipDist
Definition: OgreLight.h:584

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.