# 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, public ShadowDataAlloc
    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         Real getSquaredViewDepth(const Camera*) 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;
    00114         virtual bool hasEdgeList(void) = 0;
    00115
    00117         virtual const AxisAlignedBox& getWorldBoundingBox(bool derive = false) const = 0;
    00119         virtual const AxisAlignedBox& getLightCapBounds(void) const = 0;
    00121         virtual const AxisAlignedBox& getDarkCapBounds(const Light& light, Real dirLightExtrusionDist) const = 0;
    00122
    00123         typedef std::vector<ShadowRenderable*> ShadowRenderableList;
    00124         typedef VectorIterator<ShadowRenderableList> ShadowRenderableListIterator;
    00125
    00141         virtual ShadowRenderableListIterator getShadowVolumeRenderableIterator(
    00142             ShadowTechnique shadowTechnique, const Light* light,
    00143             HardwareIndexBufferSharedPtr* indexBuffer,
    00144             bool extrudeVertices, Real extrusionDistance, unsigned long flags = 0 ) = 0;
    00145
    00165         static void extrudeVertices(const HardwareVertexBufferSharedPtr& vertexBuffer,
    00166             size_t originalVertexCount, const Vector4& lightPos, Real extrudeDist);
    00168         virtual Real getPointExtrusionDistance(const Light* l) const = 0;
    00169     protected:
    00171         Real getExtrusionDistance(const Vector3& objectPos, const Light* light) const;
    00179         virtual void updateEdgeListLightFacing(EdgeData* edgeData,
    00180             const Vector4& lightPos);
    00181
    00195         virtual void generateShadowVolume(EdgeData* edgeData,
    00196             const HardwareIndexBufferSharedPtr& indexBuffer, const Light* light,
    00197             ShadowRenderableList& shadowRenderables, unsigned long flags);
    00204         virtual void extrudeBounds(AxisAlignedBox& box, const Vector4& lightPos,
    00205             Real extrudeDist) const;
    00206
    00207
    00208     };
    00209 }
    00210
    00211 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sat Apr 11 13:46:43 2009