OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreShadowCameraSetupFocused.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2011 Torus Knot Software Ltd
8 Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
9 
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16 
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19 
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 THE SOFTWARE.
27 -----------------------------------------------------------------------------
28 */
29 #ifndef __ShadowCameraSetupFocused_H__
30 #define __ShadowCameraSetupFocused_H__
31 
32 #include "OgrePrerequisites.h"
33 #include "OgreShadowCameraSetup.h"
34 #include "OgrePolygon.h"
35 #include "OgreConvexBody.h"
36 
37 
38 namespace Ogre {
39 
40  class ConvexBody;
41 
58  {
59  protected:
69 
74 
79 
82 
86  {
89 
90  public:
91  PointListBody();
92  PointListBody(const ConvexBody& body);
93  ~PointListBody();
94 
97  void merge(const PointListBody& plb);
98 
103  void build(const ConvexBody& body, bool filterDuplicates = true);
104 
114  void buildAndIncludeDirection(const ConvexBody& body,
115  Real extrudeDist, const Vector3& dir);
116 
119  const AxisAlignedBox& getAAB(void) const;
120 
123  void addPoint(const Vector3& point);
124 
127  void addAAB(const AxisAlignedBox& aab);
128 
131  const Vector3& getPoint(size_t cnt) const;
132 
135  size_t getPointCount(void) const;
136 
139  void reset(void);
140 
141  };
142 
143  // Persistent calculations to prevent reallocation
147 
148  protected:
163  void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam,
164  const Light& light, Matrix4 *out_view,
165  Matrix4 *out_proj, Camera *out_cam) const;
166 
186  void calculateB(const SceneManager& sm, const Camera& cam, const Light& light,
187  const AxisAlignedBox& sceneBB, const AxisAlignedBox& receiverBB, PointListBody *out_bodyB) const;
188 
203  void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light,
204  const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const;
205 
215  Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam,
216  const PointListBody& bodyLVS) const;
217 
227  Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix,
228  const PointListBody& bodyLVS) const;
229 
239  Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const;
240 
245  Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const;
246 
247  public:
253 
258  virtual ~FocusedShadowCameraSetup(void);
259 
262  virtual void getShadowCamera(const SceneManager *sm, const Camera *cam,
263  const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const;
264 
278  void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; }
279 
280  bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; }
281 
282  };
283 
287 }
288 
289 #endif
bool mUseAggressiveRegion
Use tighter focus region?
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:85
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:203
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:84
Manages the organisation and rendering of a 'scene' i.e.
Holds a solid representation of a convex body.
A 3D box aligned with the x/y/z axes.
Camera * mLightFrustumCamera
Temporary preallocated camera to set up a light frustum for clipping in ::calculateB.
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:72
vector< Vector3 >::type VertexList
Definition: OgrePolygon.h:55
This class allows you to plug in new ways to define the camera setup when rendering and projecting sh...
static const Matrix4 msNormalToLightSpace
Transform to or from light space as defined by Wimmer et al.
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
Internal class holding a point list representation of a convex body.
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:56
Frustum * mTempFrustum
Temporary preallocated frustum to set up a projection matrix in ::calculateShadowMappingMatrix() ...
void setUseAggressiveFocusRegion(bool aggressive)
Sets whether or not to use the more aggressive approach to deciding on the focus region or not...
Implements the uniform shadow mapping algorithm in focused mode.