# 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 (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 __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         mutable Quaternion mRealOrientation;
    00096         mutable Vector3 mRealPosition;
    00097
    00099         bool mYawFixed;
    00101         Vector3 mYawFixedAxis;
    00102
    00104         PolygonMode mSceneDetail;
    00105
    00107         unsigned int mVisFacesLastRender;
    00108
    00110         static String msMovableType;
    00111
    00113         SceneNode* mAutoTrackTarget;
    00115         Vector3 mAutoTrackOffset;
    00116
    00117         // Scene LOD factor used to adjust overall LOD
    00118         Real mSceneLodFactor;
    00120         Real mSceneLodFactorInv;
    00121
    00122
    00127         Real mWLeft, mWTop, mWRight, mWBottom;
    00129         bool mWindowSet;
    00131         mutable std::vector<Plane> mWindowClipPlanes;
    00132         // Was viewing window changed.
    00133         mutable bool mRecalcWindow;
    00135         Viewport* mLastViewport;
    00139         bool mAutoAspectRatio;
    00141         Frustum *mCullFrustum;
    00143         bool mUseRenderingDistance;
    00144
    00145
    00146         // Internal functions for calcs
    00147         bool isViewOutOfDate(void) const;
    00149         void invalidateFrustum(void) const;
    00151         void invalidateView(void) const;
    00152
    00153
    00158         virtual void setWindowImpl(void) const;
    00160         const Vector3& getPositionForViewUpdate(void) const;
    00162         const Quaternion& getOrientationForViewUpdate(void) const;
    00163
    00164
    00165     public:
    00168         Camera( const String& name, SceneManager* sm);
    00169
    00172         virtual ~Camera();
    00173
    00174
    00177         SceneManager* getSceneManager(void) const;
    00178
    00181         virtual const String& getName(void) const;
    00182
    00183
    00191         void setPolygonMode(PolygonMode sd);
    00192
    00195         PolygonMode getPolygonMode(void) const;
    00196
    00199         void setPosition(Real x, Real y, Real z);
    00200
    00203         void setPosition(const Vector3& vec);
    00204
    00207         const Vector3& getPosition(void) const;
    00208
    00211         void move(const Vector3& vec);
    00212
    00215         void moveRelative(const Vector3& vec);
    00216
    00222         void setDirection(Real x, Real y, Real z);
    00223
    00226         void setDirection(const Vector3& vec);
    00227
    00228         /* Gets the camera's direction.
    00229         */
    00230         Vector3 getDirection(void) const;
    00231
    00234         Vector3 getUp(void) const;
    00235
    00238         Vector3 getRight(void) const;
    00239
    00248         void lookAt( const Vector3& targetPoint );
    00261         void lookAt(Real x, Real y, Real z);
    00262
    00265         void roll(const Radian& angle);
    00266 #ifndef OGRE_FORCE_ANGLE_TYPES
    00267         void roll(Real degrees) { roll ( Angle(degrees) ); }
    00268 #endif//OGRE_FORCE_ANGLE_TYPES
    00269
    00272         void yaw(const Radian& angle);
    00273 #ifndef OGRE_FORCE_ANGLE_TYPES
    00274         void yaw(Real degrees) { yaw ( Angle(degrees) ); }
    00275 #endif//OGRE_FORCE_ANGLE_TYPES
    00276
    00279         void pitch(const Radian& angle);
    00280 #ifndef OGRE_FORCE_ANGLE_TYPES
    00281         void pitch(Real degrees) { pitch ( Angle(degrees) ); }
    00282 #endif//OGRE_FORCE_ANGLE_TYPES
    00283
    00286         void rotate(const Vector3& axis, const Radian& angle);
    00287 #ifndef OGRE_FORCE_ANGLE_TYPES
    00288         void rotate(const Vector3& axis, Real degrees) { rotate ( axis, Angle(degrees) ); }
    00289 #endif//OGRE_FORCE_ANGLE_TYPES
    00290
    00293         void rotate(const Quaternion& q);
    00294
    00314         void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
    00315
    00316
    00319         const Quaternion& getOrientation(void) const;
    00320
    00323         void setOrientation(const Quaternion& q);
    00324
    00329         void _renderScene(Viewport *vp, bool includeOverlays);
    00330
    00333         friend std::ostream& operator<<(std::ostream& o, Camera& c);
    00334
    00337         void _notifyRenderedFaces(unsigned int numfaces);
    00338
    00341         unsigned int _getNumRenderedFaces(void) const;
    00342
    00345         const Quaternion& getDerivedOrientation(void) const;
    00348         const Vector3& getDerivedPosition(void) const;
    00351         Vector3 getDerivedDirection(void) const;
    00354         Vector3 getDerivedUp(void) const;
    00357         Vector3 getDerivedRight(void) const;
    00358
    00361         const Quaternion& getRealOrientation(void) const;
    00364         const Vector3& getRealPosition(void) const;
    00367         Vector3 getRealDirection(void) const;
    00370         Vector3 getRealUp(void) const;
    00373         Vector3 getRealRight(void) const;
    00374
    00376         const String& getMovableType(void) const;
    00377
    00397         void setAutoTracking(bool enabled, SceneNode* target = 0,
    00398             const Vector3& offset = Vector3::ZERO);
    00399
    00400
    00416         void setLodBias(Real factor = 1.0);
    00417
    00422         Real getLodBias(void) const;
    00423
    00424
    00425
    00430         Ray getCameraToViewportRay(Real screenx, Real screeny) const;
    00431
    00433         Real _getLodBiasInverse(void) const;
    00434
    00435
    00437         void _autoTrack(void);
    00438
    00439
    00449         virtual void setWindow (Real Left, Real Top, Real Right, Real Bottom);
    00451         virtual void resetWindow (void);
    00453         virtual bool isWindowSet(void) const { return mWindowSet; }
    00455         const std::vector<Plane>& getWindowPlanes(void) const;
    00456
    00458         Real getBoundingRadius(void) const;
    00460         SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
    00462         const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
    00463
    00469         Viewport* getViewport(void) const {return mLastViewport;}
    00471         void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}
    00472
    00480         void setAutoAspectRatio(bool autoratio);
    00481
    00484         bool getAutoAspectRatio(void) const;
    00485
    00497         void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
    00499         Frustum* getCullingFrustum(void) { return mCullFrustum; }
    00500
    00502         bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
    00504         bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
    00506         bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
    00508         const Vector3* getWorldSpaceCorners(void) const;
    00510         const Plane& getFrustumPlane( unsigned short plane ) const;
    00512         bool projectSphere(const Sphere& sphere,
    00513             Real* left, Real* top, Real* right, Real* bottom) const;
    00515         Real getNearClipDistance(void) const;
    00517         Real getFarClipDistance(void) const;
    00519         const Matrix4& getViewMatrix(void) const;
    00528         const Matrix4& getViewMatrix(bool ownFrustumOnly) const;
    00534         virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
    00538         virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }
    00539      };
    00540
    00541 } // namespace Ogre
    00542 #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 17 15:39:07 2006