Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreFrustum.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright © 2000-2003 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Frustum_H__
00026 #define __Frustum_H__
00027 
00028 #include "OgrePrerequisites.h"
00029 #include "OgreMovableObject.h"
00030 #include "OgreRenderable.h"
00031 #include "OgreAxisAlignedBox.h"
00032 #include "OgreVertexIndexData.h"
00033 
00034 namespace Ogre
00035 {
00038     enum ProjectionType
00039     {
00040         PT_ORTHOGRAPHIC,
00041         PT_PERSPECTIVE
00042     };
00043 
00046     enum FrustumPlane
00047     {
00048         FRUSTUM_PLANE_NEAR   = 0,
00049         FRUSTUM_PLANE_FAR    = 1,
00050         FRUSTUM_PLANE_LEFT   = 2,
00051         FRUSTUM_PLANE_RIGHT  = 3,
00052         FRUSTUM_PLANE_TOP    = 4,
00053         FRUSTUM_PLANE_BOTTOM = 5
00054     };
00055 
00060     class _OgreExport Frustum : public MovableObject, public Renderable
00061     {
00062     protected:
00064         ProjectionType mProjType;
00065 
00067         Real mFOVy;
00069         Real mFarDist;
00071         Real mNearDist;
00073         Real mAspect;
00074 
00076         mutable Plane mFrustumPlanes[6];
00077 
00079         mutable Quaternion mLastParentOrientation;
00080         mutable Vector3 mLastParentPosition;
00081 
00083         mutable Matrix4 mProjMatrix;
00085         mutable Matrix4 mStandardProjMatrix;
00087         mutable Matrix4 mViewMatrix;
00089         mutable bool mRecalcFrustum;
00091         mutable bool mRecalcView;
00092 
00093 
00097         mutable Real mCoeffL[2], mCoeffR[2], mCoeffB[2], mCoeffT[2];
00098 
00099 
00100         // Internal functions for calcs
00101         virtual void updateFrustum(void) const;
00102         virtual void updateView(void) const;
00103         virtual bool isViewOutOfDate(void) const;
00104         virtual bool isFrustumOutOfDate(void) const;
00106         virtual void invalidateFrustum(void);
00108         virtual void invalidateView(void);
00109 
00111         static String msMovableType;
00112 
00113         mutable AxisAlignedBox mBoundingBox;
00114         mutable VertexData mVertexData;
00115 
00116         Material* mMaterial;
00117         mutable Vector3 mWorldSpaceCorners[8];
00118 
00120         bool mReflect;
00121         Matrix4 mReflectMatrix;
00122         Plane mReflectPlane;
00123 
00125         virtual const Vector3& getPositionForViewUpdate(void) const;
00127         virtual const Quaternion& getOrientationForViewUpdate(void) const;
00128 
00129 
00130     public:
00131 
00132         Frustum();
00133         virtual ~Frustum();
00146         virtual void setFOVy(Real fovy);
00147 
00150         virtual Real getFOVy(void) const;
00151 
00163         virtual void setNearClipDistance(Real nearDist);
00164 
00167         virtual Real getNearClipDistance(void) const;
00168 
00189         virtual void setFarClipDistance(Real farDist);
00190 
00193         virtual Real getFarClipDistance(void) const;
00194 
00203         virtual void setAspectRatio(Real ratio);
00204 
00207         virtual Real getAspectRatio(void) const;
00208 
00216         virtual const Matrix4& getProjectionMatrix(void) const;
00228         virtual const Matrix4& getStandardProjectionMatrix(void) const;
00229 
00232         virtual const Matrix4& getViewMatrix(void) const;
00233 
00238         virtual const Plane& getFrustumPlane( unsigned short plane ) const;
00239 
00251         virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
00252 
00264         virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
00265 
00277         virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
00278 
00279 
00281         const AxisAlignedBox& getBoundingBox(void) const;
00282 
00284         Real getBoundingRadius(void) const;
00285 
00287         void _updateRenderQueue(RenderQueue* queue);
00288 
00290         const String& getMovableType(void) const;
00291 
00293         const String& getName(void) const;
00294 
00296         void _notifyCurrentCamera(Camera* cam);
00297 
00299         Material* getMaterial(void) const;
00300 
00302         void getRenderOperation(RenderOperation& op);
00303 
00305         void getWorldTransforms(Matrix4* xform) const;
00306 
00308         const Quaternion& getWorldOrientation(void) const;
00309 
00311         const Vector3& getWorldPosition(void) const;
00312 
00314         Real getSquaredViewDepth(const Camera* cam) const;
00315 
00317         const LightList& getLights(void) const;
00318 
00325         virtual const Vector3* getWorldSpaceCorners(void) const;
00326 
00329         virtual void setProjectionType(ProjectionType pt);
00330 
00333         virtual ProjectionType getProjectionType(void) const;
00334 
00340         virtual void enableReflection(const Plane& p);
00341 
00343         virtual void disableReflection(void);
00344 
00346         virtual bool isReflected(void) const { return mReflect; }
00348         virtual const Matrix4& getReflectionMatrix(void) const { return mReflectMatrix; }
00350         virtual const Plane& getReflectionPlane(void) const { return mReflectPlane; }
00351 
00361         virtual bool projectSphere(const Sphere& sphere, 
00362             Real* left, Real* top, Real* right, Real* bottom) const;
00363 
00364 
00366         static const Real INFINITE_FAR_PLANE_ADJUST;
00367     };
00368 
00369 
00370 }
00371 
00372 #endif 

Copyright © 2002-2003 by The OGRE Team
Last modified Fri May 14 23:22:10 2004