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 #include "OgreFrustum.h"
00041 #include "OgreRay.h"
00042 
00043 
00044 namespace Ogre {
00045 
00046 
00047 
00076     class _OgreExport Camera : public Frustum
00077     {
00078     protected:
00080         String mName;
00082         SceneManager *mSceneMgr;
00083 
00085         Quaternion mOrientation;
00086 
00088         Vector3 mPosition;
00089 
00091         mutable Quaternion mDerivedOrientation;
00092         mutable Vector3 mDerivedPosition;
00093 
00095         bool mYawFixed;
00097         Vector3 mYawFixedAxis;
00098 
00100         SceneDetailLevel mSceneDetail;
00101 
00103         unsigned int mVisFacesLastRender;
00104 
00106         static String msMovableType;
00107 
00109         SceneNode* mAutoTrackTarget;
00111         Vector3 mAutoTrackOffset;
00112 
00113         // Scene LOD factor used to adjust overall LOD
00114         Real mSceneLodFactor;
00116         Real mSceneLodFactorInv;
00117 
00118 
00123         Real mWLeft, mWTop, mWRight, mWBottom;
00125         bool mWindowSet;
00127         mutable std::vector<Plane> mWindowClipPlanes;
00128         // Was viewing window changed.
00129         mutable bool mRecalcWindow;
00130 
00131         // Internal functions for calcs
00132         void updateFrustum(void) const;
00133         void updateView(void) const;
00134         bool isViewOutOfDate(void) const;
00136         void invalidateFrustum(void);
00138         void invalidateView(void);
00139 
00140 
00145         virtual void setWindowImpl(void) const;
00147         const Vector3& getPositionForViewUpdate(void) const;
00149         const Quaternion& getOrientationForViewUpdate(void) const;
00150 
00151 
00152     public:
00155         Camera( const String& name, SceneManager* sm);
00156 
00159         virtual ~Camera();
00160 
00161 
00164         SceneManager* getSceneManager(void) const;
00165 
00168         virtual const String& getName(void) const;
00169 
00170 
00178         void setDetailLevel(SceneDetailLevel sd);
00179 
00182         SceneDetailLevel getDetailLevel(void) const;
00183 
00186         void setPosition(Real x, Real y, Real z);
00187 
00190         void setPosition(const Vector3& vec);
00191 
00194         const Vector3& getPosition(void) const;
00195 
00198         void move(const Vector3& vec);
00199 
00202         void moveRelative(const Vector3& vec);
00203 
00209         void setDirection(Real x, Real y, Real z);
00210 
00213         void setDirection(const Vector3& vec);
00214 
00215         /* Gets the camera's direction.
00216         */
00217         Vector3 getDirection(void) const;
00218 
00221         Vector3 getUp(void) const;
00222 
00225         Vector3 getRight(void) const;
00226 
00235         void lookAt( const Vector3& targetPoint );
00248         void lookAt(Real x, Real y, Real z);
00249 
00252         void roll(Real degrees);
00253 
00256         void yaw(Real degrees);
00257 
00260         void pitch(Real degrees);
00261 
00264         void rotate(const Vector3& axis, Real degrees);
00265 
00268         void rotate(const Quaternion& q);
00269 
00284         void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
00285 
00286 
00289         const Quaternion& getOrientation(void) const;
00290 
00293         void setOrientation(const Quaternion& q);
00294 
00299         void _renderScene(Viewport *vp, bool includeOverlays);
00300 
00303         friend std::ostream& operator<<(std::ostream& o, Camera& c);
00304 
00307         void _notifyRenderedFaces(unsigned int numfaces);
00308 
00311         unsigned int _getNumRenderedFaces(void) const;
00312 
00315         Quaternion getDerivedOrientation(void) const;
00318         Vector3 getDerivedPosition(void) const;
00321         Vector3 getDerivedDirection(void) const;
00322 
00324         const String& getMovableType(void) const;
00325 
00345         void setAutoTracking(bool enabled, SceneNode* target = 0, 
00346             const Vector3& offset = Vector3::ZERO);
00347 
00348 
00364         void setLodBias(Real factor = 1.0);
00365 
00370         Real getLodBias(void) const;
00371 
00372 
00373 
00378         Ray getCameraToViewportRay(Real screenx, Real screeny);
00379 
00381         Real _getLodBiasInverse(void) const;
00382 
00383 
00385         void _autoTrack(void);
00386 
00387 
00397         virtual void setWindow (Real Left, Real Top, Real Right, Real Bottom);
00399         virtual void resetWindow (void);
00401         virtual bool isWindowSet(void) const { return mWindowSet; }
00403         const std::vector<Plane>& getWindowPlanes(void) const;
00404 
00406         Real getBoundingRadius(void) const;
00408         SceneNode* getAutoTrackTarget(void) { return mAutoTrackTarget; }
00410         const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
00411         
00412 
00413     };
00414 
00415 } // namespace Ogre
00416 #endif

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