OgreShadowCameraSetupFocused.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Copyright (c) 2006 Matthias Fink, netAllied GmbH <matthias.fink@web.de>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ShadowCameraSetupFocused_H__
#define __ShadowCameraSetupFocused_H__
#include "OgrePrerequisites.h"
#include "OgreShadowCameraSetup.h"
#include "OgrePolygon.h"
#include "OgreConvexBody.h"
#include "OgreHeaderPrefix.h"
namespace Ogre {
class ConvexBody;
class _OgreExport FocusedShadowCameraSetup : public ShadowCameraSetup
{
protected:
static const Matrix4 msNormalToLightSpace;
static const Matrix4 msLightSpaceToNormal;
Frustum* mTempFrustum;
Camera* mLightFrustumCamera;
mutable bool mLightFrustumCameraCalculated;
bool mUseAggressiveRegion;
class _OgreExport PointListBody
{
Polygon::VertexList mBodyPoints;
AxisAlignedBox mAAB;
public:
PointListBody();
PointListBody(const ConvexBody& body);
~PointListBody();
void merge(const PointListBody& plb);
void build(const ConvexBody& body, bool filterDuplicates = true);
void buildAndIncludeDirection(const ConvexBody& body,
Real extrudeDist, const Vector3& dir);
const AxisAlignedBox& getAAB(void) const;
void addPoint(const Vector3& point);
void addAAB(const AxisAlignedBox& aab);
const Vector3& getPoint(size_t cnt) const;
size_t getPointCount(void) const;
void reset(void);
};
// Persistent calculations to prevent reallocation
mutable ConvexBody mBodyB;
mutable PointListBody mPointListBodyB;
mutable PointListBody mPointListBodyLVS;
protected:
void calculateShadowMappingMatrix(const SceneManager& sm, const Camera& cam,
const Light& light, Matrix4 *out_view,
Matrix4 *out_proj, Camera *out_cam) const;
void calculateB(const SceneManager& sm, const Camera& cam, const Light& light,
const AxisAlignedBox& sceneBB, const AxisAlignedBox& receiverBB, PointListBody *out_bodyB) const;
void calculateLVS(const SceneManager& sm, const Camera& cam, const Light& light,
const AxisAlignedBox& sceneBB, PointListBody *out_LVS) const;
Vector3 getLSProjViewDir(const Matrix4& lightSpace, const Camera& cam,
const PointListBody& bodyLVS) const;
Vector3 getNearCameraPoint_ws(const Matrix4& viewMatrix,
const PointListBody& bodyLVS) const;
Matrix4 transformToUnitCube(const Matrix4& m, const PointListBody& body) const;
Matrix4 buildViewMatrix(const Vector3& pos, const Vector3& dir, const Vector3& up) const;
public:
FocusedShadowCameraSetup(void);
virtual ~FocusedShadowCameraSetup(void);
virtual void getShadowCamera(const SceneManager *sm, const Camera *cam,
const Viewport *vp, const Light *light, Camera *texCam, size_t iteration) const;
void setUseAggressiveFocusRegion(bool aggressive) { mUseAggressiveRegion = aggressive; }
bool getUseAggressiveFocusRegion() const { return mUseAggressiveRegion; }
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // __ShadowCameraSetupFocused_H__
Ogre::FocusedShadowCameraSetup::getUseAggressiveFocusRegion
bool getUseAggressiveFocusRegion() const
Definition: OgreShadowCameraSetupFocused.h:305
Ogre::FocusedShadowCameraSetup::mPointListBodyB
PointListBody mPointListBodyB
Definition: OgreShadowCameraSetupFocused.h:146
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
OgreConvexBody.h
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
OgrePolygon.h
Ogre::FocusedShadowCameraSetup::msLightSpaceToNormal
static const Matrix4 msLightSpaceToNormal
Definition: OgreShadowCameraSetupFocused.h:69
Ogre::FocusedShadowCameraSetup::mLightFrustumCamera
Camera * mLightFrustumCamera
Temporary preallocated camera to set up a light frustum for clipping in FocusedShadowCameraSetup::cal...
Definition: OgreShadowCameraSetupFocused.h:78
Ogre::Viewport
An abstraction of a viewport, i.e.
Definition: OgreViewport.h:57
Ogre::FocusedShadowCameraSetup::mBodyB
ConvexBody mBodyB
Definition: OgreShadowCameraSetupFocused.h:145
Ogre::FocusedShadowCameraSetup::PointListBody::mAAB
AxisAlignedBox mAAB
Definition: OgreShadowCameraSetupFocused.h:89
Ogre::Matrix4
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
Ogre::Vector3
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
OgrePrerequisites.h
Ogre::Polygon::VertexList
vector< Vector3 >::type VertexList
Definition: OgrePolygon.h:56
Ogre::FocusedShadowCameraSetup::mTempFrustum
Frustum * mTempFrustum
Temporary preallocated frustum to set up a projection matrix in calculateShadowMappingMatrix().
Definition: OgreShadowCameraSetupFocused.h:74
Ogre::FocusedShadowCameraSetup::mPointListBodyLVS
PointListBody mPointListBodyLVS
Definition: OgreShadowCameraSetupFocused.h:147
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::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::ShadowCameraSetup
This class allows you to plug in new ways to define the camera setup when rendering and projecting sh...
Definition: OgreShadowCameraSetup.h:68
Ogre::ConvexBody
Holds a solid representation of a convex body.
Definition: OgreConvexBody.h:55
Ogre
Definition: OgreAndroidLogListener.h:34
OgreShadowCameraSetup.h
OgreHeaderPrefix.h
Ogre::FocusedShadowCameraSetup
Implements the uniform shadow mapping algorithm in focused mode.
Definition: OgreShadowCameraSetupFocused.h:58
Ogre::FocusedShadowCameraSetup::msNormalToLightSpace
static const Matrix4 msNormalToLightSpace
Transform to or from light space as defined by Wimmer et al.
Definition: OgreShadowCameraSetupFocused.h:68
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:85
Ogre::AxisAlignedBox
A 3D box aligned with the x/y/z axes.
Definition: OgreAxisAlignedBox.h:54
Ogre::SceneManager
Manages the organisation and rendering of a &#39;scene&#39; i.e.
Definition: OgreSceneManager.h:143
Ogre::FocusedShadowCameraSetup::PointListBody
Internal class holding a point list representation of a convex body.
Definition: OgreShadowCameraSetupFocused.h:86
Ogre::FocusedShadowCameraSetup::mLightFrustumCameraCalculated
bool mLightFrustumCameraCalculated
Definition: OgreShadowCameraSetupFocused.h:79
Ogre::FocusedShadowCameraSetup::mUseAggressiveRegion
bool mUseAggressiveRegion
Use tighter focus region?
Definition: OgreShadowCameraSetupFocused.h:82
Ogre::Light
Representation of a dynamic light source in the scene.
Definition: OgreLight.h:73
Ogre::FocusedShadowCameraSetup::PointListBody::mBodyPoints
Polygon::VertexList mBodyPoints
Definition: OgreShadowCameraSetupFocused.h:88

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