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__
OgreHeaderSuffix.h
Ogre::FocusedShadowCameraSetup::transformToUnitCube
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...
Ogre::FocusedShadowCameraSetup::PointListBody::getPointCount
size_t getPointCount(void) const
Returns the point count.
Ogre::FocusedShadowCameraSetup::PointListBody::mAAB
AxisAlignedBox mAAB
Definition: OgreShadowCameraSetupFocused.h:89
Ogre::FocusedShadowCameraSetup::msNormalToLightSpace
static const Matrix4 msNormalToLightSpace
Transform to or from light space as defined by Wimmer et al.
Definition: OgreShadowCameraSetupFocused.h:68
Ogre
Definition: OgreAndroidLogListener.h:35
OgrePolygon.h
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Ogre::FocusedShadowCameraSetup::PointListBody
Internal class holding a point list representation of a convex body.
Definition: OgreShadowCameraSetupFocused.h:87
Ogre::FocusedShadowCameraSetup::mPointListBodyB
PointListBody mPointListBodyB
Definition: OgreShadowCameraSetupFocused.h:146
Ogre::ShadowCameraSetup
This class allows you to plug in new ways to define the camera setup when rendering and projecting sh...
Definition: OgreShadowCameraSetup.h:69
Ogre::FocusedShadowCameraSetup::mUseAggressiveRegion
bool mUseAggressiveRegion
Use tighter focus region?
Definition: OgreShadowCameraSetupFocused.h:82
Ogre::FocusedShadowCameraSetup::setUseAggressiveFocusRegion
void setUseAggressiveFocusRegion(bool aggressive)
Sets whether or not to use the more aggressive approach to deciding on the focus region or not.
Definition: OgreShadowCameraSetupFocused.h:303
Ogre::FocusedShadowCameraSetup::PointListBody::~PointListBody
~PointListBody()
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:74
Ogre::FocusedShadowCameraSetup::calculateB
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.
OgreShadowCameraSetup.h
Ogre::FocusedShadowCameraSetup::getLSProjViewDir
Vector3 getLSProjViewDir(const Matrix4 &lightSpace, const Camera &cam, const PointListBody &bodyLVS) const
Returns the projection view direction.
Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal
static const Matrix4 msLightSpaceToNormal
Definition: OgreShadowCameraSetupFocused.h:69
Ogre::FocusedShadowCameraSetup
Implements the uniform shadow mapping algorithm in focused mode.
Definition: OgreShadowCameraSetupFocused.h:59
OgreConvexBody.h
Ogre::FocusedShadowCameraSetup::PointListBody::addPoint
void addPoint(const Vector3 &point)
Adds a specific point to the body list.
Ogre::FocusedShadowCameraSetup::PointListBody::getPoint
const Vector3 & getPoint(size_t cnt) const
Returns a point.
Ogre::FocusedShadowCameraSetup::PointListBody::mBodyPoints
Polygon::VertexList mBodyPoints
Definition: OgreShadowCameraSetupFocused.h:88
OgreHeaderPrefix.h
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
Ogre::SceneManager
Manages the organisation and rendering of a 'scene' i.e.
Definition: OgreSceneManager.h:144
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:58
OgrePrerequisites.h
Ogre::FocusedShadowCameraSetup::PointListBody::merge
void merge(const PointListBody &plb)
Merges a second PointListBody into this one.
Ogre::FocusedShadowCameraSetup::calculateLVS
void calculateLVS(const SceneManager &sm, const Camera &cam, const Light &light, const AxisAlignedBox &sceneBB, PointListBody *out_LVS) const
Calculates the bodyLVS.
Ogre::ConvexBody
Holds a solid representation of a convex body.
Definition: OgreConvexBody.h:56
Ogre::FocusedShadowCameraSetup::FocusedShadowCameraSetup
FocusedShadowCameraSetup(void)
Default constructor.
Ogre::Polygon::VertexList
vector< Vector3 >::type VertexList
Definition: OgrePolygon.h:56
Ogre::FocusedShadowCameraSetup::calculateShadowMappingMatrix
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.
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:55
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::FocusedShadowCameraSetup::PointListBody::reset
void reset(void)
Resets the body.
Ogre::FocusedShadowCameraSetup::mLightFrustumCamera
Camera * mLightFrustumCamera
Temporary preallocated camera to set up a light frustum for clipping in FocusedShadowCameraSetup::cal...
Definition: OgreShadowCameraSetupFocused.h:78
Ogre::FocusedShadowCameraSetup::PointListBody::PointListBody
PointListBody(const ConvexBody &body)
Ogre::FocusedShadowCameraSetup::getShadowCamera
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.
Ogre::Frustum
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:86
Ogre::FocusedShadowCameraSetup::buildViewMatrix
Matrix4 buildViewMatrix(const Vector3 &pos, const Vector3 &dir, const Vector3 &up) const
Builds a view matrix.
Ogre::FocusedShadowCameraSetup::mTempFrustum
Frustum * mTempFrustum
Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
Definition: OgreShadowCameraSetupFocused.h:74
Ogre::FocusedShadowCameraSetup::getNearCameraPoint_ws
Vector3 getNearCameraPoint_ws(const Matrix4 &viewMatrix, const PointListBody &bodyLVS) const
Returns a valid near-point seen by the camera.
Ogre::FocusedShadowCameraSetup::PointListBody::PointListBody
PointListBody()
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated
bool mLightFrustumCameraCalculated
Definition: OgreShadowCameraSetupFocused.h:79
Ogre::FocusedShadowCameraSetup::PointListBody::addAAB
void addAAB(const AxisAlignedBox &aab)
Adds all points of an AAB.
Ogre::FocusedShadowCameraSetup::PointListBody::getAAB
const AxisAlignedBox & getAAB(void) const
Returns the bounding box representation.
Ogre::FocusedShadowCameraSetup::mPointListBodyLVS
PointListBody mPointListBodyLVS
Definition: OgreShadowCameraSetupFocused.h:147
Ogre::FocusedShadowCameraSetup::PointListBody::build
void build(const ConvexBody &body, bool filterDuplicates=true)
Builds a point list body from a 'real' body.
Ogre::FocusedShadowCameraSetup::~FocusedShadowCameraSetup
virtual ~FocusedShadowCameraSetup(void)
Default destructor.
Ogre::FocusedShadowCameraSetup::mBodyB
ConvexBody mBodyB
Definition: OgreShadowCameraSetupFocused.h:145
Ogre::FocusedShadowCameraSetup::getUseAggressiveFocusRegion
bool getUseAggressiveFocusRegion() const
Definition: OgreShadowCameraSetupFocused.h:305
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:52
Ogre::FocusedShadowCameraSetup::PointListBody::buildAndIncludeDirection
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.

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