Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreShadowCaster.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-2005 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         MaterialPtr 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(MaterialPtr& mat) { mMaterial = mat; }
00057         const MaterialPtr& 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;
00082         bool isLightCapSeparate(void) const { return mLightCap != 0; }
00083 
00085         ShadowRenderable* getLightCapRenderable(void) { return mLightCap; }
00087         virtual bool isVisible(void) const { return true; }
00088 
00089     };
00090 
00092     enum ShadowRenderableFlags
00093     {
00095         SRF_INCLUDE_LIGHT_CAP = 0x00000001,
00097         SRF_INCLUDE_DARK_CAP  = 0x00000002,
00099         SRF_EXTRUDE_TO_INFINITY  = 0x00000004
00100     };
00101 
00104     class _OgreExport ShadowCaster
00105     {
00106     public:
00107         virtual ~ShadowCaster() { }
00109         virtual bool getCastShadows(void) const = 0;
00110 
00112         virtual EdgeData* getEdgeList(void) = 0;
00113 
00115         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0;
00117         virtual const AxisAlignedBox& getLightCapBounds(void) const = 0;
00119         virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0;
00120 
00121         typedef std::vector<ShadowRenderable*> ShadowRenderableList;
00122         typedef VectorIterator<ShadowRenderableList> ShadowRenderableListIterator;
00123 
00139         virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00140             ShadowTechnique shadowTechnique, const Light* light, 
00141             HardwareIndexBufferSharedPtr* indexBuffer, 
00142             bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
00143 
00163         static void extrudeVertices(HardwareVertexBufferSharedPtr vertexBuffer, 
00164             size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
00166         virtual Real getPointExtrusionDistance(const Light* l) const = 0;
00167     protected:
00169         Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
00177         virtual void updateEdgeListLightFacing(EdgeData* edgeData, 
00178             const Vector4& lightPos);
00179 
00193         virtual void generateShadowVolume(EdgeData* edgeData, 
00194             HardwareIndexBufferSharedPtr indexBuffer, const Light* light,
00195             ShadowRenderableList& shadowRenderables, unsigned long flags);
00202         virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos, 
00203             Real extrudeDist) const;
00204 
00205 
00206     };
00207 }
00208 
00209 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:49 2006