OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
camera.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWRENDER_CAMERA_H
2 #define GAME_MWRENDER_CAMERA_H
3 
4 #include <string>
5 
6 #include <osg/ref_ptr>
7 #include <osg/Vec3>
8 #include <osg/Vec3d>
9 
10 #include "../mwworld/ptr.hpp"
11 
12 namespace osg
13 {
14  class Camera;
15  class NodeCallback;
16  class Node;
17 }
18 
19 namespace MWRender
20 {
21  class NpcAnimation;
22 
24  class Camera
25  {
26  struct CamData {
27  float pitch, yaw, offset;
28  };
29 
31  osg::ref_ptr<const osg::Node> mTrackingNode;
32  float mHeightScale;
33 
34  osg::ref_ptr<osg::Camera> mCamera;
35 
37 
40  bool mFreeLook;
41  float mNearest;
42  float mFurthest;
43  bool mIsNearest;
44 
45  struct {
47  } mVanity;
48 
51 
55 
57 
58  osg::ref_ptr<osg::NodeCallback> mUpdateCallback;
59 
60  public:
61  Camera(osg::Camera* camera);
62  ~Camera();
63 
65 
67  void updateCamera(osg::Camera* cam);
68 
70  void reset();
71 
74  void rotateCamera(float pitch, float yaw, bool adjust);
75 
76  float getYaw();
77  void setYaw(float angle);
78 
79  float getPitch();
80  void setPitch(float angle);
81 
83  void attachTo(const MWWorld::Ptr &);
84 
86  void toggleViewMode(bool force=false);
87 
88  bool toggleVanityMode(bool enable);
89  void allowVanityMode(bool allow);
90 
92  void togglePreviewMode(bool enable);
93 
95  void setSneakOffset(float offset);
96 
97  bool isFirstPerson() const
98  { return !(mVanity.enabled || mPreviewMode || !mFirstPersonView); }
99 
100  void processViewChange();
101 
102  void update(float duration, bool paused=false);
103 
108  void setCameraDistance(float dist, bool adjust = false, bool override = true);
109 
111  void setCameraDistance();
112 
113  float getCameraDistance() const;
114 
115  void setAnimation(NpcAnimation *anim);
116 
117  osg::Vec3d getFocalPoint();
118 
120  void getPosition(osg::Vec3f &focal, osg::Vec3f &camera);
121 
122  void togglePlayerLooking(bool enable);
123 
125 
126  bool isNearest();
127  };
128 }
129 
130 #endif
bool mVanityToggleQueued
Definition: camera.hpp:52
struct MWRender::Camera::@8 mVanity
float getPitch()
Definition: camera.cpp:284
bool toggleVanityMode(bool enable)
Definition: camera.cpp:201
float pitch
Definition: camera.hpp:27
osg::ref_ptr< osg::Camera > mCamera
Definition: camera.hpp:34
float mCameraDistance
Definition: camera.hpp:56
void setCameraDistance()
Restore default camera distance for current mode.
Definition: camera.cpp:347
bool mPreviewMode
Definition: camera.hpp:39
bool isNearest()
Definition: camera.cpp:406
Definition: camera.hpp:26
void attachTo(const MWWorld::Ptr &)
Attach camera to object.
Definition: camera.cpp:141
float mMaxCameraDistance
Definition: camera.hpp:49
CamData mMainCam
Definition: camera.hpp:50
bool mIsNearest
Definition: camera.hpp:43
float offset
Definition: camera.hpp:27
bool mFreeLook
Definition: camera.hpp:40
MWWorld::Ptr getTrackingPtr() const
Definition: camera.cpp:83
float yaw
Definition: camera.hpp:27
float mHeight
Definition: camera.hpp:49
CamData mPreviewCam
Definition: camera.hpp:50
void processViewChange()
Definition: camera.cpp:363
void setPitch(float angle)
Definition: camera.cpp:292
bool enabled
Definition: camera.hpp:46
void updateCamera(osg::Camera *cam)
Update the view matrix of cam.
Definition: camera.cpp:104
void getPosition(osg::Vec3f &focal, osg::Vec3f &camera)
Stores focal and camera world positions in passed arguments.
Definition: camera.cpp:386
bool isFirstPerson() const
Definition: camera.hpp:97
float getCameraDistance() const
Definition: camera.cpp:311
NpcAnimation * mAnimation
Definition: camera.hpp:36
osg::Vec3d getFocalPoint()
Definition: camera.cpp:88
void toggleViewMode(bool force=false)
Definition: camera.cpp:178
float mFurthest
Definition: camera.hpp:42
void allowVanityMode(bool allow)
Definition: camera.cpp:194
bool mViewModeToggleQueued
Definition: camera.hpp:54
Camera(osg::Camera *camera)
Definition: camera.cpp:45
void setSneakOffset(float offset)
Lowers the camera for sneak.
Definition: camera.cpp:258
float mHeightScale
Definition: camera.hpp:32
void rotateCamera(float pitch, float yaw, bool adjust)
Definition: camera.cpp:130
void setAnimation(NpcAnimation *anim)
Definition: camera.cpp:356
Camera control.
Definition: camera.hpp:24
float getYaw()
Definition: camera.cpp:263
bool mFirstPersonView
Definition: camera.hpp:38
bool allowed
Definition: camera.hpp:46
MWWorld::Ptr mTrackingPtr
Definition: camera.hpp:30
void update(float duration, bool paused=false)
Definition: camera.cpp:146
~Camera()
Definition: camera.cpp:78
void togglePreviewMode(bool enable)
Definition: camera.cpp:235
bool isVanityOrPreviewModeEnabled()
Definition: camera.cpp:401
Definition: npcanimation.hpp:23
float mNearest
Definition: camera.hpp:41
osg::ref_ptr< const osg::Node > mTrackingNode
Definition: camera.hpp:31
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
void setYaw(float angle)
Definition: camera.cpp:270
void enable(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:870
void reset()
Reset to defaults.
Definition: camera.cpp:122
bool mVanityToggleQueuedValue
Definition: camera.hpp:53
void togglePlayerLooking(bool enable)
Definition: camera.cpp:396
osg::ref_ptr< osg::NodeCallback > mUpdateCallback
Definition: camera.hpp:58