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 © 2000-2004 The OGRE Team 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 */ 00025 #ifndef __ShadowCaster_H__ 00026 #define __ShadowCaster_H__ 00027 00028 #include "OgrePrerequisites.h" 00029 #include "OgreRenderable.h" 00030 00031 00032 namespace Ogre { 00033 00034 00043 class _OgreExport ShadowRenderable : public Renderable 00044 { 00045 protected: 00046 Material* mMaterial; 00047 RenderOperation mRenderOp; 00048 ShadowRenderable* mLightCap; // used only if isLightCapSeparate == true 00049 public: 00050 ShadowRenderable() : mMaterial(0), mLightCap(0) {} 00051 virtual ~ShadowRenderable() { delete mLightCap; } 00055 void setMaterial(Material* mat) { mMaterial = mat; } 00057 Material* getMaterial(void) const { return mMaterial; } 00059 void getRenderOperation(RenderOperation& op) { op = mRenderOp; } 00061 RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;} 00063 void getWorldTransforms(Matrix4* xform) const = 0; 00065 const Quaternion& getWorldOrientation(void) const = 0; 00067 const Vector3& getWorldPosition(void) const = 0; 00069 Real getSquaredViewDepth(const Camera* cam) const{ return 0; /* not used */} 00071 const LightList& getLights(void) const 00072 { 00073 // return empty 00074 static LightList ll; 00075 return ll; 00076 } 00087 bool isLightCapSeparate(void) const { return mLightCap != 0; } 00088 00090 ShadowRenderable* getLightCapRenderable(void) { return mLightCap; } 00092 virtual bool isVisible(void) const { return true; } 00093 00094 }; 00095 00097 enum ShadowRenderableFlags 00098 { 00100 SRF_INCLUDE_LIGHT_CAP = 0x00000001, 00102 SRF_INCLUDE_DARK_CAP = 0x00000002, 00104 SRF_EXTRUDE_TO_INFINITY = 0x00000004 00105 }; 00106 00109 class _OgreExport ShadowCaster 00110 { 00111 public: 00113 virtual bool getCastShadows(void) const = 0; 00114 00116 virtual EdgeData* getEdgeList(void) = 0; 00117 00119 virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0; 00121 virtual const AxisAlignedBox& getLightCapBounds(void) const = 0; 00123 virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0; 00124 00125 typedef std::vector<ShadowRenderable*> ShadowRenderableList; 00126 typedef VectorIterator<ShadowRenderableList> ShadowRenderableListIterator; 00127 00143 virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator( 00144 ShadowTechnique shadowTechnique, const Light* light, 00145 HardwareIndexBufferSharedPtr* indexBuffer, 00146 bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0; 00147 00167 static void extrudeVertices(HardwareVertexBufferSharedPtr vertexBuffer, 00168 size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist); 00170 virtual Real getPointExtrusionDistance(const Light* l) const = 0; 00171 protected: 00173 Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const; 00181 virtual void updateEdgeListLightFacing(EdgeData* edgeData, 00182 const Vector4& lightPos); 00183 00197 virtual void generateShadowVolume(EdgeData* edgeData, 00198 HardwareIndexBufferSharedPtr indexBuffer, const Light* light, 00199 ShadowRenderableList& shadowRenderables, unsigned long flags); 00206 virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos, 00207 Real extrudeDist) const; 00208 00209 00210 }; 00211 } 00212 00213 #endif
Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:47 2004