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-2005 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 #include "OgreMovablePlane.h" 00034 00035 namespace Ogre 00036 { 00039 enum ProjectionType 00040 { 00041 PT_ORTHOGRAPHIC, 00042 PT_PERSPECTIVE 00043 }; 00044 00047 enum FrustumPlane 00048 { 00049 FRUSTUM_PLANE_NEAR = 0, 00050 FRUSTUM_PLANE_FAR = 1, 00051 FRUSTUM_PLANE_LEFT = 2, 00052 FRUSTUM_PLANE_RIGHT = 3, 00053 FRUSTUM_PLANE_TOP = 4, 00054 FRUSTUM_PLANE_BOTTOM = 5 00055 }; 00056 00061 class _OgreExport Frustum : public MovableObject, public Renderable 00062 { 00063 protected: 00065 ProjectionType mProjType; 00066 00068 Radian mFOVy; 00070 Real mFarDist; 00072 Real mNearDist; 00074 Real mAspect; 00075 00077 mutable Plane mFrustumPlanes[6]; 00078 00080 mutable Quaternion mLastParentOrientation; 00081 mutable Vector3 mLastParentPosition; 00082 00084 mutable Matrix4 mProjMatrix; 00086 mutable Matrix4 mStandardProjMatrix; 00088 mutable Matrix4 mViewMatrix; 00090 mutable bool mRecalcFrustum; 00092 mutable bool mRecalcView; 00093 00094 00098 mutable Real mCoeffL[2], mCoeffR[2], mCoeffB[2], mCoeffT[2]; 00099 00100 00101 00102 00103 // Internal functions for calcs 00104 virtual void updateFrustum(void) const; 00105 virtual void updateView(void) const; 00106 virtual bool isViewOutOfDate(void) const; 00107 virtual bool isFrustumOutOfDate(void) const; 00109 virtual void invalidateFrustum(void) const; 00111 virtual void invalidateView(void) const; 00112 00114 static String msMovableType; 00115 00116 mutable AxisAlignedBox mBoundingBox; 00117 mutable VertexData mVertexData; 00118 00119 MaterialPtr mMaterial; 00120 mutable Vector3 mWorldSpaceCorners[8]; 00121 00123 bool mReflect; 00125 mutable Matrix4 mReflectMatrix; 00127 mutable Plane mReflectPlane; 00129 const MovablePlane* mLinkedReflectPlane; 00131 mutable Plane mLastLinkedReflectionPlane; 00132 00134 bool mObliqueDepthProjection; 00136 mutable Plane mObliqueProjPlane; 00138 const MovablePlane* mLinkedObliqueProjPlane; 00140 mutable Plane mLastLinkedObliqueProjPlane; 00141 00142 00144 virtual const Vector3& getPositionForViewUpdate(void) const; 00146 virtual const Quaternion& getOrientationForViewUpdate(void) const; 00147 00148 00149 public: 00150 00151 Frustum(); 00152 virtual ~Frustum(); 00165 virtual void setFOVy(const Radian& fovy); 00166 #ifndef OGRE_FORCE_ANGLE_TYPES 00167 inline void setFOVy(Real fovy) { 00168 setFOVy ( Angle(fovy) ); 00169 } 00170 #endif//OGRE_FORCE_ANGLE_TYPES 00171 00174 virtual const Radian& getFOVy(void) const; 00175 00187 virtual void setNearClipDistance(Real nearDist); 00188 00191 virtual Real getNearClipDistance(void) const; 00192 00213 virtual void setFarClipDistance(Real farDist); 00214 00217 virtual Real getFarClipDistance(void) const; 00218 00227 virtual void setAspectRatio(Real ratio); 00228 00231 virtual Real getAspectRatio(void) const; 00232 00240 virtual const Matrix4& getProjectionMatrix(void) const; 00252 virtual const Matrix4& getStandardProjectionMatrix(void) const; 00253 00256 virtual const Matrix4& getViewMatrix(void) const; 00257 00262 virtual const Plane& getFrustumPlane( unsigned short plane ) const; 00263 00275 virtual bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const; 00276 00288 virtual bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const; 00289 00301 virtual bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const; 00302 00303 00305 const AxisAlignedBox& getBoundingBox(void) const; 00306 00308 Real getBoundingRadius(void) const; 00309 00311 void _updateRenderQueue(RenderQueue* queue); 00312 00314 const String& getMovableType(void) const; 00315 00317 const String& getName(void) const; 00318 00320 void _notifyCurrentCamera(Camera* cam); 00321 00323 const MaterialPtr& getMaterial(void) const; 00324 00326 void getRenderOperation(RenderOperation& op); 00327 00329 void getWorldTransforms(Matrix4* xform) const; 00330 00332 const Quaternion& getWorldOrientation(void) const; 00333 00335 const Vector3& getWorldPosition(void) const; 00336 00338 Real getSquaredViewDepth(const Camera* cam) const; 00339 00341 const LightList& getLights(void) const; 00342 00349 virtual const Vector3* getWorldSpaceCorners(void) const; 00350 00353 virtual void setProjectionType(ProjectionType pt); 00354 00357 virtual ProjectionType getProjectionType(void) const; 00358 00364 virtual void enableReflection(const Plane& p); 00373 virtual void enableReflection(const MovablePlane* p); 00374 00376 virtual void disableReflection(void); 00377 00379 virtual bool isReflected(void) const { return mReflect; } 00381 virtual const Matrix4& getReflectionMatrix(void) const { return mReflectMatrix; } 00383 virtual const Plane& getReflectionPlane(void) const { return mReflectPlane; } 00384 00394 virtual bool projectSphere(const Sphere& sphere, 00395 Real* left, Real* top, Real* right, Real* bottom) const; 00396 00397 00423 virtual void enableCustomNearClipPlane(const MovablePlane* plane); 00444 virtual void enableCustomNearClipPlane(const Plane& plane); 00446 virtual void disableCustomNearClipPlane(void); 00448 virtual bool isCustomNearClipPlaneEnabled(void) const 00449 { return mObliqueDepthProjection; } 00450 00451 00453 static const Real INFINITE_FAR_PLANE_ADJUST; 00454 }; 00455 00456 00457 } 00458 00459 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:45 2006