OgreFrustum.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
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 __Frustum_H__
#define __Frustum_H__
#include "OgrePrerequisites.h"
#include "OgreMovableObject.h"
#include "OgreRenderable.h"
#include "OgreAxisAlignedBox.h"
#include "OgreVertexIndexData.h"
#include "OgreMovablePlane.h"
#include "OgreHeaderPrefix.h"
namespace Ogre
{
enum OrientationMode
{
OR_DEGREE_0 = 0,
OR_DEGREE_90 = 1,
OR_DEGREE_180 = 2,
OR_DEGREE_270 = 3,
OR_PORTRAIT = OR_DEGREE_0,
OR_LANDSCAPERIGHT = OR_DEGREE_90,
OR_LANDSCAPELEFT = OR_DEGREE_270
};
enum ProjectionType
{
PT_ORTHOGRAPHIC,
PT_PERSPECTIVE
};
enum FrustumPlane
{
FRUSTUM_PLANE_NEAR = 0,
FRUSTUM_PLANE_FAR = 1,
FRUSTUM_PLANE_LEFT = 2,
FRUSTUM_PLANE_RIGHT = 3,
FRUSTUM_PLANE_TOP = 4,
FRUSTUM_PLANE_BOTTOM = 5
};
class _OgreExport Frustum : public MovableObject, public Renderable
{
protected:
ProjectionType mProjType;
Radian mFOVy;
Real mFarDist;
Real mNearDist;
Real mAspect;
Real mOrthoHeight;
Vector2 mFrustumOffset;
Real mFocalLength;
mutable Plane mFrustumPlanes[6];
mutable Quaternion mLastParentOrientation;
mutable Vector3 mLastParentPosition;
mutable Matrix4 mProjMatrixRS;
mutable Matrix4 mProjMatrixRSDepth;
mutable Matrix4 mProjMatrix;
mutable Matrix4 mViewMatrix;
mutable bool mRecalcFrustum;
mutable bool mRecalcView;
mutable bool mRecalcFrustumPlanes;
mutable bool mRecalcWorldSpaceCorners;
mutable bool mRecalcVertexData;
bool mCustomViewMatrix;
bool mCustomProjMatrix;
bool mFrustumExtentsManuallySet;
mutable Real mLeft, mRight, mTop, mBottom;
mutable OrientationMode mOrientationMode;
// Internal functions for calcs
virtual void calcProjectionParameters(Real& left, Real& right, Real& bottom, Real& top) const;
virtual void updateFrustum(void) const;
virtual void updateView(void) const;
virtual void updateFrustumImpl(void) const;
virtual void updateViewImpl(void) const;
virtual void updateFrustumPlanes(void) const;
virtual void updateFrustumPlanesImpl(void) const;
virtual void updateWorldSpaceCorners(void) const;
virtual void updateWorldSpaceCornersImpl(void) const;
virtual void updateVertexData(void) const;
virtual bool isViewOutOfDate(void) const;
virtual bool isFrustumOutOfDate(void) const;
virtual void invalidateFrustum(void) const;
virtual void invalidateView(void) const;
static String msMovableType;
mutable AxisAlignedBox mBoundingBox;
mutable VertexData mVertexData;
MaterialPtr mMaterial;
mutable Vector3 mWorldSpaceCorners[8];
bool mReflect;
mutable Matrix4 mReflectMatrix;
mutable Plane mReflectPlane;
const MovablePlane* mLinkedReflectPlane;
mutable Plane mLastLinkedReflectionPlane;
bool mObliqueDepthProjection;
mutable Plane mObliqueProjPlane;
const MovablePlane* mLinkedObliqueProjPlane;
mutable Plane mLastLinkedObliqueProjPlane;
public:
Frustum(const String& name = StringUtil::BLANK);
virtual ~Frustum();
virtual void setFOVy(const Radian& fovy);
virtual const Radian& getFOVy(void) const;
virtual void setNearClipDistance(Real nearDist);
virtual Real getNearClipDistance(void) const;
virtual void setFarClipDistance(Real farDist);
virtual Real getFarClipDistance(void) const;
virtual void setAspectRatio(Real ratio);
virtual Real getAspectRatio(void) const;
virtual void setFrustumOffset(const Vector2& offset);
virtual void setFrustumOffset(Real horizontal = 0.0, Real vertical = 0.0);
virtual const Vector2& getFrustumOffset() const;
virtual void setFocalLength(Real focalLength = 1.0);
virtual Real getFocalLength() const;
virtual void setFrustumExtents(Real left, Real right, Real top, Real bottom);
virtual void resetFrustumExtents();
virtual void getFrustumExtents(Real& outleft, Real& outright, Real& outtop, Real& outbottom) const;
virtual const Matrix4& getProjectionMatrixRS(void) const;
virtual const Matrix4& getProjectionMatrixWithRSDepth(void) const;
virtual const Matrix4& getProjectionMatrix(void) const;
virtual const Matrix4& getViewMatrix(void) const;
virtual void calcViewMatrixRelative(const Vector3& relPos, Matrix4& matToUpdate) const;
virtual void setCustomViewMatrix(bool enable,
const Matrix4& viewMatrix = Matrix4::IDENTITY);
virtual bool isCustomViewMatrixEnabled(void) const
{ return mCustomViewMatrix; }
virtual void setCustomProjectionMatrix(bool enable,
const Matrix4& projectionMatrix = Matrix4::IDENTITY);
virtual bool isCustomProjectionMatrixEnabled(void) const
{ return mCustomProjMatrix; }
virtual const Plane* getFrustumPlanes(void) const;
virtual const Plane& getFrustumPlane( unsigned short plane ) const;
virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
uint32 getTypeFlags(void) const;
const AxisAlignedBox& getBoundingBox(void) const;
Real getBoundingRadius(void) const;
void _updateRenderQueue(RenderQueue* queue);
const String& getMovableType(void) const;
void _notifyCurrentCamera(Camera* cam);
const MaterialPtr& getMaterial(void) const;
void getRenderOperation(RenderOperation& op);
void getWorldTransforms(Matrix4* xform) const;
Real getSquaredViewDepth(const Camera* cam) const;
const LightList& getLights(void) const;
virtual const Vector3* getWorldSpaceCorners(void) const;
virtual void setProjectionType(ProjectionType pt);
virtual ProjectionType getProjectionType(void) const;
virtual void setOrthoWindow(Real w, Real h);
virtual void setOrthoWindowHeight(Real h);
virtual void setOrthoWindowWidth(Real w);
virtual Real getOrthoWindowHeight() const;
virtual Real getOrthoWindowWidth() const;
virtual void enableReflection(const Plane& p);
virtual void enableReflection(const MovablePlane* p);
virtual void disableReflection(void);
virtual bool isReflected(void) const { return mReflect; }
virtual const Matrix4& getReflectionMatrix(void) const { return mReflectMatrix; }
virtual const Plane& getReflectionPlane(void) const { return mReflectPlane; }
virtual bool projectSphere(const Sphere& sphere,
Real* left, Real* top, Real* right, Real* bottom) const;
virtual void enableCustomNearClipPlane(const MovablePlane* plane);
virtual void enableCustomNearClipPlane(const Plane& plane);
virtual void disableCustomNearClipPlane(void);
virtual bool isCustomNearClipPlaneEnabled(void) const
{ return mObliqueDepthProjection; }
void visitRenderables(Renderable::Visitor* visitor,
bool debugRenderables = false);
static const Real INFINITE_FAR_PLANE_ADJUST;
virtual const Vector3& getPositionForViewUpdate(void) const;
virtual const Quaternion& getOrientationForViewUpdate(void) const;
PlaneBoundedVolume getPlaneBoundedVolume();
void setOrientationMode(OrientationMode orientationMode);
OrientationMode getOrientationMode() const;
};
} // namespace Ogre
#include "OgreHeaderSuffix.h"
#endif // __Frustum_H__
Ogre::Frustum::mReflectMatrix
Matrix4 mReflectMatrix
Derived reflection matrix.
Definition: OgreFrustum.h:178
Ogre::Frustum::isCustomNearClipPlaneEnabled
virtual bool isCustomNearClipPlaneEnabled(void) const
Is a custom near clip plane in use?
Definition: OgreFrustum.h:651
Ogre::Frustum::isCustomViewMatrixEnabled
virtual bool isCustomViewMatrixEnabled(void) const
Returns whether a custom view matrix is in use.
Definition: OgreFrustum.h:391
Ogre::Renderable
Abstract class defining the interface all renderable objects must implement.
Definition: OgreRenderable.h:63
OgreAxisAlignedBox.h
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::Frustum::getReflectionMatrix
virtual const Matrix4 & getReflectionMatrix(void) const
Returns the reflection matrix of the frustum if appropriate.
Definition: OgreFrustum.h:574
Ogre::OR_DEGREE_180
Definition: OgreFrustum.h:53
Ogre::MovableObject
Abstract class defining a movable object in a scene.
Definition: OgreMovableObject.h:60
Ogre::Frustum::mLastParentOrientation
Quaternion mLastParentOrientation
Stored versions of parent orientation / position.
Definition: OgreFrustum.h:110
OgreRenderable.h
OgreMovableObject.h
Ogre::VertexData
Summary class collecting together vertex source information.
Definition: OgreVertexIndexData.h:49
Ogre::PlaneBoundedVolume
Represents a convex volume bounded by planes.
Definition: OgrePlaneBoundedVolume.h:49
Ogre::Quaternion
Implementation of a Quaternion, i.e.
Definition: OgreQuaternion.h:57
Ogre::Sphere
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Ogre::Frustum::mLastLinkedObliqueProjPlane
Plane mLastLinkedObliqueProjPlane
Record of the last world-space oblique depth projection plane info used.
Definition: OgreFrustum.h:193
Ogre::Frustum::mObliqueProjPlane
Plane mObliqueProjPlane
Fixed oblique projection plane.
Definition: OgreFrustum.h:189
Ogre::Frustum::mFocalLength
Real mFocalLength
Focal length of frustum (for stereo rendering, defaults to 1.0)
Definition: OgreFrustum.h:104
Ogre::Frustum::mCustomViewMatrix
bool mCustomViewMatrix
Are we using a custom view matrix?
Definition: OgreFrustum.h:132
Ogre::OR_DEGREE_0
Definition: OgreFrustum.h:51
Ogre::Matrix4::IDENTITY
static const Matrix4 IDENTITY
Definition: OgreMatrix4.h:511
Ogre::OR_DEGREE_90
Definition: OgreFrustum.h:52
Ogre::FRUSTUM_PLANE_BOTTOM
Definition: OgreFrustum.h:78
Ogre::Vector2
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
Ogre::PT_ORTHOGRAPHIC
Definition: OgreFrustum.h:65
Ogre::Real
float Real
Software floating point type.
Definition: OgrePrerequisites.h:70
Ogre::FRUSTUM_PLANE_FAR
Definition: OgreFrustum.h:74
Ogre::Frustum::mLinkedObliqueProjPlane
const MovablePlane * mLinkedObliqueProjPlane
Pointer to oblique projection plane (automatically updated)
Definition: OgreFrustum.h:191
Ogre::RenderQueue
Class to manage the scene object rendering queue.
Definition: OgreRenderQueue.h:92
Ogre::FRUSTUM_PLANE_NEAR
Definition: OgreFrustum.h:73
Ogre::Frustum::mOrthoHeight
Real mOrthoHeight
Ortho height size (world units)
Definition: OgreFrustum.h:100
Ogre::Frustum::mProjMatrixRSDepth
Matrix4 mProjMatrixRSDepth
Pre-calced standard projection matrix but with render system depth range.
Definition: OgreFrustum.h:116
Ogre::Frustum::mRecalcFrustum
bool mRecalcFrustum
Something&#39;s changed in the frustum shape?
Definition: OgreFrustum.h:122
Ogre::Frustum::mProjType
ProjectionType mProjType
Orthographic or perspective?
Definition: OgreFrustum.h:89
Ogre::Frustum::INFINITE_FAR_PLANE_ADJUST
static const Real INFINITE_FAR_PLANE_ADJUST
Small constant used to reduce far plane projection to avoid inaccuracies.
Definition: OgreFrustum.h:659
Ogre::Frustum::mRecalcWorldSpaceCorners
bool mRecalcWorldSpaceCorners
Something re the world space corners has changed.
Definition: OgreFrustum.h:128
Ogre::Frustum::mRecalcVertexData
bool mRecalcVertexData
Something re the vertex data has changed.
Definition: OgreFrustum.h:130
Ogre::Frustum::mLinkedReflectPlane
const MovablePlane * mLinkedReflectPlane
Pointer to a reflection plane (automatically updated)
Definition: OgreFrustum.h:182
Ogre::Frustum::msMovableType
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreFrustum.h:167
Ogre::OR_DEGREE_270
Definition: OgreFrustum.h:54
Ogre::Frustum::mLastParentPosition
Vector3 mLastParentPosition
Definition: OgreFrustum.h:111
Ogre::Plane
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Ogre::Frustum::mAspect
Real mAspect
x/y viewport ratio - default 1.3333
Definition: OgreFrustum.h:98
Ogre::Frustum::mRecalcFrustumPlanes
bool mRecalcFrustumPlanes
Something re the frustum planes has changed.
Definition: OgreFrustum.h:126
Ogre::OrientationMode
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:49
OgreVertexIndexData.h
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::PT_PERSPECTIVE
Definition: OgreFrustum.h:66
Ogre::Frustum::mViewMatrix
Matrix4 mViewMatrix
Pre-calced view matrix.
Definition: OgreFrustum.h:120
Ogre::HashedVector
A hashed vector.
Definition: OgreCommon.h:332
Ogre::Renderable::Visitor
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Definition: OgreRenderable.h:377
Ogre::Frustum::mMaterial
MaterialPtr mMaterial
Definition: OgreFrustum.h:172
Ogre::Frustum::mFOVy
Radian mFOVy
y-direction field-of-view (default 45)
Definition: OgreFrustum.h:92
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::Frustum::mVertexData
VertexData mVertexData
Definition: OgreFrustum.h:170
Ogre::Frustum::mNearDist
Real mNearDist
Near clip distance - default 100.
Definition: OgreFrustum.h:96
Ogre::OR_LANDSCAPELEFT
Definition: OgreFrustum.h:58
Ogre::Frustum::mCustomProjMatrix
bool mCustomProjMatrix
Are we using a custom projection matrix?
Definition: OgreFrustum.h:134
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
OgreHeaderSuffix.h
Ogre::Frustum::isCustomProjectionMatrixEnabled
virtual bool isCustomProjectionMatrixEnabled(void) const
Returns whether a custom projection matrix is in use.
Definition: OgreFrustum.h:418
Ogre::uint32
unsigned int uint32
Definition: OgrePlatform.h:359
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::FrustumPlane
FrustumPlane
Worldspace clipping planes.
Definition: OgreFrustum.h:71
Ogre::Frustum::isReflected
virtual bool isReflected(void) const
Returns whether this frustum is being reflected.
Definition: OgreFrustum.h:572
Ogre::Frustum::mLastLinkedReflectionPlane
Plane mLastLinkedReflectionPlane
Record of the last world-space reflection plane info used.
Definition: OgreFrustum.h:184
Ogre::Frustum::mReflect
bool mReflect
Is this frustum to act as a reflection of itself?
Definition: OgreFrustum.h:176
Ogre::OR_LANDSCAPERIGHT
Definition: OgreFrustum.h:57
OgreMovablePlane.h
Ogre::Frustum::mOrientationMode
OrientationMode mOrientationMode
Frustum orientation mode.
Definition: OgreFrustum.h:140
Ogre::FRUSTUM_PLANE_RIGHT
Definition: OgreFrustum.h:76
Ogre::SharedPtr< Material >
Ogre::Frustum::mProjMatrixRS
Matrix4 mProjMatrixRS
Pre-calced projection matrix for the specific render system.
Definition: OgreFrustum.h:114
Ogre::Frustum::mFarDist
Real mFarDist
Far clip distance - default 10000.
Definition: OgreFrustum.h:94
Ogre::Frustum::mBoundingBox
AxisAlignedBox mBoundingBox
Definition: OgreFrustum.h:169
OgreHeaderPrefix.h
Ogre::FRUSTUM_PLANE_TOP
Definition: OgreFrustum.h:77
Ogre::FRUSTUM_PLANE_LEFT
Definition: OgreFrustum.h:75
Ogre::OR_PORTRAIT
Definition: OgreFrustum.h:56
Ogre::Frustum::mFrustumOffset
Vector2 mFrustumOffset
Off-axis frustum center offset - default (0.0, 0.0)
Definition: OgreFrustum.h:102
Ogre::RenderOperation
&#39;New&#39; rendering operation using vertex buffers.
Definition: OgreRenderOperation.h:45
Ogre::Frustum::mFrustumExtentsManuallySet
bool mFrustumExtentsManuallySet
Have the frustum extents been manually set?
Definition: OgreFrustum.h:136
Ogre::Frustum::mObliqueDepthProjection
bool mObliqueDepthProjection
Is this frustum using an oblique depth projection?
Definition: OgreFrustum.h:187
Ogre::Frustum::mProjMatrix
Matrix4 mProjMatrix
Pre-calced standard projection matrix.
Definition: OgreFrustum.h:118
Ogre::Frustum::mTop
Real mTop
Definition: OgreFrustum.h:138
Ogre::Frustum::getReflectionPlane
virtual const Plane & getReflectionPlane(void) const
Returns the reflection plane of the frustum if appropriate.
Definition: OgreFrustum.h:576
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::MovablePlane
Definition of a Plane that may be attached to a node, and the derived details of it retrieved simply...
Definition: OgreMovablePlane.h:54
Ogre::ProjectionType
ProjectionType
Specifies perspective (realistic) or orthographic (architectural) projection.
Definition: OgreFrustum.h:63
Ogre::Frustum::mRecalcView
bool mRecalcView
Something re the view pos has changed.
Definition: OgreFrustum.h:124
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::Frustum::mReflectPlane
Plane mReflectPlane
Fixed reflection plane.
Definition: OgreFrustum.h:180
Ogre::Radian
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:47

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