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:
93  PointListBody(const ConvexBody& body);
95 
98  void merge(const PointListBody& plb);
99 
104  void build(const ConvexBody& body, bool filterDuplicates = true);
105 
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:
170  void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam,
171  const Light& light, Matrix4 *out_view,
172  Matrix4 *out_proj, Camera *out_cam) const;
173 
199  void calculateB(const SceneManager& sm, const Camera& cam, const Light& light,
200  const AxisAlignedBox& sceneBB, const AxisAlignedBox& receiverBB, PointListBody *out_bodyB) const;
201 
220  void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light,
221  const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const;
222 
235  Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam,
236  const PointListBody& bodyLVS) const;
237 
250  const PointListBody& bodyLVS) const;
251 
263  Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const;
264 
269  Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const;
270 
271  public:
277 
283 
286  virtual void getShadowCamera(const SceneManager *sm, const Camera *cam,
287  const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const;
288 
303  void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; }
304 
305  bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; }
306 
307  };
308 
312 } // namespace Ogre
313 
314 #include "OgreHeaderSuffix.h"
315 
316 #endif // __ShadowCameraSetupFocused_H__
#define _OgreExport
Definition: OgrePlatform.h:257
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Holds a solid representation of a convex body.
Internal class holding a point list representation of a convex body.
size_t getPointCount(void) const
Returns the point count.
void merge(const PointListBody &plb)
Merges a second PointListBody into this one.
void buildAndIncludeDirection(const ConvexBody &body, Real extrudeDist, const Vector3 &dir)
Builds a PointListBody from a Body and includes all the space in a given direction.
void addPoint(const Vector3 &point)
Adds a specific point to the body list.
const AxisAlignedBox & getAAB(void) const
Returns the bounding box representation.
const Vector3 & getPoint(size_t cnt) const
Returns a point.
void build(const ConvexBody &body, bool filterDuplicates=true)
Builds a point list body from a 'real' body.
void addAAB(const AxisAlignedBox &aab)
Adds all points of an AAB.
Implements the uniform shadow mapping algorithm in focused mode.
virtual void getShadowCamera(const SceneManager *sm, const Camera *cam, const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const
Returns a uniform shadow camera with a focused view.
Frustum * mTempFrustum
Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
Camera * mLightFrustumCamera
Temporary preallocated camera to set up a light frustum for clipping in FocusedShadowCameraSetup::cal...
static const Matrix4 msNormalToLightSpace
Transform to or from light space as defined by Wimmer et al.
Vector3 getLSProjViewDir(const Matrix4 &lightSpace, const Camera &cam, const PointListBody &bodyLVS) const
Returns the projection view direction.
Matrix4 transformToUnitCube(const Matrix4 &m, const PointListBody &body) const
Transforms a given body to the unit cube (-1,-1,-1) / (+1,+1,+1) with a specific shadow matrix enable...
void calculateShadowMappingMatrix(const SceneManager &sm, const Camera &cam, const Light &light, Matrix4 *out_view, Matrix4 *out_proj, Camera *out_cam) const
Calculates the standard shadow mapping matrix.
virtual ~FocusedShadowCameraSetup(void)
Default destructor.
bool mUseAggressiveRegion
Use tighter focus region?
Vector3 getNearCameraPoint_ws(const Matrix4 &viewMatrix, const PointListBody &bodyLVS) const
Returns a valid near-point seen by the camera.
void calculateB(const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, const AxisAlignedBox &receiverBB, PointListBody *out_bodyB) const
Calculates the intersection bodyB.
FocusedShadowCameraSetup(void)
Default constructor.
void setUseAggressiveFocusRegion(bool aggressive)
Sets whether or not to use the more aggressive approach to deciding on the focus region or not.
Matrix4 buildViewMatrix(const Vector3 &pos, const Vector3 &dir, const Vector3 &up) const
Builds a view matrix.
void calculateLVS(const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, PointListBody *out_LVS) const
Calculates the bodyLVS.
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:86
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:74
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
vector< Vector3 >::type VertexList
Definition: OgrePolygon.h:56
Manages the organisation and rendering of a 'scene' i.e.
This class allows you to plug in new ways to define the camera setup when rendering and projecting sh...
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:58
float Real
Software floating point type.

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.