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

# OgreShadowCameraSetupFocused.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) 2006 Torus Knot Software Ltd
    00008 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
    00009 Also see acknowledgements in Readme.html
    00010
    00011 This program is free software; you can redistribute it and/or modify it under
    00012 the terms of the GNU Lesser General Public License as published by the Free Software
    00013 Foundation; either version 2 of the License, or (at your option) any later
    00014 version.
    00015
    00016 This program is distributed in the hope that it will be useful, but WITHOUT
    00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00019
    00020 You should have received a copy of the GNU Lesser General Public License along with
    00021 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00023 http://www.gnu.org/copyleft/lesser.txt.
    00024
    00025 You may alternatively use this source under the terms of a specific version of
    00026 the OGRE Unrestricted License provided you have obtained such a license from
    00027 Torus Knot Software Ltd.
    00028 -----------------------------------------------------------------------------
    00029 */
    00030 #ifndef __ShadowCameraSetupFocused_H__
    00031 #define __ShadowCameraSetupFocused_H__
    00032
    00033 #include "OgrePrerequisites.h"
    00034 #include "OgreShadowCameraSetup.h"
    00035 #include "OgrePolygon.h"
    00036 #include "OgreConvexBody.h"
    00037
    00038
    00039 namespace Ogre {
    00040
    00041     class ConvexBody;
    00042
    00052     class _OgreExport FocusedShadowCameraSetup : public ShadowCameraSetup
    00053     {
    00054     protected:
    00062         static const Matrix4 msNormalToLightSpace;
    00063         static const Matrix4 msLightSpaceToNormal;
    00064
    00068         Frustum* mTempFrustum;
    00069
    00072         Camera* mLightFrustumCamera;
    00073         mutable bool mLightFrustumCameraCalculated;
    00074
    00076         bool mUseAggressiveRegion;
    00077
    00080         class _OgreExport PointListBody
    00081         {
    00082             Polygon::VertexList mBodyPoints;
    00083             AxisAlignedBox      mAAB;
    00084
    00085         public:
    00086             PointListBody();
    00087             PointListBody(const ConvexBody& body);
    00088             ~PointListBody();
    00089
    00092             void merge(const PointListBody& plb);
    00093
    00098             void build(const ConvexBody& body, bool filterDuplicates = true);
    00099
    00109             void buildAndIncludeDirection(const ConvexBody& body,
    00110                 const AxisAlignedBox& aabMax, const Vector3& dir);
    00111
    00114             const AxisAlignedBox& getAAB(void) const;
    00115
    00118             void addPoint(const Vector3& point);
    00119
    00122             void addAAB(const AxisAlignedBox& aab);
    00123
    00126             const Vector3& getPoint(size_t cnt) const;
    00127
    00130             size_t getPointCount(void) const;
    00131
    00134             void reset(void);
    00135
    00136         };
    00137
    00138         // Persistent calculations to prevent reallocation
    00139         mutable ConvexBody mBodyB;
    00140         mutable PointListBody mPointListBodyB;
    00141         mutable PointListBody mPointListBodyLVS;
    00142
    00143     protected:
    00158         void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam,
    00159             const Light& light, Matrix4 *out_view,
    00160             Matrix4 *out_proj, Camera *out_cam) const;
    00161
    00180         void calculateB(const SceneManager& sm, const Camera& cam, const Light& light,
    00181             const AxisAlignedBox& sceneBB, PointListBody *out_bodyB) const;
    00182
    00197         void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light,
    00198             const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const;
    00199
    00209         Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam,
    00210             const PointListBody& bodyLVS) const;
    00211
    00221         Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix,
    00222             const PointListBody& bodyLVS) const;
    00223
    00233         Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const;
    00234
    00239         Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const;
    00240
    00241     public:
    00246         FocusedShadowCameraSetup(void);
    00247
    00252         virtual ~FocusedShadowCameraSetup(void);
    00253
    00256         virtual void getShadowCamera(const SceneManager *sm, const Camera *cam,
    00257             const Viewport *vp, const Light *light, Camera *texCam) const;
    00258
    00272         void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; }
    00273
    00274         bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; }
    00275
    00276     };
    00277
    00278
    00279 }
    00280
    00281 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:26 2008