All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GlobeCameraTouchController.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "GlobeCamera.h"
6 #include "ITouchController.h"
7 #include "GlobeCameraTouchControllerConfiguration.h"
8 #include "VectorMath.h"
9 #include "Rendering.h"
10 #include "ScreenProperties.h"
11 
12 namespace Eegeo
13 {
14  namespace Camera
15  {
16  namespace GlobeCamera
17  {
19  {
20  public:
22  const Rendering::ScreenProperties& screenProperties);
23 
24  virtual ~GlobeCameraTouchController();
25 
26  void SetDebugLogging(bool enableDebugLogging) { m_enableDebugLogging = enableDebugLogging; }
27 
28  virtual void Reset();
29 
30  virtual void Update(float deltaSeconds);
31 
32  virtual float GetZoomDelta() const { return m_zoomDelta; }
33  virtual float GetZoomVelocity() const { return m_zoomVelocity; }
34  virtual float GetRotationDelta() const { return m_rotationDelta; }
35  virtual const v2& GetPanPixelDelta() const { return m_panPixelDelta; }
36  virtual float GetTiltDelta() const { return m_tiltDelta; }
37 
38  virtual bool IsPanning() const { return m_panning; }
39  virtual bool IsTilting() const { return m_tilting; }
40  virtual bool IsRotating() const { return m_rotating; }
41 
42  virtual void SetPanIsHeavilyDamped(bool panIsHeavilyDamped) { m_panIsHeavilyDamped = panIsHeavilyDamped; }
43 
44  virtual const v2& GetPanAbsolutePixelCoord() const { return m_panAbsolutePixelCoord; }
45 
46  virtual float GetScreenScale() const { return m_screenScale; }
47 
48  virtual void Event_TouchRotate(const AppInterface::RotateData& data);
49  virtual void Event_TouchRotate_Start(const AppInterface::RotateData& data);
50  virtual void Event_TouchRotate_End(const AppInterface::RotateData& data);
51 
52  virtual void Event_TouchPinch(const AppInterface::PinchData& data);
53  virtual void Event_TouchPinch_Start(const AppInterface::PinchData& data);
54  virtual void Event_TouchPinch_End(const AppInterface::PinchData& data);
55 
56  virtual void Event_TouchPan(const AppInterface::PanData& data);
57  virtual void Event_TouchPan_Start(const AppInterface::PanData& data);
58  virtual void Event_TouchPan_End(const AppInterface::PanData& data);
59 
60  virtual void Event_TouchTap(const AppInterface::TapData& data) {}
61  virtual void Event_TouchDoubleTap(const AppInterface::TapData& data) {}
62 
63  virtual void Event_TouchDown(const AppInterface::TouchData& data);
64  virtual void Event_TouchMove(const AppInterface::TouchData& data) {}
65  virtual void Event_TouchUp(const AppInterface::TouchData& data) {}
66 
67  virtual void Event_Zoom(const AppInterface::ZoomData& data);
68 
69  virtual void Event_TiltStart(const AppInterface::TiltData& data);
70  virtual void Event_TiltEnd(const AppInterface::TiltData& data);
71  virtual void Event_Tilt(const AppInterface::TiltData& data);
72  private:
73  void UpdateRotationInertia(float deltaSeconds);
74  void UpdateZoomInertia(float deltaSeconds);
75  void UpdatePanInertia(float deltaSeconds);
76  void AccumulateTouchRotate(const AppInterface::RotateData& data);
77  void AccumulateTouchPanTilt(const AppInterface::PanData& data);
78  bool ShouldTilt(const AppInterface::PanData& data) const;
79  bool ShouldApplyPanInertia(const AppInterface::PanData& data) const;
80 
81  const GlobeCameraTouchControllerConfiguration m_configuration;
82 
83  bool m_enableDebugLogging;
84 
85  bool m_rotating;
86  bool m_pinching;
87  bool m_zooming;
88  bool m_panning;
89  bool m_tilting;
90  bool m_tiltStartBlocked;
91  bool m_panIsHeavilyDamped;
92 
93  float m_zoomDelta;
94  float m_zoomAccumulator;
95  float m_zoomVelocity;
96  int m_zoomSign;
97  float m_rotationDelta;
98  float m_rotationAccumulator;
99  float m_rotationVelocity;
100  float m_previousEventRotation;
101  float m_screenScale;
102 
103  int m_singleTouchRotateEvents;
104  int m_panEventsSinceGestureStart;
105  int m_framesSincePanEvent;
106 
107  Eegeo::v2 m_panPixelDelta;
108  Eegeo::v2 m_panPixelAccumulator;
109  Eegeo::v2 m_panPixelVelocity;
110  Eegeo::v2 m_previousEventPanPointRelative;
111  Eegeo::v2 m_panAbsolutePixelCoord;
112  Eegeo::v2 m_tiltOriginalExtents;
113 
114  float m_tiltAccumulator;
115  float m_tiltDelta;
116 
117  const Rendering::ScreenProperties m_screenProperties;
118  };
119  }
120  }
121 }