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 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; 00131 Viewport* mLastViewport; 00135 bool mAutoAspectRatio; 00136 00137 // Internal functions for calcs 00138 void updateFrustum(void) const; 00139 void updateView(void) const; 00140 bool isViewOutOfDate(void) const; 00142 void invalidateFrustum(void) const; 00144 void invalidateView(void) const; 00145 00146 00151 virtual void setWindowImpl(void) const; 00153 const Vector3& getPositionForViewUpdate(void) const; 00155 const Quaternion& getOrientationForViewUpdate(void) const; 00156 00157 00158 public: 00161 Camera( const String& name, SceneManager* sm); 00162 00165 virtual ~Camera(); 00166 00167 00170 SceneManager* getSceneManager(void) const; 00171 00174 virtual const String& getName(void) const; 00175 00176 00184 void setDetailLevel(SceneDetailLevel sd); 00185 00188 SceneDetailLevel getDetailLevel(void) const; 00189 00192 void setPosition(Real x, Real y, Real z); 00193 00196 void setPosition(const Vector3& vec); 00197 00200 const Vector3& getPosition(void) const; 00201 00204 void move(const Vector3& vec); 00205 00208 void moveRelative(const Vector3& vec); 00209 00215 void setDirection(Real x, Real y, Real z); 00216 00219 void setDirection(const Vector3& vec); 00220 00221 /* Gets the camera's direction. 00222 */ 00223 Vector3 getDirection(void) const; 00224 00227 Vector3 getUp(void) const; 00228 00231 Vector3 getRight(void) const; 00232 00241 void lookAt( const Vector3& targetPoint ); 00254 void lookAt(Real x, Real y, Real z); 00255 00258 void roll(const Radian& angle); 00259 #ifndef OGRE_FORCE_ANGLE_TYPES 00260 void roll(Real degrees) { roll ( Angle(degrees) ); } 00261 #endif//OGRE_FORCE_ANGLE_TYPES 00262 00265 void yaw(const Radian& angle); 00266 #ifndef OGRE_FORCE_ANGLE_TYPES 00267 void yaw(Real degrees) { yaw ( Angle(degrees) ); } 00268 #endif//OGRE_FORCE_ANGLE_TYPES 00269 00272 void pitch(const Radian& angle); 00273 #ifndef OGRE_FORCE_ANGLE_TYPES 00274 void pitch(Real degrees) { pitch ( Angle(degrees) ); } 00275 #endif//OGRE_FORCE_ANGLE_TYPES 00276 00279 void rotate(const Vector3& axis, const Radian& angle); 00280 #ifndef OGRE_FORCE_ANGLE_TYPES 00281 void rotate(const Vector3& axis, Real degrees) { rotate ( axis, Angle(degrees) ); } 00282 #endif//OGRE_FORCE_ANGLE_TYPES 00283 00286 void rotate(const Quaternion& q); 00287 00302 void setFixedYawAxis( bool useFixed, const Vector3& fixedAxis = Vector3::UNIT_Y ); 00303 00304 00307 const Quaternion& getOrientation(void) const; 00308 00311 void setOrientation(const Quaternion& q); 00312 00317 void _renderScene(Viewport *vp, bool includeOverlays); 00318 00321 friend std::ostream& operator<<(std::ostream& o, Camera& c); 00322 00325 void _notifyRenderedFaces(unsigned int numfaces); 00326 00329 unsigned int _getNumRenderedFaces(void) const; 00330 00333 const Quaternion& getDerivedOrientation(void) const; 00336 const Vector3& getDerivedPosition(void) const; 00339 Vector3 getDerivedDirection(void) const; 00340 00342 const String& getMovableType(void) const; 00343 00363 void setAutoTracking(bool enabled, SceneNode* target = 0, 00364 const Vector3& offset = Vector3::ZERO); 00365 00366 00382 void setLodBias(Real factor = 1.0); 00383 00388 Real getLodBias(void) const; 00389 00390 00391 00396 Ray getCameraToViewportRay(Real screenx, Real screeny) const; 00397 00399 Real _getLodBiasInverse(void) const; 00400 00401 00403 void _autoTrack(void); 00404 00405 00415 virtual void setWindow (Real Left, Real Top, Real Right, Real Bottom); 00417 virtual void resetWindow (void); 00419 virtual bool isWindowSet(void) const { return mWindowSet; } 00421 const std::vector<Plane>& getWindowPlanes(void) const; 00422 00424 Real getBoundingRadius(void) const; 00426 SceneNode* getAutoTrackTarget(void) const { return mAutoTrackTarget; } 00428 const Vector3& getAutoTrackOffset(void) const { return mAutoTrackOffset; } 00429 00435 Viewport* getViewport(void) const {return mLastViewport;} 00437 void _notifyViewport(Viewport* viewport) {mLastViewport = viewport;} 00438 00446 void setAutoAspectRatio(bool autoratio); 00447 00450 bool getAutoAspectRatio(void) const; 00451 }; 00452 00453 } // namespace Ogre 00454 #endif
Copyright © 2000-2005 by The OGRE Team
Last modified Wed Feb 23 00:19:03 2005