OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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-2013 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 #include "OgreHeaderPrefix.h"
37 
38 
39 namespace Ogre {
40 
41  class ConvexBody;
42 
59  {
60  protected:
70 
75 
80 
83 
87  {
90 
91  public:
92  PointListBody();
93  PointListBody(const ConvexBody& body);
94  ~PointListBody();
95 
98  void merge(const PointListBody& plb);
99 
104  void build(const ConvexBody& body, bool filterDuplicates = true);
105 
115  void buildAndIncludeDirection(const ConvexBody& body,
116  Real extrudeDist, const Vector3& dir);
117 
120  const AxisAlignedBox& getAAB(void) const;
121 
124  void addPoint(const Vector3& point);
125 
128  void addAAB(const AxisAlignedBox& aab);
129 
132  const Vector3& getPoint(size_t cnt) const;
133 
136  size_t getPointCount(void) const;
137 
140  void reset(void);
141 
142  };
143 
144  // Persistent calculations to prevent reallocation
148 
149  protected:
164  void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam,
165  const Light& light, Matrix4 *out_view,
166  Matrix4 *out_proj, Camera *out_cam) const;
167 
187  void calculateB(const SceneManager& sm, const Camera& cam, const Light& light,
188  const AxisAlignedBox& sceneBB, const AxisAlignedBox& receiverBB, PointListBody *out_bodyB) const;
189 
204  void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light,
205  const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const;
206 
216  Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam,
217  const PointListBody& bodyLVS) const;
218 
228  Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix,
229  const PointListBody& bodyLVS) const;
230 
240  Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const;
241 
246  Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const;
247 
248  public:
254 
259  virtual ~FocusedShadowCameraSetup(void);
260 
263  virtual void getShadowCamera(const SceneManager *sm, const Camera *cam,
264  const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const;
265 
279  void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; }
280 
281  bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; }
282 
283  };
284 
288 }
289 
290 #include "OgreHeaderSuffix.h"
291 
292 #endif
bool mUseAggressiveRegion
Use tighter focus region?
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:233
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:85
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:73
vector< Vector3 >::type VertexList
Definition: OgrePolygon.h:56
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.