OGRE  1.9.0
OgreShadowCameraSetupFocused.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE.
27-----------------------------------------------------------------------------
28*/
29#ifndef __ShadowCameraSetupFocused_H__
30#define __ShadowCameraSetupFocused_H__
31
32#include "OgrePrerequisites.h"
34#include "OgrePolygon.h"
35#include "OgreConvexBody.h"
36#include "OgreHeaderPrefix.h"
37
38
39namespace Ogre {
40
41 class ConvexBody;
42
59 {
60 protected:
70
75
80
83
87 {
90
91 public:
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:
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:260
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.
const Vector3 & getPoint(size_t cnt) const
Returns a point.
void addPoint(const Vector3 &point)
Adds a specific point to the body list.
const AxisAlignedBox & getAAB(void) const
Returns the bounding box representation.
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.