Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class 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://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 __Camera_H__
    00030 #define __Camera_H__
    00031
    00032 // Default options
    00033 #include "OgrePrerequisites.h"
    00034
    00035 #include "OgreString.h"
    00036 #include "OgreMovableObject.h"
    00037
    00038 // Matrices & Vectors
    00039 #include "OgreMatrix4.h"
    00040 #include "OgreVector3.h"
    00041 #include "OgrePlane.h"
    00042 #include "OgreQuaternion.h"
    00043 #include "OgreCommon.h"
    00044 #include "OgreFrustum.h"
    00045 #include "OgreRay.h"
    00046
    00047
    00048 namespace Ogre {
    00049
    00050
    00051
    00080     class _OgreExport Camera : public Frustum
    00081     {
    00082     protected:
    00084         String mName;
    00086         SceneManager *mSceneMgr;
    00087
    00089         Quaternion mOrientation;
    00090
    00092         Vector3 mPosition;
    00093
    00095         mutable Quaternion mDerivedOrientation;
    00096         mutable Vector3 mDerivedPosition;
    00097
    00099         mutable Quaternion mRealOrientation;
    00100         mutable Vector3 mRealPosition;
    00101
    00103         bool mYawFixed;
    00105         Vector3 mYawFixedAxis;
    00106
    00108         PolygonMode mSceneDetail;
    00109
    00111         unsigned int mVisFacesLastRender;
    00112
    00114         unsigned int mVisBatchesLastRender;
    00115
    00117         static String msMovableType;
    00118
    00120         SceneNode* mAutoTrackTarget;
    00122         Vector3 mAutoTrackOffset;
    00123
    00124         // Scene LOD factor used to adjust overall LOD
    00125         Real mSceneLodFactor;
    00127         Real mSceneLodFactorInv;
    00128
    00129
    00134         Real mWLeft, mWTop, mWRight, mWBottom;
    00136         bool mWindowSet;
    00138         mutable std::vector<Plane> mWindowClipPlanes;
    00139         // Was viewing window changed.
    00140         mutable bool mRecalcWindow;
    00142         Viewport* mLastViewport;
    00146         bool mAutoAspectRatio;
    00148         Frustum *mCullFrustum;
    00150         bool mUseRenderingDistance;
    00151
    00152
    00153         // Internal functions for calcs
    00154         bool isViewOutOfDate(void) const;
    00156         void invalidateFrustum(void) const;
    00158         void invalidateView(void) const;
    00159
    00160
    00165         virtual void setWindowImpl(void) const;
    00167         const Vector3& getPositionForViewUpdate(void) const;
    00169         const Quaternion& getOrientationForViewUpdate(void) const;
    00170
    00172         virtual std::vector<Vector4> getRayForwardIntersect(const Vector3& anchor, const Vector3 *dir, Real planeOffset) const;
    00173
    00174     public:
    00177         Camera( const String& name, SceneManager* sm);
    00178
    00181         virtual ~Camera();
    00182
    00183
    00186         SceneManager* getSceneManager(void) const;
    00187
    00190         virtual const String& getName(void) const;
    00191
    00192
    00200         void setPolygonMode(PolygonMode sd);
    00201
    00204         PolygonMode getPolygonMode(void) const;
    00205
    00208         void setPosition(Real x, Real y, Real z);
    00209
    00212         void setPosition(const Vector3& vec);
    00213
    00216         const Vector3& getPosition(void) const;
    00217
    00220         void move(const Vector3& vec);
    00221
    00224         void moveRelative(const Vector3& vec);
    00225
    00231         void setDirection(Real x, Real y, Real z);
    00232
    00235         void setDirection(const Vector3& vec);
    00236
    00237         /* Gets the camera's direction.
    00238         */
    00239         Vector3 getDirection(void) const;
    00240
    00243         Vector3 getUp(void) const;
    00244
    00247         Vector3 getRight(void) const;
    00248
    00257         void lookAt( const Vector3& targetPoint );
    00270         void lookAt(Real x, Real y, Real z);
    00271
    00274         void roll(const Radian& angle);
    00275 #ifndef OGRE_FORCE_ANGLE_TYPES
    00276         void roll(Real degrees) { roll ( Angle(degrees) ); }
    00277 #endif//OGRE_FORCE_ANGLE_TYPES
    00278
    00281         void yaw(const Radian& angle);
    00282 #ifndef OGRE_FORCE_ANGLE_TYPES
    00283         void yaw(Real degrees) { yaw ( Angle(degrees) ); }
    00284 #endif//OGRE_FORCE_ANGLE_TYPES
    00285
    00288         void pitch(const Radian& angle);
    00289 #ifndef OGRE_FORCE_ANGLE_TYPES
    00290         void pitch(Real degrees) { pitch ( Angle(degrees) ); }
    00291 #endif//OGRE_FORCE_ANGLE_TYPES
    00292
    00295         void rotate(const Vector3& axis, const Radian& angle);
    00296 #ifndef OGRE_FORCE_ANGLE_TYPES
    00297         void rotate(const Vector3& axis, Real degrees) { rotate ( axis, Angle(degrees) ); }
    00298 #endif//OGRE_FORCE_ANGLE_TYPES
    00299
    00302         void rotate(const Quaternion& q);
    00303
    00323         void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y );
    00324
    00325
    00328         const Quaternion& getOrientation(void) const;
    00329
    00332         void setOrientation(const Quaternion& q);
    00333
    00338         void _renderScene(Viewport *vp, bool includeOverlays);
    00339
    00342         _OgreExport friend std::ostream& operator<<(std::ostream& o, const Camera& c);
    00343
    00346         void _notifyRenderedFaces(unsigned int numfaces);
    00347
    00350         void _notifyRenderedBatches(unsigned int numbatches);
    00351
    00354         unsigned int _getNumRenderedFaces(void) const;
    00355
    00358         unsigned int _getNumRenderedBatches(void) const;
    00359
    00362         const Quaternion& getDerivedOrientation(void) const;
    00365         const Vector3& getDerivedPosition(void) const;
    00368         Vector3 getDerivedDirection(void) const;
    00371         Vector3 getDerivedUp(void) const;
    00374         Vector3 getDerivedRight(void) const;
    00375
    00378         const Quaternion& getRealOrientation(void) const;
    00381         const Vector3& getRealPosition(void) const;
    00384         Vector3 getRealDirection(void) const;
    00387         Vector3 getRealUp(void) const;
    00390         Vector3 getRealRight(void) const;
    00391
    00393         const String& getMovableType(void) const;
    00394
    00414         void setAutoTracking(bool enabled, SceneNode* target = 0,
    00415             const Vector3& offset = Vector3::ZERO);
    00416
    00417
    00433         void setLodBias(Real factor = 1.0);
    00434
    00439         Real getLodBias(void) const;
    00440
    00441
    00442
    00447         Ray getCameraToViewportRay(Real screenx, Real screeny) const;
    00448
    00450         Real _getLodBiasInverse(void) const;
    00451
    00452
    00454         void _autoTrack(void);
    00455
    00456
    00466         virtual void setWindow (Real Left, Real Top, Real Right, Real Bottom);
    00468         virtual void resetWindow (void);
    00470         virtual bool isWindowSet(void) const { return mWindowSet; }
    00472         const std::vector<Plane>& getWindowPlanes(void) const;
    00473
    00475         Real getBoundingRadius(void) const;
    00477         SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; }
    00479         const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; }
    00480
    00486         Viewport* getViewport(void) const {return mLastViewport;}
    00488         void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;}
    00489
    00497         void setAutoAspectRatio(bool autoratio);
    00498
    00501         bool getAutoAspectRatio(void) const;
    00502
    00514         void setCullingFrustum(Frustum* frustum) { mCullFrustum = frustum; }
    00516         Frustum* getCullingFrustum(void) { return mCullFrustum; }
    00517
    00522         virtual void forwardIntersect(const Plane& worldPlane, std::vector<Vector4>* intersect3d) const;
    00523
    00525         bool isVisible(const AxisAlignedBox& bound, FrustumPlane* culledBy = 0) const;
    00527         bool isVisible(const Sphere& bound, FrustumPlane* culledBy = 0) const;
    00529         bool isVisible(const Vector3& vert, FrustumPlane* culledBy = 0) const;
    00531         const Vector3* getWorldSpaceCorners(void) const;
    00533         const Plane& getFrustumPlane( unsigned short plane ) const;
    00535         bool projectSphere(const Sphere& sphere,
    00536             Real* left, Real* top, Real* right, Real* bottom) const;
    00538         Real getNearClipDistance(void) const;
    00540         Real getFarClipDistance(void) const;
    00542         const Matrix4& getViewMatrix(void) const;
    00551         const Matrix4& getViewMatrix(bool ownFrustumOnly) const;
    00557         virtual void setUseRenderingDistance(bool use) { mUseRenderingDistance = use; }
    00561         virtual bool getUseRenderingDistance(void) const { return mUseRenderingDistance; }
    00562
    00563      };
    00564
    00565 } // namespace Ogre
    00566 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Thu Mar 6 09:46:25 2008