# 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;
    00073         void _calcTempSquareDist(const Vector3& worldPos);
    00074
    00076         enum LightTypes
    00077         {
    00079             LT_POINT = 0,
    00081             LT_DIRECTIONAL = 1,
    00083             LT_SPOTLIGHT = 2
    00084         };
    00085
    00088         Light();
    00089
    00092         Light(const String& name);
    00093
    00096         ~Light();
    00097
    00100         void setType(LightTypes type);
    00101
    00104         LightTypes getType(void) const;
    00105
    00115         void setDiffuseColour(Real red, Real green, Real blue);
    00116
    00126         void setDiffuseColour(const ColourValue& colour);
    00127
    00130         const ColourValue& getDiffuseColour(void) const;
    00131
    00141         void setSpecularColour(Real red, Real green, Real blue);
    00142
    00152         void setSpecularColour(const ColourValue& colour);
    00153
    00156         const ColourValue& getSpecularColour(void) const;
    00157
    00177         void setAttenuation(Real range, Real constant, Real linear, Real quadratic);
    00178
    00181         Real getAttenuationRange(void) const;
    00182
    00185         Real getAttenuationConstant(void) const;
    00186
    00189         Real getAttenuationLinear(void) const;
    00190
    00193         Real getAttenuationQuadric(void) const;
    00194
    00201         void setPosition(Real x, Real y, Real z);
    00202
    00209         void setPosition(const Vector3& vec);
    00210
    00215         const Vector3& getPosition(void) const;
    00216
    00223         void setDirection(Real x, Real y, Real z);
    00224
    00231         void setDirection(const Vector3& vec);
    00232
    00237         const Vector3& getDirection(void) const;
    00238
    00249         void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0);
    00250
    00253         const Radian& getSpotlightInnerAngle(void) const;
    00254
    00257         const Radian& getSpotlightOuterAngle(void) const;
    00258
    00261         Real getSpotlightFalloff(void) const;
    00262
    00265         void setSpotlightInnerAngle(const Radian& val);
    00266
    00269         void setSpotlightOuterAngle(const Radian& val);
    00270
    00273         void setSpotlightFalloff(Real val);
    00274
    00282         void setPowerScale(Real power);
    00283
    00287         Real getPowerScale(void) const;
    00288
    00290         void _notifyAttached(Node* parent, bool isTagPoint = false);
    00291
    00293         void _notifyMoved(void);
    00294
    00296         const AxisAlignedBox& getBoundingBox(void) const;
    00297
    00299         void _updateRenderQueue(RenderQueue* queue);
    00300
    00302         const String& getMovableType(void) const;
    00303
    00307         const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const;
    00308
    00310         const Vector3& getDerivedDirection(void) const;
    00311
    00317         void setVisible(bool visible);
    00318
    00320         Real getBoundingRadius(void) const { return 0; /* not visible */ }
    00321
    00331         Vector4 getAs4DVector(bool cameraRelativeIfSet = false) 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
    00375         void visitRenderables(Renderable::Visitor* visitor,
    00376             bool debugRenderables = false);
    00377
    00386         size_t _getIndexInFrame() const { return mIndexInFrame; }
    00387         void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; }
    00388
    00404         void setShadowFarDistance(Real distance);
    00407         void resetShadowFarDistance(void);
    00411         Real getShadowFarDistance(void) const;
    00412         Real getShadowFarDistanceSquared(void) const;
    00413
    00415         void _setCameraRelative(Camera* cam);
    00416
    00417
    00418     protected:
    00420         virtual void update(void) const;
    00421
    00423         const String& getAnimableDictionaryName(void) const;
    00425         void initialiseAnimableDictionary(StringVector& vec) const;
    00426
    00427         LightTypes mLightType;
    00428         Vector3 mPosition;
    00429         ColourValue mDiffuse;
    00430         ColourValue mSpecular;
    00431
    00432         Vector3 mDirection;
    00433
    00434         Radian mSpotOuter;
    00435         Radian mSpotInner;
    00436         Real mSpotFalloff;
    00437         Real mRange;
    00438         Real mAttenuationConst;
    00439         Real mAttenuationLinear;
    00440         Real mAttenuationQuad;
    00441         Real mPowerScale;
    00442         size_t mIndexInFrame;
    00443         bool mOwnShadowFarDist;
    00444         Real mShadowFarDist;
    00445         Real mShadowFarDistSquared;
    00446
    00447
    00448         mutable Vector3 mDerivedPosition;
    00449         mutable Vector3 mDerivedDirection;
    00450         // Slightly hacky but unless we separate observed light render state from main Light...
    00451         mutable Vector3 mDerivedCamRelativePosition;
    00452         mutable bool mDerivedCamRelativeDirty;
    00453         Camera* mCameraToBeRelativeTo;
    00454
    00456         static String msMovableType;
    00457
    00458         mutable PlaneBoundedVolume mNearClipVolume;
    00459         mutable PlaneBoundedVolumeList mFrustumClipVolumes;
    00461         mutable bool mDerivedTransformDirty;
    00462
    00464         mutable ShadowCameraSetupPtr mCustomShadowCameraSetup;
    00465
    00466     };
    00467
    00469     class _OgreExport LightFactory : public MovableObjectFactory
    00470     {
    00471     protected:
    00472         MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params);
    00473     public:
    00474         LightFactory() {}
    00475         ~LightFactory() {}
    00476
    00477         static String FACTORY_TYPE_NAME;
    00478
    00479         const String& getType(void) const;
    00480         void destroyInstance( MovableObject* obj);
    00481
    00482     };
    00483
    00484 } // Namespace
    00485 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Dec 27 17:31:05 2009