# OgreLight.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004     (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2006 Torus Knot Software Ltd
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023
    00024 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef _LIGHT_H__
    00030 #define _LIGHT_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033
    00034 #include "OgreColourValue.h"
    00035 #include "OgreVector3.h"
    00036 #include "OgreVector4.h"
    00037 #include "OgreString.h"
    00038 #include "OgreMovableObject.h"
    00039 #include "OgrePlaneBoundedVolume.h"
    00040 #include "OgreShadowCameraSetup.h"
    00041
    00042 namespace Ogre {
    00043
    00044
    00067     class _OgreExport Light : public MovableObject
    00068     {
    00069     public:
    00071         Real tempSquareDist;
    00072
    00074         enum LightTypes
    00075         {
    00077             LT_POINT,
    00079             LT_DIRECTIONAL,
    00081             LT_SPOTLIGHT
    00082         };
    00083
    00086         Light();
    00087
    00090         Light(const String& name);
    00091
    00094         ~Light();
    00095
    00098         void setType(LightTypes type);
    00099
    00102         LightTypes getType(void) const;
    00103
    00113         void setDiffuseColour(Real red, Real green, Real blue);
    00114
    00124         void setDiffuseColour(const ColourValue& colour);
    00125
    00128         const ColourValue& getDiffuseColour(void) const;
    00129
    00139         void setSpecularColour(Real red, Real green, Real blue);
    00140
    00150         void setSpecularColour(const ColourValue& colour);
    00151
    00154         const ColourValue& getSpecularColour(void) const;
    00155
    00175         void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
    00176
    00179         Real getAttenuationRange(void) const;
    00180
    00183         Real getAttenuationConstant(void) const;
    00184
    00187         Real getAttenuationLinear(void) const;
    00188
    00191         Real getAttenuationQuadric(void) const;
    00192
    00199         void setPosition(Real x, Real y, Real z);
    00200
    00207         void setPosition(const Vector3& vec);
    00208
    00213         const Vector3& getPosition(void) const;
    00214
    00221         void setDirection(Real x, Real y, Real z);
    00222
    00229         void setDirection(const Vector3& vec);
    00230
    00235         const Vector3& getDirection(void) const;
    00236
    00247         void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
    00248 #ifndef OGRE_FORCE_ANGLE_TYPES
    00249         inline void setSpotlightRange(Real innerAngle, Real outerAngle, Real falloff = 1.0) {
    00250             setSpotlightRange ( Angle(innerAngle), Angle(outerAngle), falloff );
    00251         }
    00252 #endif//OGRE_FORCE_ANGLE_TYPES
    00253
    00256         const Radian& getSpotlightInnerAngle(void) const;
    00257
    00260         const Radian& getSpotlightOuterAngle(void) const;
    00261
    00264         Real getSpotlightFalloff(void) const;
    00265
    00268         void setSpotlightInnerAngle(const Radian& val);
    00269
    00272         void setSpotlightOuterAngle(const Radian& val);
    00273
    00276         void setSpotlightFalloff(Real val);
    00277
    00285         void setPowerScale(Real power);
    00286
    00290         Real getPowerScale(void) const;
    00291
    00293         void _notifyAttached(Node* parent, bool isTagPoint = false);
    00294
    00296         void _notifyMoved(void);
    00297
    00299         const AxisAlignedBox& getBoundingBox(void) const;
    00300
    00302         void _updateRenderQueue(RenderQueue* queue);
    00303
    00305         const String& getMovableType(void) const;
    00306
    00308         const Vector3& getDerivedPosition(void) const;
    00309
    00311         const Vector3& getDerivedDirection(void) const;
    00312
    00318         void setVisible(bool visible);
    00319
    00321         Real getBoundingRadius(void) const { return 0; /* not visible */ }
    00322
    00331         Vector4 getAs4DVector(void) const;
    00332
    00342         virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const;
    00343
    00350         virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const;
    00351
    00353         uint32 getTypeFlags(void) const;
    00354
    00356         AnimableValuePtr createAnimableValue(const String& valueName);
    00357
    00364         void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup);
    00365
    00369         void resetCustomShadowCameraSetup(void);
    00370
    00372         const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const;
    00373
    00374     protected:
    00376         virtual void update(void) const;
    00377
    00379         const String& getAnimableDictionaryName(void) const;
    00381         void initialiseAnimableDictionary(StringVector& vec) const;
    00382
    00383         LightTypes mLightType;
    00384         Vector3 mPosition;
    00385         ColourValue mDiffuse;
    00386         ColourValue mSpecular;
    00387
    00388         Vector3 mDirection;
    00389
    00390         Radian mSpotOuter;
    00391         Radian mSpotInner;
    00392         Real mSpotFalloff;
    00393         Real mRange;
    00394         Real mAttenuationConst;
    00395         Real mAttenuationLinear;
    00396         Real mAttenuationQuad;
    00397         Real mPowerScale;
    00398
    00399
    00400         mutable Vector3 mDerivedPosition;
    00401         mutable Vector3 mDerivedDirection;
    00402
    00404         static String msMovableType;
    00405
    00406         mutable PlaneBoundedVolume mNearClipVolume;
    00407         mutable PlaneBoundedVolumeList mFrustumClipVolumes;
    00409         mutable bool mDerivedTransformDirty;
    00410
    00412         mutable ShadowCameraSetupPtr mCustomShadowCameraSetup;
    00413
    00414     };
    00415
    00417     class _OgreExport LightFactory : public MovableObjectFactory
    00418     {
    00419     protected:
    00420         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00421     public:
    00422         LightFactory() {}
    00423         ~LightFactory() {}
    00424
    00425         static String FACTORY_TYPE_NAME;
    00426
    00427         const String& getType(void) const;
    00428         void destroyInstance( MovableObject* obj);
    00429
    00430     };
    00431
    00432 } // Namespace
    00433 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Aug 20 13:50:46 2007