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

OgreCamera.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://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 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 __Camera_H__
00026 #define __Camera_H__
00027 
00028 // Default options
00029 #include "OgrePrerequisites.h"
00030 
00031 #include "OgreString.h"
00032 #include "OgreMovableObject.h"
00033 
00034 // Matrices & Vectors
00035 #include "OgreMatrix4.h"
00036 #include "OgreVector3.h"
00037 #include "OgrePlane.h"
00038 #include "OgreQuaternion.h"
00039 #include "OgreCommon.h"
00040 
00041 
00042 namespace Ogre {
00043 
00046     enum ProjectionType
00047     {
00048         PT_ORTHOGRAPHIC,
00049         PT_PERSPECTIVE
00050     };
00051 
00054     enum FrustumPlane
00055     {
00056         FRUSTUM_PLANE_NEAR   = 0,
00057         FRUSTUM_PLANE_FAR    = 1,
00058         FRUSTUM_PLANE_LEFT   = 2,
00059         FRUSTUM_PLANE_RIGHT  = 3,
00060         FRUSTUM_PLANE_TOP    = 4,
00061         FRUSTUM_PLANE_BOTTOM = 5
00062     };
00063 
00092     class _OgreExport Camera : public MovableObject
00093     {
00094     protected:
00096         String mName;
00098         SceneManager *mSceneMgr;
00099 
00101         Quaternion mOrientation;
00102 
00104         Vector3 mPosition;
00105 
00107         mutable Quaternion mLastParentOrientation;
00108         mutable Vector3 mLastParentPosition;
00109 
00111         mutable Quaternion mDerivedOrientation;
00112         mutable Vector3 mDerivedPosition;
00113 
00115         Real mFOVy;
00117         Real mFarDist;
00119         Real mNearDist;
00121         Real mAspect;
00123         bool mYawFixed;
00125         Vector3 mYawFixedAxis;
00126 
00128         mutable Plane mFrustumPlanes[6];
00129 
00131         ProjectionType mProjType;
00133         SceneDetailLevel mSceneDetail;
00134 
00135 
00137         mutable Matrix4 mProjMatrix;
00139         mutable Matrix4 mViewMatrix;
00141         mutable bool mRecalcFrustum;
00143         mutable bool mRecalcView;
00144 
00148         mutable Real mCoeffL[2], mCoeffR[2], mCoeffB[2], mCoeffT[2];
00149 
00150 
00151         // Internal functions for calcs
00152         void updateFrustum(void) const;
00153         void updateView(void) const;
00154         bool isViewOutOfDate(void) const;
00155         bool isFrustumOutOfDate(void) const;
00156 
00158         unsigned int mVisFacesLastRender;
00159 
00161         static String msMovableType;
00162 
00164         SceneNode* mAutoTrackTarget;
00166         Vector3 mAutoTrackOffset;
00167 
00168         // Scene LOD factor used to adjust overall LOD
00169         Real mSceneLodFactor;
00171         Real mSceneLodFactorInv;
00172 
00173     public:
00176         Camera(String name, SceneManager* sm);
00177 
00180         virtual ~Camera();
00181 
00182 
00185         SceneManager* getSceneManager(void) const;
00186 
00189         virtual const String& getName(void) const;
00190 
00193         void setProjectionType(ProjectionType pt);
00194 
00197         ProjectionType getProjectionType(void) const;
00198 
00206         void setDetailLevel(SceneDetailLevel sd);
00207 
00210         SceneDetailLevel getDetailLevel(void) const;
00211 
00214         void setPosition(Real x, Real y, Real z);
00215 
00218         void setPosition(const Vector3& vec);
00219 
00222         const Vector3& getPosition(void) const;
00223 
00226         void move(const Vector3& vec);
00227 
00230         void moveRelative(const Vector3& vec);
00231 
00237         void setDirection(Real x, Real y, Real z);
00238 
00241         void setDirection(const Vector3& vec);
00242 
00243         /* Gets the camera's direction.
00244         */
00245         Vector3 getDirection(void) const;
00246 
00247 
00256         void lookAt( const Vector3& targetPoint );
00269         void lookAt(Real x, Real y, Real z);
00270 
00273         void roll(Real degrees);
00274 
00277         void yaw(Real degrees);
00278 
00281         void pitch(Real degrees);
00282 
00285         void rotate(const Vector3& axis, Real degrees);
00286 
00289         void rotate(const Quaternion& q);
00290 
00305         void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
00306 
00319         void setFOVy(Real fovy);
00320 
00323         Real getFOVy(void) const;
00324 
00336         void setNearClipDistance(Real nearDist);
00337 
00340         Real getNearClipDistance(void) const;
00341 
00358         void setFarClipDistance(Real farDist);
00359 
00362         Real getFarClipDistance(void) const;
00363 
00372         void setAspectRatio(Real ratio);
00373 
00376         Real getAspectRatio(void) const;
00377 
00380         const Matrix4& getProjectionMatrix(void);
00381 
00384         const Matrix4& getViewMatrix(void);
00385 
00390         const Plane& getFrustumPlane( FrustumPlane plane );
00391 
00403         bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0);
00404 
00416         bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0);
00417 
00429         bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0);
00430 
00433         const Quaternion& getOrientation(void) const;
00434 
00437         void setOrientation(const Quaternion& q);
00438 
00443         void _renderScene(Viewport *vp, bool includeOverlays);
00444 
00447         friend std::ostream& operator<<(std::ostream& o, Camera& c);
00448 
00451         void _notifyRenderedFaces(unsigned int numfaces);
00452 
00455         unsigned int _getNumRenderedFaces(void) const;
00456 
00459         Quaternion getDerivedOrientation(void) const;
00462         Vector3 getDerivedPosition(void) const;
00465         Vector3 getDerivedDirection(void) const;
00466 
00468         void _notifyCurrentCamera(Camera* cam);
00469 
00471         const AxisAlignedBox& getBoundingBox(void) const;
00472 
00474         void _updateRenderQueue(RenderQueue* queue);
00475 
00477         const String getMovableType(void) const;
00478 
00498         void setAutoTracking(bool enabled, SceneNode* target = 0, 
00499             const Vector3& offset = Vector3::ZERO);
00500 
00501 
00517         void setLodBias(Real factor = 1.0);
00518 
00523         Real getLodBias(void);
00524 
00526         Real _getLodBiasInverse(void);
00527 
00528 
00530         void _autoTrack(void);
00531     };
00532 
00533 } // namespace Ogre
00534 #endif

Copyright © 2002 by The OGRE Team