OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreFrustum.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 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __Frustum_H__
29 #define __Frustum_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreMovableObject.h"
33 #include "OgreRenderable.h"
34 #include "OgreAxisAlignedBox.h"
35 #include "OgreVertexIndexData.h"
36 #include "OgreMovablePlane.h"
37 #include "OgreHeaderPrefix.h"
38 
39 namespace Ogre
40 {
50  {
55 
59  };
60 
64  {
67  };
68 
72  {
79  };
80 
86  {
87  protected:
90 
105 
107  mutable Plane mFrustumPlanes[6];
108 
112 
122  mutable bool mRecalcFrustum;
124  mutable bool mRecalcView;
126  mutable bool mRecalcFrustumPlanes;
130  mutable bool mRecalcVertexData;
138  mutable Real mLeft, mRight, mTop, mBottom;
141 
142  // Internal functions for calcs
143  virtual void calcProjectionParameters(Real& left, Real& right, Real& bottom, Real& top) const;
145  virtual void updateFrustum(void) const;
147  virtual void updateView(void) const;
149  virtual void updateFrustumImpl(void) const;
151  virtual void updateViewImpl(void) const;
152  virtual void updateFrustumPlanes(void) const;
154  virtual void updateFrustumPlanesImpl(void) const;
155  virtual void updateWorldSpaceCorners(void) const;
157  virtual void updateWorldSpaceCornersImpl(void) const;
158  virtual void updateVertexData(void) const;
159  virtual bool isViewOutOfDate(void) const;
160  virtual bool isFrustumOutOfDate(void) const;
162  virtual void invalidateFrustum(void) const;
164  virtual void invalidateView(void) const;
165 
168 
171 
173  mutable Vector3 mWorldSpaceCorners[8];
174 
176  bool mReflect;
185 
194 
195  public:
196 
198  Frustum(const String& name = StringUtil::BLANK);
199 
200  virtual ~Frustum();
213  virtual void setFOVy(const Radian& fovy);
214 
217  virtual const Radian& getFOVy(void) const;
218 
230  virtual void setNearClipDistance(Real nearDist);
231 
234  virtual Real getNearClipDistance(void) const;
235 
256  virtual void setFarClipDistance(Real farDist);
257 
260  virtual Real getFarClipDistance(void) const;
261 
270  virtual void setAspectRatio(Real ratio);
271 
274  virtual Real getAspectRatio(void) const;
275 
287  virtual void setFrustumOffset(const Vector2& offset);
288 
302  virtual void setFrustumOffset(Real horizontal = 0.0, Real vertical = 0.0);
303 
306  virtual const Vector2& getFrustumOffset() const;
307 
312  virtual void setFocalLength(Real focalLength = 1.0);
313 
316  virtual Real getFocalLength() const;
317 
322  virtual void setFrustumExtents(Real left, Real right, Real top, Real bottom);
324  virtual void resetFrustumExtents();
326  virtual void getFrustumExtents(Real& outleft, Real& outright, Real& outtop, Real& outbottom) const;
327 
328 
338  virtual const Matrix4& getProjectionMatrixRS(void) const;
350  virtual const Matrix4& getProjectionMatrixWithRSDepth(void) const;
360  virtual const Matrix4& getProjectionMatrix(void) const;
361 
364  virtual const Matrix4& getViewMatrix(void) const;
365 
370  virtual void calcViewMatrixRelative(const Vector3& relPos, Matrix4& matToUpdate) const;
371 
389  virtual void setCustomViewMatrix(bool enable,
390  const Matrix4& viewMatrix = Matrix4::IDENTITY);
392  virtual bool isCustomViewMatrixEnabled(void) const
393  { return mCustomViewMatrix; }
394 
414  virtual void setCustomProjectionMatrix(bool enable,
415  const Matrix4& projectionMatrix = Matrix4::IDENTITY);
417  virtual bool isCustomProjectionMatrixEnabled(void) const
418  { return mCustomProjMatrix; }
419 
424  virtual const Plane* getFrustumPlanes(void) const;
425 
430  virtual const Plane& getFrustumPlane( unsigned short plane ) const;
431 
443  virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
444 
456  virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
457 
469  virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
470 
472  uint32 getTypeFlags(void) const;
473 
475  const AxisAlignedBox& getBoundingBox(void) const;
476 
478  Real getBoundingRadius(void) const;
479 
481  void _updateRenderQueue(RenderQueue* queue);
482 
484  const String& getMovableType(void) const;
485 
487  void _notifyCurrentCamera(Camera* cam);
488 
490  const MaterialPtr& getMaterial(void) const;
491 
493  void getRenderOperation(RenderOperation& op);
494 
496  void getWorldTransforms(Matrix4* xform) const;
497 
499  Real getSquaredViewDepth(const Camera* cam) const;
500 
502  const LightList& getLights(void) const;
503 
510  virtual const Vector3* getWorldSpaceCorners(void) const;
511 
514  virtual void setProjectionType(ProjectionType pt);
515 
518  virtual ProjectionType getProjectionType(void) const;
519 
527  virtual void setOrthoWindow(Real w, Real h);
532  virtual void setOrthoWindowHeight(Real h);
537  virtual void setOrthoWindowWidth(Real w);
540  virtual Real getOrthoWindowHeight() const;
544  virtual Real getOrthoWindowWidth() const;
545 
551  virtual void enableReflection(const Plane& p);
560  virtual void enableReflection(const MovablePlane* p);
561 
563  virtual void disableReflection(void);
564 
566  virtual bool isReflected(void) const { return mReflect; }
568  virtual const Matrix4& getReflectionMatrix(void) const { return mReflectMatrix; }
570  virtual const Plane& getReflectionPlane(void) const { return mReflectPlane; }
571 
581  virtual bool projectSphere(const Sphere& sphere,
582  Real* left, Real* top, Real* right, Real* bottom) const;
583 
584 
610  virtual void enableCustomNearClipPlane(const MovablePlane* plane);
631  virtual void enableCustomNearClipPlane(const Plane& plane);
633  virtual void disableCustomNearClipPlane(void);
635  virtual bool isCustomNearClipPlaneEnabled(void) const
636  { return mObliqueDepthProjection; }
637 
639  void visitRenderables(Renderable::Visitor* visitor,
640  bool debugRenderables = false);
641 
644 
646  virtual const Vector3& getPositionForViewUpdate(void) const;
648  virtual const Quaternion& getOrientationForViewUpdate(void) const;
649 
652  PlaneBoundedVolume getPlaneBoundedVolume();
658  void setOrientationMode(OrientationMode orientationMode);
659 
665  OrientationMode getOrientationMode() const;
666 
667  };
668 
672 }
673 
674 #include "OgreHeaderSuffix.h"
675 
676 #endif
virtual bool isCustomViewMatrixEnabled(void) const
Returns whether a custom view matrix is in use.
Definition: OgreFrustum.h:392
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
virtual const Plane & getReflectionPlane(void) const
Returns the reflection plane of the frustum if appropriate.
Definition: OgreFrustum.h:570
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:78
MaterialPtr mMaterial
Definition: OgreFrustum.h:172
Matrix4 mViewMatrix
Pre-calced view matrix.
Definition: OgreFrustum.h:120
AxisAlignedBox mBoundingBox
Definition: OgreFrustum.h:169
float Real
Software floating point type.
const MovablePlane * mLinkedObliqueProjPlane
Pointer to oblique projection plane (automatically updated)
Definition: OgreFrustum.h:191
unsigned int uint32
Definition: OgrePlatform.h:270
#define _OgreExport
Definition: OgrePlatform.h:233
Matrix4 mProjMatrixRS
Pre-calced projection matrix for the specific render system.
Definition: OgreFrustum.h:114
OrientationMode mOrientationMode
Frustum orientation mode.
Definition: OgreFrustum.h:140
Defines a plane in 3D space.
Definition: OgrePlane.h:61
Vector2 mFrustumOffset
Off-axis frustum center offset - default (0.0, 0.0)
Definition: OgreFrustum.h:102
Real mFarDist
Far clip distance - default 10000.
Definition: OgreFrustum.h:94
const MovablePlane * mLinkedReflectPlane
Pointer to a reflection plane (automatically updated)
Definition: OgreFrustum.h:182
ProjectionType mProjType
Orthographic or perspective?
Definition: OgreFrustum.h:89
Vector3 mLastParentPosition
Definition: OgreFrustum.h:111
A frustum represents a pyramid, capped at the near and far end which is used to represent either a vi...
Definition: OgreFrustum.h:85
static const Matrix4 IDENTITY
Definition: OgreMatrix4.h:511
Radian mFOVy
y-direction field-of-view (default 45)
Definition: OgreFrustum.h:92
virtual bool isReflected(void) const
Returns whether this frustum is being reflected.
Definition: OgreFrustum.h:566
A 3D box aligned with the x/y/z axes.
Quaternion mLastParentOrientation
Stored versions of parent orientation / position.
Definition: OgreFrustum.h:110
VertexData mVertexData
Definition: OgreFrustum.h:170
bool mCustomProjMatrix
Are we using a custom projection matrix?
Definition: OgreFrustum.h:134
Real mNearDist
Near clip distance - default 100.
Definition: OgreFrustum.h:96
Plane mObliqueProjPlane
Fixed oblique projection plane.
Definition: OgreFrustum.h:189
Abstract class defining a movable object in a scene.
bool mRecalcWorldSpaceCorners
Something re the world space corners has changed.
Definition: OgreFrustum.h:128
Abstract class defining the interface all renderable objects must implement.
Implementation of a Quaternion, i.e.
virtual const Matrix4 & getReflectionMatrix(void) const
Returns the reflection matrix of the frustum if appropriate.
Definition: OgreFrustum.h:568
bool mRecalcFrustum
Something's changed in the frustum shape?
Definition: OgreFrustum.h:122
static String msMovableType
Shared class-level name for Movable type.
Definition: OgreFrustum.h:167
OrientationMode
Specifies orientation mode.
Definition: OgreFrustum.h:49
ProjectionType
Specifies perspective (realistic) or orthographic (architectural) projection.
Definition: OgreFrustum.h:63
Matrix4 mReflectMatrix
Derived reflection matrix.
Definition: OgreFrustum.h:178
Matrix4 mProjMatrixRSDepth
Pre-calced standard projection matrix but with render system depth range.
Definition: OgreFrustum.h:116
Real mOrthoHeight
Ortho height size (world units)
Definition: OgreFrustum.h:100
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
Standard 2-dimensional vector.
Definition: OgreVector2.h:51
bool mRecalcVertexData
Something re the vertex data has changed.
Definition: OgreFrustum.h:130
Plane mLastLinkedObliqueProjPlane
Record of the last world-space oblique depth projection plane info used.
Definition: OgreFrustum.h:193
bool mReflect
Is this frustum to act as a reflection of itself?
Definition: OgreFrustum.h:176
Visitor object that can be used to iterate over a collection of Renderable instances abstractly...
Plane mReflectPlane
Fixed reflection plane.
Definition: OgreFrustum.h:180
Definition of a Plane that may be attached to a node, and the derived details of it retrieved simply...
Standard 3-dimensional vector.
Definition: OgreVector3.h:51
virtual bool isCustomProjectionMatrixEnabled(void) const
Returns whether a custom projection matrix is in use.
Definition: OgreFrustum.h:417
Represents a convex volume bounded by planes.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Summary class collecting together vertex source information.
bool mRecalcView
Something re the view pos has changed.
Definition: OgreFrustum.h:124
'New' rendering operation using vertex buffers.
Real mAspect
x/y viewport ratio - default 1.3333
Definition: OgreFrustum.h:98
virtual bool isCustomNearClipPlaneEnabled(void) const
Is a custom near clip plane in use?
Definition: OgreFrustum.h:635
Wrapper class which indicates a given angle value is in Radians.
Definition: OgreMath.h:46
static const Real INFINITE_FAR_PLANE_ADJUST
Small constant used to reduce far plane projection to avoid inaccuracies.
Definition: OgreFrustum.h:643
Class to manage the scene object rendering queue.
bool mRecalcFrustumPlanes
Something re the frustum planes has changed.
Definition: OgreFrustum.h:126
FrustumPlane
Worldspace clipping planes.
Definition: OgreFrustum.h:71
_StringBase String
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
bool mFrustumExtentsManuallySet
Have the frustum extents been manually set?
Definition: OgreFrustum.h:136
Plane mLastLinkedReflectionPlane
Record of the last world-space reflection plane info used.
Definition: OgreFrustum.h:184
bool mObliqueDepthProjection
Is this frustum using an oblique depth projection?
Definition: OgreFrustum.h:187
Real mFocalLength
Focal length of frustum (for stereo rendering, defaults to 1.0)
Definition: OgreFrustum.h:104
Matrix4 mProjMatrix
Pre-calced standard projection matrix.
Definition: OgreFrustum.h:118
bool mCustomViewMatrix
Are we using a custom view matrix?
Definition: OgreFrustum.h:132