Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class 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 (c) 2000-2006 Torus Knot Software Ltd
    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 You may alternatively use this source under the terms of a specific version of
    00025 the OGRE Unrestricted License provided you have obtained such a license from
    00026 Torus Knot Software Ltd.
    00027 -----------------------------------------------------------------------------
    00028 */
    00029 #ifndef __Frustum_H__
    00030 #define __Frustum_H__
    00031
    00032 #include "OgrePrerequisites.h"
    00033 #include "OgreMovableObject.h"
    00034 #include "OgreRenderable.h"
    00035 #include "OgreAxisAlignedBox.h"
    00036 #include "OgreVertexIndexData.h"
    00037 #include "OgreMovablePlane.h"
    00038
    00039 namespace Ogre
    00040 {
    00043     enum ProjectionType
    00044     {
    00045         PT_ORTHOGRAPHIC,
    00046         PT_PERSPECTIVE
    00047     };
    00048
    00051     enum FrustumPlane
    00052     {
    00053         FRUSTUM_PLANE_NEAR   = 0,
    00054         FRUSTUM_PLANE_FAR    = 1,
    00055         FRUSTUM_PLANE_LEFT   = 2,
    00056         FRUSTUM_PLANE_RIGHT  = 3,
    00057         FRUSTUM_PLANE_TOP    = 4,
    00058         FRUSTUM_PLANE_BOTTOM = 5
    00059     };
    00060
    00065     class _OgreExport Frustum : public MovableObject, public Renderable
    00066     {
    00067     protected:
    00069         ProjectionType mProjType;
    00070
    00072         Radian mFOVy;
    00074         Real mFarDist;
    00076         Real mNearDist;
    00078         Real mAspect;
    00080         Vector2 mFrustumOffset;
    00082         Real mFocalLength;
    00083
    00085         mutable Plane mFrustumPlanes[6];
    00086
    00088         mutable Quaternion mLastParentOrientation;
    00089         mutable Vector3 mLastParentPosition;
    00090
    00092         mutable Matrix4 mProjMatrixRS;
    00094         mutable Matrix4 mProjMatrixRSDepth;
    00096         mutable Matrix4 mProjMatrix;
    00098         mutable Matrix4 mViewMatrix;
    00100         mutable bool mRecalcFrustum;
    00102         mutable bool mRecalcView;
    00104         mutable bool mRecalcFrustumPlanes;
    00106         mutable bool mRecalcWorldSpaceCorners;
    00108         mutable bool mRecalcVertexData;
    00110         bool mCustomViewMatrix;
    00112         bool mCustomProjMatrix;
    00113
    00114
    00115         // Internal functions for calcs
    00116         virtual void calcProjectionParameters(Real& left, Real& right, Real& bottom, Real& top) const;
    00118         virtual void updateFrustum(void) const;
    00120         virtual void updateView(void) const;
    00122         virtual void updateFrustumImpl(void) const;
    00124         virtual void updateViewImpl(void) const;
    00125         virtual void updateFrustumPlanes(void) const;
    00127         virtual void updateFrustumPlanesImpl(void) const;
    00128         virtual void updateWorldSpaceCorners(void) const;
    00130         virtual void updateWorldSpaceCornersImpl(void) const;
    00131         virtual void updateVertexData(void) const;
    00132         virtual bool isViewOutOfDate(void) const;
    00133         virtual bool isFrustumOutOfDate(void) const;
    00135         virtual void invalidateFrustum(void) const;
    00137         virtual void invalidateView(void) const;
    00138
    00140         static String msMovableType;
    00141
    00142         mutable AxisAlignedBox mBoundingBox;
    00143         mutable VertexData mVertexData;
    00144
    00145         MaterialPtr mMaterial;
    00146         mutable Vector3 mWorldSpaceCorners[8];
    00147
    00149         bool mReflect;
    00151         mutable Matrix4 mReflectMatrix;
    00153         mutable Plane mReflectPlane;
    00155         const MovablePlane* mLinkedReflectPlane;
    00157         mutable Plane mLastLinkedReflectionPlane;
    00158
    00160         bool mObliqueDepthProjection;
    00162         mutable Plane mObliqueProjPlane;
    00164         const MovablePlane* mLinkedObliqueProjPlane;
    00166         mutable Plane mLastLinkedObliqueProjPlane;
    00167
    00168
    00170         virtual const Vector3& getPositionForViewUpdate(void) const;
    00172         virtual const Quaternion& getOrientationForViewUpdate(void) const;
    00173
    00174
    00175     public:
    00176
    00177         Frustum();
    00178         virtual ~Frustum();
    00191         virtual void setFOVy(const Radian& fovy);
    00192 #ifndef OGRE_FORCE_ANGLE_TYPES
    00193         inline void setFOVy(Real fovy) {
    00194             setFOVy ( Angle(fovy) );
    00195         }
    00196 #endif//OGRE_FORCE_ANGLE_TYPES
    00197
    00200         virtual const Radian& getFOVy(void) const;
    00201
    00213         virtual void setNearClipDistance(Real nearDist);
    00214
    00217         virtual Real getNearClipDistance(void) const;
    00218
    00239         virtual void setFarClipDistance(Real farDist);
    00240
    00243         virtual Real getFarClipDistance(void) const;
    00244
    00253         virtual void setAspectRatio(Real ratio);
    00254
    00257         virtual Real getAspectRatio(void) const;
    00258
    00270         virtual void setFrustumOffset(const Vector2& offset);
    00271
    00285         virtual void setFrustumOffset(Real horizontal = 0.0, Real vertical = 0.0);
    00286
    00289         virtual const Vector2& getFrustumOffset() const;
    00290
    00295         virtual void setFocalLength(Real focalLength = 1.0);
    00296
    00299         virtual Real getFocalLength() const;
    00300
    00310         virtual const Matrix4& getProjectionMatrixRS(void) const;
    00322         virtual const Matrix4& getProjectionMatrixWithRSDepth(void) const;
    00332         virtual const Matrix4& getProjectionMatrix(void) const;
    00333
    00336         virtual const Matrix4& getViewMatrix(void) const;
    00337
    00355         virtual void setCustomViewMatrix(bool enable,
    00356             const Matrix4& viewMatrix = Matrix4::IDENTITY);
    00358         virtual bool isCustomViewMatrixEnabled(void) const
    00359         { return mCustomViewMatrix; }
    00360
    00380         virtual void setCustomProjectionMatrix(bool enable,
    00381             const Matrix4& projectionMatrix = Matrix4::IDENTITY);
    00383         virtual bool isCustomProjectionMatrixEnabled(void) const
    00384         { return mCustomProjMatrix; }
    00385
    00390         virtual const Plane* getFrustumPlanes(void) const;
    00391
    00396         virtual const Plane& getFrustumPlane( unsigned short plane ) const;
    00397
    00409         virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
    00410
    00422         virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
    00423
    00435         virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
    00436
    00437
    00439         const AxisAlignedBox& getBoundingBox(void) const;
    00440
    00442         Real getBoundingRadius(void) const;
    00443
    00445         void _updateRenderQueue(RenderQueue* queue);
    00446
    00448         const String& getMovableType(void) const;
    00449
    00451         void _notifyCurrentCamera(Camera* cam);
    00452
    00454         const MaterialPtr& getMaterial(void) const;
    00455
    00457         void getRenderOperation(RenderOperation& op);
    00458
    00460         void getWorldTransforms(Matrix4* xform) const;
    00461
    00463         const Quaternion& getWorldOrientation(void) const;
    00464
    00466         const Vector3& getWorldPosition(void) const;
    00467
    00469         Real getSquaredViewDepth(const Camera* cam) const;
    00470
    00472         const LightList& getLights(void) const;
    00473
    00480         virtual const Vector3* getWorldSpaceCorners(void) const;
    00481
    00484         virtual void setProjectionType(ProjectionType pt);
    00485
    00488         virtual ProjectionType getProjectionType(void) const;
    00489
    00495         virtual void enableReflection(const Plane& p);
    00504         virtual void enableReflection(const MovablePlane* p);
    00505
    00507         virtual void disableReflection(void);
    00508
    00510         virtual bool isReflected(void) const { return mReflect; }
    00512         virtual const Matrix4& getReflectionMatrix(void) const { return mReflectMatrix; }
    00514         virtual const Plane& getReflectionPlane(void) const { return mReflectPlane; }
    00515
    00525         virtual bool projectSphere(const Sphere& sphere,
    00526             Real* left, Real* top, Real* right, Real* bottom) const;
    00527
    00528
    00554         virtual void enableCustomNearClipPlane(const MovablePlane* plane);
    00575         virtual void enableCustomNearClipPlane(const Plane& plane);
    00577         virtual void disableCustomNearClipPlane(void);
    00579         virtual bool isCustomNearClipPlaneEnabled(void) const
    00580         { return mObliqueDepthProjection; }
    00581
    00582
    00584         static const Real INFINITE_FAR_PLANE_ADJUST;
    00585     };
    00586
    00587
    00588 }
    00589
    00590 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 30 10:50:56 2007