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-2012 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 00041 namespace Ogre { 00042 00043 00072 class _OgreExport Light : public MovableObject 00073 { 00074 public: 00076 Real tempSquareDist; 00078 void _calcTempSquareDist(const Vector3& worldPos); 00079 00081 enum LightTypes 00082 { 00084 LT_POINT = 0, 00086 LT_DIRECTIONAL = 1, 00088 LT_SPOTLIGHT = 2 00089 }; 00090 00093 Light(); 00094 00097 Light(const String& name); 00098 00101 ~Light(); 00102 00105 void setType(LightTypes type); 00106 00109 LightTypes getType(void) const; 00110 00120 void setDiffuseColour(Real red, Real green, Real blue); 00121 00131 void setDiffuseColour(const ColourValue& colour); 00132 00135 const ColourValue& getDiffuseColour(void) const; 00136 00146 void setSpecularColour(Real red, Real green, Real blue); 00147 00157 void setSpecularColour(const ColourValue& colour); 00158 00161 const ColourValue& getSpecularColour(void) const; 00162 00182 void setAttenuation(Real range, Real constant, Real linear, Real quadratic); 00183 00186 Real getAttenuationRange(void) const; 00187 00190 Real getAttenuationConstant(void) const; 00191 00194 Real getAttenuationLinear(void) const; 00195 00198 Real getAttenuationQuadric(void) const; 00199 00206 void setPosition(Real x, Real y, Real z); 00207 00214 void setPosition(const Vector3& vec); 00215 00220 const Vector3& getPosition(void) const; 00221 00228 void setDirection(Real x, Real y, Real z); 00229 00236 void setDirection(const Vector3& vec); 00237 00242 const Vector3& getDirection(void) const; 00243 00254 void setSpotlightRange(const Radian& innerAngle, const Radian& outerAngle, Real falloff = 1.0); 00255 00258 const Radian& getSpotlightInnerAngle(void) const; 00259 00262 const Radian& getSpotlightOuterAngle(void) const; 00263 00266 Real getSpotlightFalloff(void) const; 00267 00270 void setSpotlightInnerAngle(const Radian& val); 00271 00274 void setSpotlightOuterAngle(const Radian& val); 00275 00278 void setSpotlightFalloff(Real val); 00279 00285 void setSpotlightNearClipDistance(Real nearClip) { mSpotNearClip = nearClip; } 00286 00290 Real getSpotlightNearClipDistance() const { return mSpotNearClip; } 00291 00299 void setPowerScale(Real power); 00300 00304 Real getPowerScale(void) const; 00305 00307 void _notifyAttached(Node* parent, bool isTagPoint = false); 00308 00310 void _notifyMoved(void); 00311 00313 const AxisAlignedBox& getBoundingBox(void) const; 00314 00316 void _updateRenderQueue(RenderQueue* queue); 00317 00319 const String& getMovableType(void) const; 00320 00324 const Vector3& getDerivedPosition(bool cameraRelativeIfSet = false) const; 00325 00327 const Vector3& getDerivedDirection(void) const; 00328 00334 void setVisible(bool visible); 00335 00337 Real getBoundingRadius(void) const { return 0; /* not visible */ } 00338 00348 Vector4 getAs4DVector(bool cameraRelativeIfSet = false) const; 00349 00359 virtual const PlaneBoundedVolume& _getNearClipVolume(const Camera* const cam) const; 00360 00367 virtual const PlaneBoundedVolumeList& _getFrustumClipVolumes(const Camera* const cam) const; 00368 00370 uint32 getTypeFlags(void) const; 00371 00373 AnimableValuePtr createAnimableValue(const String& valueName); 00374 00381 void setCustomShadowCameraSetup(const ShadowCameraSetupPtr& customShadowSetup); 00382 00386 void resetCustomShadowCameraSetup(void); 00387 00389 const ShadowCameraSetupPtr& getCustomShadowCameraSetup(void) const; 00390 00392 void visitRenderables(Renderable::Visitor* visitor, 00393 bool debugRenderables = false); 00394 00403 size_t _getIndexInFrame() const { return mIndexInFrame; } 00404 void _notifyIndexInFrame(size_t i) { mIndexInFrame = i; } 00405 00421 void setShadowFarDistance(Real distance); 00424 void resetShadowFarDistance(void); 00428 Real getShadowFarDistance(void) const; 00429 Real getShadowFarDistanceSquared(void) const; 00430 00435 void setShadowNearClipDistance(Real nearClip) { mShadowNearClipDist = nearClip; } 00436 00442 Real getShadowNearClipDistance() const { return mShadowNearClipDist; } 00443 00447 Real _deriveShadowNearClipDistance(const Camera* maincam) const; 00448 00456 void setShadowFarClipDistance(Real farClip) { mShadowFarClipDist = farClip; } 00457 00463 Real getShadowFarClipDistance() const { return mShadowFarClipDist; } 00464 00468 Real _deriveShadowFarClipDistance(const Camera* maincam) const; 00469 00471 void _setCameraRelative(Camera* cam); 00472 00488 void setCustomParameter(uint16 index, const Vector4& value); 00489 00494 const Vector4& getCustomParameter(uint16 index) const; 00495 00518 virtual void _updateCustomGpuParameter(uint16 paramIndex, 00519 const GpuProgramParameters::AutoConstantEntry& constantEntry, 00520 GpuProgramParameters* params) const; 00521 protected: 00523 virtual void update(void) const; 00524 00526 const String& getAnimableDictionaryName(void) const; 00528 void initialiseAnimableDictionary(StringVector& vec) const; 00529 00530 LightTypes mLightType; 00531 Vector3 mPosition; 00532 ColourValue mDiffuse; 00533 ColourValue mSpecular; 00534 00535 Vector3 mDirection; 00536 00537 Radian mSpotOuter; 00538 Radian mSpotInner; 00539 Real mSpotFalloff; 00540 Real mSpotNearClip; 00541 Real mRange; 00542 Real mAttenuationConst; 00543 Real mAttenuationLinear; 00544 Real mAttenuationQuad; 00545 Real mPowerScale; 00546 size_t mIndexInFrame; 00547 bool mOwnShadowFarDist; 00548 Real mShadowFarDist; 00549 Real mShadowFarDistSquared; 00550 00551 Real mShadowNearClipDist; 00552 Real mShadowFarClipDist; 00553 00554 00555 mutable Vector3 mDerivedPosition; 00556 mutable Vector3 mDerivedDirection; 00557 // Slightly hacky but unless we separate observed light render state from main Light... 00558 mutable Vector3 mDerivedCamRelativePosition; 00559 mutable bool mDerivedCamRelativeDirty; 00560 Camera* mCameraToBeRelativeTo; 00561 00563 static String msMovableType; 00564 00565 mutable PlaneBoundedVolume mNearClipVolume; 00566 mutable PlaneBoundedVolumeList mFrustumClipVolumes; 00568 mutable bool mDerivedTransformDirty; 00569 00571 mutable ShadowCameraSetupPtr mCustomShadowCameraSetup; 00572 00573 typedef map<uint16, Vector4>::type CustomParameterMap; 00575 CustomParameterMap mCustomParameters; 00576 }; 00577 00579 class _OgreExport LightFactory : public MovableObjectFactory 00580 { 00581 protected: 00582 MovableObject* createInstanceImpl( const String& name, const NameValuePairList* params); 00583 public: 00584 LightFactory() {} 00585 ~LightFactory() {} 00586 00587 static String FACTORY_TYPE_NAME; 00588 00589 const String& getType(void) const; 00590 void destroyInstance( MovableObject* obj); 00591 00592 }; 00596 } // Namespace 00597 #endif
Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Fri May 25 23:36:24 2012