Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | 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-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 __ShadowCaster_H__
00030 #define __ShadowCaster_H__
00031 
00032 #include "OgrePrerequisites.h"
00033 #include "OgreRenderable.h"
00034 
00035 
00036 namespace Ogre {
00037 
00038 
00047     class _OgreExport ShadowRenderable : public Renderable
00048     {
00049     protected:
00050         MaterialPtr mMaterial;
00051         RenderOperation mRenderOp;
00052         ShadowRenderable* mLightCap; // used only if isLightCapSeparate == true
00053     public:
00054         ShadowRenderable() : mMaterial(), mLightCap(0) {}
00055         virtual ~ShadowRenderable() { delete mLightCap; }
00059         void setMaterial(const MaterialPtr& mat) { mMaterial = mat; }
00061         const MaterialPtr& getMaterial(void) const { return mMaterial; }
00063         void getRenderOperation(RenderOperation& op) { op = mRenderOp; }
00065         RenderOperation* getRenderOperationForUpdate(void) {return &mRenderOp;}
00067         void getWorldTransforms(Matrix4* xform) const = 0;
00069         const Quaternion& getWorldOrientation(void) const = 0;
00071         const Vector3& getWorldPosition(void) const = 0;
00073         Real getSquaredViewDepth(const Camera*) const{ return 0; /* not used */}
00075         const LightList& getLights(void) const;
00086         bool isLightCapSeparate(void) const { return mLightCap != 0; }
00087 
00089         ShadowRenderable* getLightCapRenderable(void) { return mLightCap; }
00091         virtual bool isVisible(void) const { return true; }
00092 
00093     };
00094 
00096     enum ShadowRenderableFlags
00097     {
00099         SRF_INCLUDE_LIGHT_CAP = 0x00000001,
00101         SRF_INCLUDE_DARK_CAP  = 0x00000002,
00103         SRF_EXTRUDE_TO_INFINITY  = 0x00000004
00104     };
00105 
00108     class _OgreExport ShadowCaster
00109     {
00110     public:
00111         virtual ~ShadowCaster() { }
00113         virtual bool getCastShadows(void) const = 0;
00114 
00116         virtual EdgeData* getEdgeList(void) = 0;
00118         virtual bool hasEdgeList(void) = 0;
00119 
00121         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0;
00123         virtual const AxisAlignedBox& getLightCapBounds(void) const = 0;
00125         virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0;
00126 
00127         typedef std::vector<ShadowRenderable*> ShadowRenderableList;
00128         typedef VectorIterator<ShadowRenderableList> ShadowRenderableListIterator;
00129 
00145         virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(
00146             ShadowTechnique shadowTechnique, const Light* light, 
00147             HardwareIndexBufferSharedPtr* indexBuffer, 
00148             bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
00149 
00169         static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer, 
00170             size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
00172         virtual Real getPointExtrusionDistance(const Light* l) const = 0;
00173     protected:
00175         Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
00183         virtual void updateEdgeListLightFacing(EdgeData* edgeData, 
00184             const Vector4& lightPos);
00185 
00199         virtual void generateShadowVolume(EdgeData* edgeData, 
00200             const HardwareIndexBufferSharedPtr& indexBuffer, const Light* light,
00201             ShadowRenderableList& shadowRenderables, unsigned long flags);
00208         virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos, 
00209             Real extrudeDist) const;
00210 
00211 
00212     };
00213 }
00214 
00215 #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 25 13:03:16 2007