Emergency 20 Dokumentation  4.2.0
IngameCameraInputHandler.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <qsf/base/WeakPtr.h>
18 #include <qsf/job/JobProxy.h>
19 
20 #include <glm/gtc/quaternion.hpp>
21 
22 
23 //[-------------------------------------------------------]
24 //[ Forward declarations ]
25 //[-------------------------------------------------------]
26 namespace qsf
27 {
28  class Transform;
29  class JobArguments;
30 }
31 
32 
33 //[-------------------------------------------------------]
34 //[ Namespace ]
35 //[-------------------------------------------------------]
36 namespace em5
37 {
38 
39 
40  //[-------------------------------------------------------]
41  //[ Classes ]
42  //[-------------------------------------------------------]
52  {
53 
54 
55  //[-------------------------------------------------------]
56  //[ Public methods ]
57  //[-------------------------------------------------------]
58  public:
63  explicit IngameCameraInputHandler(uint32 id);
64 
69  virtual ~IngameCameraInputHandler();
70 
71  qsf::Entity* getCameraFollowEntity() const;
72  void setCameraFollowEntity(qsf::Entity* followEntity);
73 
78  void updateCameraFollowEntity(const qsf::JobArguments& jobArguments);
79 
80  void internalUpdateInputHandler(const qsf::Time& timePassed, bool inputBlocked);
81 
82  float getMinimumZoomout() const;
83  float getMaximumZoomout() const;
84  void setMaximumZoomout(float maximumZoomout);
85  void setMaximumPitch(float maximumPitch);
86  float getCurrentZoomout() const;
87 
88 
89  //[-------------------------------------------------------]
90  //[ Public virtual qsf::InputHandler methods ]
91  //[-------------------------------------------------------]
92  public:
93  virtual void updateInputHandler(const qsf::Time& timePassed) override;
94 
95 
96  //[-------------------------------------------------------]
97  //[ Public virtual qsf::InputListener methods ]
98  //[-------------------------------------------------------]
99  public:
100  virtual void eventReceived(const qsf::InputEvent& inputEvent, Response& response) override;
101 
102 
103  //[-------------------------------------------------------]
104  //[ Protected virtual qsf::EntityInputHandler methods ]
105  //[-------------------------------------------------------]
106  protected:
107  virtual void startupForEntity(qsf::Entity& entity) override;
108  virtual void shutdownForEntity(qsf::Entity& entity) override;
109 
110 
111  //[-------------------------------------------------------]
112  //[ Private definitions ]
113  //[-------------------------------------------------------]
114  private:
115  static const uint32 GROUND_MAP_ID;
116 
117 
118  //[-------------------------------------------------------]
119  //[ Private methods ]
120  //[-------------------------------------------------------]
121  private:
122  float getPitchFromZoomout(float zoomout) const;
123  glm::vec3 getMovementByMouse() const;
124  void correctCameraTransformation(qsf::Transform& transform, float& zoomout);
125  float getKeyboardScrolling() const;
126  bool isBlocked() const;
127 
128  // For follow entity mode
129  void onSelectionChange(const qsf::MessageParameters& parameters);
130  void abortCameraFollowMode(const qsf::MessageParameters& parameters);
131 
132 
133  //[-------------------------------------------------------]
134  //[ Private data ]
135  //[-------------------------------------------------------]
136  private:
137  // Configuration
138  float mMinimumZoomout;
139  float mMaximumZoomout;
140  float mMinimumPitch;
141  float mMaximumPitch;
142  bool mLinkPitchToZoomout;
143  float mMaximumVelocity;
144  float mMaximumAcceleration;
145  float mAutomaticDeceleration;
146  float mZoomSpeed;
147  float mZoomDeceleration;
148 
149  // State
150  glm::vec3 mMoveVelocity;
151  bool mForceUpdate;
152  float mCurrentZoomout;
153 
154  // Entity following
155  qsf::WeakPtr<qsf::Entity> mCameraFollowEntity;
156  bool mFollowingHelicopter;
157  float mLastFollowEntityYaw;
158  qsf::MessageProxy mOnSelectionChangedMessageProxy;
159  qsf::MessageProxy mOnMinimapClickedProxy;
160  qsf::JobProxy mCameraFollowJobProxy;
161 
162 
163  //[-------------------------------------------------------]
164  //[ CAMP reflection system ]
165  //[-------------------------------------------------------]
166  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
167 
168 
169  };
170 
171 
172 //[-------------------------------------------------------]
173 //[ Namespace ]
174 //[-------------------------------------------------------]
175 } // em5
176 
177 
178 //[-------------------------------------------------------]
179 //[ CAMP reflection system ]
180 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Entity class.
Definition: Entity.h:46
Message parameters class.
Definition: MessageParameters.h:34
unsigned int uint32
Definition: PlatformTypes.h:181
EMERGENCY 5 in-game camera input handler class.
Definition: IngameCameraInputHandler.h:51
Input event base class.
Definition: InputEvent.h:40
#define EM5_API_EXPORT
Definition: Export.h:28
Message listener proxy class.
Definition: MessageProxy.h:47
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
3D transform class
Definition: Transform.h:45
Definition: PickupPersonByParamedicAction.h:21
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
Orbiting camera input handler class.
Definition: OrbitingCameraInputHandler.h:43
Definition: InputListener.h:51
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32