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-2013 Torus Knot Software Ltd 00008 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de> 00009 00010 Permission is hereby granted, free of charge, to any person obtaining a copy 00011 of this software and associated documentation files (the "Software"), to deal 00012 in the Software without restriction, including without limitation the rights 00013 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00014 copies of the Software, and to permit persons to whom the Software is 00015 furnished to do so, subject to the following conditions: 00016 00017 The above copyright notice and this permission notice shall be included in 00018 all copies or substantial portions of the Software. 00019 00020 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00023 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00026 THE SOFTWARE. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __ShadowCameraSetupFocused_H__ 00030 #define __ShadowCameraSetupFocused_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 #include "OgreShadowCameraSetup.h" 00034 #include "OgrePolygon.h" 00035 #include "OgreConvexBody.h" 00036 #include "OgreHeaderPrefix.h" 00037 00038 00039 namespace Ogre { 00040 00041 class ConvexBody; 00042 00058 class _OgreExport FocusedShadowCameraSetup : public ShadowCameraSetup 00059 { 00060 protected: 00068 static const Matrix4 msNormalToLightSpace; 00069 static const Matrix4 msLightSpaceToNormal; 00070 00074 Frustum* mTempFrustum; 00075 00078 Camera* mLightFrustumCamera; 00079 mutable bool mLightFrustumCameraCalculated; 00080 00082 bool mUseAggressiveRegion; 00083 00086 class _OgreExport PointListBody 00087 { 00088 Polygon::VertexList mBodyPoints; 00089 AxisAlignedBox mAAB; 00090 00091 public: 00092 PointListBody(); 00093 PointListBody(const ConvexBody& body); 00094 ~PointListBody(); 00095 00098 void merge(const PointListBody& plb); 00099 00104 void build(const ConvexBody& body, bool filterDuplicates = true); 00105 00115 void buildAndIncludeDirection(const ConvexBody& body, 00116 Real extrudeDist, const Vector3& dir); 00117 00120 const AxisAlignedBox& getAAB(void) const; 00121 00124 void addPoint(const Vector3& point); 00125 00128 void addAAB(const AxisAlignedBox& aab); 00129 00132 const Vector3& getPoint(size_t cnt) const; 00133 00136 size_t getPointCount(void) const; 00137 00140 void reset(void); 00141 00142 }; 00143 00144 // Persistent calculations to prevent reallocation 00145 mutable ConvexBody mBodyB; 00146 mutable PointListBody mPointListBodyB; 00147 mutable PointListBody mPointListBodyLVS; 00148 00149 protected: 00170 void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam, 00171 const Light& light, Matrix4 *out_view, 00172 Matrix4 *out_proj, Camera *out_cam) const; 00173 00199 void calculateB(const SceneManager& sm, const Camera& cam, const Light& light, 00200 const AxisAlignedBox& sceneBB, const AxisAlignedBox& receiverBB, PointListBody *out_bodyB) const; 00201 00220 void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light, 00221 const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const; 00222 00235 Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam, 00236 const PointListBody& bodyLVS) const; 00237 00249 Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix, 00250 const PointListBody& bodyLVS) const; 00251 00263 Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const; 00264 00269 Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const; 00270 00271 public: 00276 FocusedShadowCameraSetup(void); 00277 00282 virtual ~FocusedShadowCameraSetup(void); 00283 00286 virtual void getShadowCamera(const SceneManager *sm, const Camera *cam, 00287 const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const; 00288 00303 void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; } 00304 00305 bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; } 00306 00307 }; 00308 00312 } // namespace Ogre 00313 00314 #include "OgreHeaderSuffix.h" 00315 00316 #endif // __ShadowCameraSetupFocused_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:47