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-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef _LIGHT_H__ 00029 #define _LIGHT_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 00033 #include "OgreColourValue.h" 00034 #include "OgreVector3.h" 00035 #include "OgreVector4.h" 00036 #include "OgreString.h" 00037 #include "OgreMovableObject.h" 00038 #include "OgrePlaneBoundedVolume.h" 00039 #include "OgreShadowCameraSetup.h" 00040 #include "OgreHeaderPrefix.h" 00041 00042 namespace Ogre { 00043 00044 00073 class _OgreExport Light : public MovableObject 00074 { 00075 public: 00077 Real tempSquareDist; 00079 void _calcTempSquareDist(const Vector3& worldPos); 00080 00082 enum LightTypes 00083 { 00085 LT_POINT = 0, 00087 LT_DIRECTIONAL = 1, 00089 LT_SPOTLIGHT = 2 00090 }; 00091 00094 Light(); 00095 00098 Light(const String& name); 00099 00102 ~Light(); 00103 00106 void setType(LightTypes type); 00107 00110 LightTypes getType(void) const; 00111 00121 void setDiffuseColour(Real red, Real green, Real blue); 00122 00132 void setDiffuseColour(const ColourValue& colour); 00133 00136 const ColourValue& getDiffuseColour(void) const; 00137 00147 void setSpecularColour(Real red, Real green, Real blue); 00148 00158 void setSpecularColour(const ColourValue& colour); 00159 00162 const ColourValue& getSpecularColour(void) const; 00163 00183 void setAttenuation(Real range, Real constant, Real linear, Real quadratic); 00184 00187 Real getAttenuationRange(void) const; 00188 00191 Real getAttenuationConstant(void) const; 00192 00195 Real getAttenuationLinear(void) const; 00196 00199 Real getAttenuationQuadric(void) const; 00200 00207 void setPosition(Real x, Real y, Real z); 00208 00215 void setPosition(const Vector3& vec); 00216 00221 const Vector3& getPosition(void) const; 00222 00229 void setDirection(Real x, Real y, Real z); 00230 00237 void setDirection(const Vector3& vec); 00238 00243 const Vector3& getDirection(void) const; 00244 00257 void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0); 00258 00261 const Radian& getSpotlightInnerAngle(void) const; 00262 00265 const Radian& getSpotlightOuterAngle(void) const; 00266 00269 Real getSpotlightFalloff(void) const; 00270 00273 void setSpotlightInnerAngle(const Radian& val); 00274 00277 void setSpotlightOuterAngle(const Radian& val); 00278 00281 void setSpotlightFalloff(Real val); 00282 00289 void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; } 00290 00294 Real getSpotlightNearClipDistance() const { return mSpotNearClip; } 00295 00304 void setPowerScale(Real power); 00305 00309 Real getPowerScale(void) const; 00310 00312 void _notifyAttached(Node* parent, bool isTagPoint = false); 00313 00315 void _notifyMoved(void); 00316 00318 const AxisAlignedBox& getBoundingBox(void) const; 00319 00321 void _updateRenderQueue(RenderQueue* queue); 00322 00324 const String& getMovableType(void) const; 00325 00329 const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const; 00330 00332 const Vector3& getDerivedDirection(void) const; 00333 00339 void setVisible(bool visible); 00340 00342 Real getBoundingRadius(void) const { return 0; /* not visible */ } 00343 00354 Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const; 00355 00366 virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const; 00367 00375 virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const; 00376 00378 uint32 getTypeFlags(void) const; 00379 00381 AnimableValuePtr createAnimableValue(const String& valueName); 00382 00389 void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup); 00390 00394 void resetCustomShadowCameraSetup(void); 00395 00397 const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const; 00398 00400 void visitRenderables(Renderable::Visitor* visitor, 00401 bool debugRenderables = false); 00402 00411 size_t _getIndexInFrame() const { return mIndexInFrame; } 00412 void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; } 00413 00429 void setShadowFarDistance(Real distance); 00432 void resetShadowFarDistance(void); 00436 Real getShadowFarDistance(void) const; 00437 Real getShadowFarDistanceSquared(void) const; 00438 00444 void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; } 00445 00452 Real getShadowNearClipDistance() const { return mShadowNearClipDist; } 00453 00457 Real _deriveShadowNearClipDistance(const Camera* maincam) const; 00458 00468 void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; } 00469 00476 Real getShadowFarClipDistance() const { return mShadowFarClipDist; } 00477 00481 Real _deriveShadowFarClipDistance(const Camera* maincam) const; 00482 00484 void _setCameraRelative(Camera* cam); 00485 00503 void setCustomParameter(uint16 index, const Vector4& value); 00504 00509 const Vector4& getCustomParameter(uint16 index) const; 00510 00536 virtual void _updateCustomGpuParameter(uint16 paramIndex, 00537 const GpuProgramParameters::AutoConstantEntry& constantEntry, 00538 GpuProgramParameters* params) const; 00539 00545 bool isInLightRange(const Ogre::Sphere& sphere) const; 00546 00552 bool isInLightRange(const Ogre::AxisAlignedBox& container) const; 00553 00554 protected: 00556 virtual void update(void) const; 00557 00559 const String& getAnimableDictionaryName(void) const; 00561 void initialiseAnimableDictionary(StringVector& vec) const; 00562 00563 LightTypes mLightType; 00564 Vector3 mPosition; 00565 ColourValue mDiffuse; 00566 ColourValue mSpecular; 00567 00568 Vector3 mDirection; 00569 00570 Radian mSpotOuter; 00571 Radian mSpotInner; 00572 Real mSpotFalloff; 00573 Real mSpotNearClip; 00574 Real mRange; 00575 Real mAttenuationConst; 00576 Real mAttenuationLinear; 00577 Real mAttenuationQuad; 00578 Real mPowerScale; 00579 size_t mIndexInFrame; 00580 bool mOwnShadowFarDist; 00581 Real mShadowFarDist; 00582 Real mShadowFarDistSquared; 00583 00584 Real mShadowNearClipDist; 00585 Real mShadowFarClipDist; 00586 00587 00588 mutable Vector3 mDerivedPosition; 00589 mutable Vector3 mDerivedDirection; 00590 // Slightly hacky but unless we separate observed light render state from main Light... 00591 mutable Vector3 mDerivedCamRelativePosition; 00592 mutable bool mDerivedCamRelativeDirty; 00593 Camera* mCameraToBeRelativeTo; 00594 00596 static String msMovableType; 00597 00598 mutable PlaneBoundedVolume mNearClipVolume; 00599 mutable PlaneBoundedVolumeList mFrustumClipVolumes; 00601 mutable bool mDerivedTransformDirty; 00602 00604 mutable ShadowCameraSetupPtr mCustomShadowCameraSetup; 00605 00606 typedef map<uint16, Vector4>::type CustomParameterMap; 00608 CustomParameterMap mCustomParameters; 00609 }; 00610 00612 class _OgreExport LightFactory : public MovableObjectFactory 00613 { 00614 protected: 00615 MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); 00616 public: 00617 LightFactory() {} 00618 ~LightFactory() {} 00619 00620 static String FACTORY_TYPE_NAME; 00621 00622 const String& getType(void) const; 00623 void destroyInstance(MovableObject* obj); 00624 00625 }; 00629 #include "OgreHeaderPrefix.h" 00630 00631 } // namespace Ogre 00632 #endif // _LIGHT_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:43