OpenMW
apps/openmw/mwrender/camera.hpp
Go to the documentation of this file.
00001 #ifndef GAME_MWRENDER_CAMERA_H
00002 #define GAME_MWRENDER_CAMERA_H
00003 
00004 #include <string>
00005 
00006 #include "../mwworld/ptr.hpp"
00007 
00008 namespace Ogre
00009 {
00010     class Vector3;
00011     class Camera;
00012     class SceneNode;
00013 }
00014 
00015 namespace MWRender
00016 {
00017     class NpcAnimation;
00018 
00020     class Camera
00021     {
00022         struct CamData {
00023             float pitch, yaw, offset;
00024         };
00025 
00026         MWWorld::Ptr mTrackingPtr;
00027 
00028         Ogre::Camera *mCamera;
00029         Ogre::SceneNode *mCameraNode;
00030 
00031         NpcAnimation *mAnimation;
00032 
00033         bool mFirstPersonView;
00034         bool mPreviewMode;
00035         bool mFreeLook;
00036         float mNearest;
00037         float mFurthest;
00038         bool mIsNearest;
00039         bool mIsFurthest;
00040 
00041         struct {
00042             bool enabled, allowed;
00043         } mVanity;
00044 
00045         float mHeight, mCameraDistance;
00046         CamData mMainCam, mPreviewCam;
00047 
00048         bool mDistanceAdjusted;
00049 
00050         bool mVanityToggleQueued;
00051         bool mViewModeToggleQueued;
00052 
00054         void updateListener();
00055 
00056     public:
00057         Camera(Ogre::Camera *camera);
00058         ~Camera();
00059 
00061         void reset();
00062 
00065         void rotateCamera(const Ogre::Vector3 &rot, bool adjust);
00066 
00067         float getYaw();
00068         void setYaw(float angle);
00069 
00070         float getPitch();
00071         void setPitch(float angle);
00072 
00073         const std::string &getHandle() const;
00074 
00076         void attachTo(const MWWorld::Ptr &);
00077 
00078         void toggleViewMode();
00079 
00080         bool toggleVanityMode(bool enable);
00081         void allowVanityMode(bool allow);
00082 
00084         void togglePreviewMode(bool enable);
00085 
00090         void setSneakOffset();
00091 
00092         bool isFirstPerson() const
00093         { return !(mVanity.enabled || mPreviewMode || !mFirstPersonView); }
00094 
00095         void processViewChange();
00096 
00097         void update(float duration, bool paused=false);
00098 
00103         void setCameraDistance(float dist, bool adjust = false, bool override = true);
00104 
00106         void setCameraDistance();
00107 
00108         float getCameraDistance() const;
00109 
00110         void setAnimation(NpcAnimation *anim);
00111 
00113         void getPosition(Ogre::Vector3 &focal, Ogre::Vector3 &camera);
00114 
00115         void togglePlayerLooking(bool enable);
00116 
00117         bool isVanityOrPreviewModeEnabled();
00118 
00119         bool isNearest();
00120 
00121         bool isFurthest();
00122     };
00123 }
00124 
00125 #endif