All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GlobeCameraController.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "GlobeCamera.h"
6 #include "Rendering.h"
7 #include "Streaming.h"
8 #include "Terrain.h"
9 #include "GlobeCameraControllerConfiguration.h"
10 #include "EcefTangentBasis.h"
11 #include "GlobeCameraModeTransition.h"
12 #include "GlobeCameraTerrainFollower.h"
13 #include "GlobeCameraTouchSettings.h"
14 #include "IInterestPointProvider.h"
15 #include "CameraState.h"
16 #include "RenderCamera.h"
17 #include "IGlobeCameraDistanceBasedPitchControl.h"
18 #include "IGlobeCameraDistanceBasedFovControl.h"
19 
20 namespace Eegeo
21 {
22  namespace Camera
23  {
24  namespace GlobeCamera
25  {
43  {
44  public:
46  const Eegeo::Rendering::EnvironmentFlatteningService& environmentFlatteningService,
47  const Streaming::ResourceCeilingProvider& resourceCeilingProvider,
48  const GlobeCameraTouchController& touchController,
49  const GlobeCameraControllerConfiguration& configuration,
50  const Eegeo::Rendering::ScreenProperties& screenProperties);
51  virtual ~GlobeCameraController();
52 
53  virtual Camera::RenderCamera GetRenderCamera() const { return m_camera; }
54 
55  virtual void Update(float deltaSeconds);
56 
57  virtual void UpdateScreenProperties(const Eegeo::Rendering::ScreenProperties& screenProperties);
58 
59  virtual const Space::EcefTangentBasis& GetInterestBasis() const { return m_interestBasis; }
60  virtual float GetDistanceToInterest() const { return m_distanceToInterest; }
61 
62  dv3 GetEcefInterestPoint() const;
63 
64  virtual void SetInterestBasis(const Space::EcefTangentBasis& interestBasis);
65  virtual void SetView(Space::EcefTangentBasis interestBasis, float distanceToInterest, bool snapToTerrain = false);
66 
67  virtual void SetProjection(float fovRadians,
68  float nearClipDistance,
69  float farClipDistance);
70 
71  virtual bool IsZoomDistanceAboveGlobeModeThreshold() const;
72 
73  virtual const GlobeCameraTouchSettings& GetTouchSettings() const { return m_touchSettings; }
74  virtual void SetTouchSettings(const GlobeCameraTouchSettings& settings) { m_touchSettings = settings; }
75 
76  virtual const GlobeCameraControllerConfiguration& GetConfig() const { return m_configuration; }
77 
78  virtual dv3 ComputeNonFlattenedCameraPosition() const;
79 
80  void ApplyTilt(float tiltDegrees) { m_tiltDegrees = tiltDegrees; };
81  const float GetTiltDegrees() const { return m_tiltDegrees; }
82 
83  virtual float CalculatePitchDegrees() const;
84  virtual float CalculateMaximumAltitude() const;
85 
86  const GlobeCameraTouchController& GetGlobeCameraTouchController() const { return m_touchController; }
87 
88  CameraState GetCameraState() const;
89 
90  void SetDistanceBasedPitchControl(IGlobeCameraDistanceBasedPitchControl *pDistanceBasedPitchControl);
91  void SetDistanceBasedFovControl(IGlobeCameraDistanceBasedFovControl *pDistanceBasedFovControl);
92  void SetScreenSpaceOffsetControl(IGlobeCameraScreenSpaceOffsetControl *pScreenSpaceOffsetControl);
93 
94  void SetVerticallyLocked(bool isVerticallyLocked);
95 
96  protected:
97  virtual float CalculateFovDegrees() const;
98 
99  private:
100  enum Mode
101  {
102  CityMode,
103  TransitioningToGlobeMode,
104  GlobeMode,
105  };
106 
107  Mode DetermineMode() const;
108 
109  void UpdateCityMode(float deltaSeconds, const v2& touchPanPixelDelta, float touchRotateAngleDelta, float touchTiltAngleDelta);
110  void UpdateGlobeMode(float deltaSeconds, const v2& touchPanPixelDelta);
111  void UpdateTransitionMode(float deltaSeconds, const v2& touchPanPixelDelta);
112 
113  void ApplyZoom(float deltaSeconds, float touchZoomDelta, float& out_distanceToInterest) const;
114  void ApplyRotation(float deltaSeconds, float touchRotateAngleDelta, v3& out_heading) const;
115  void ApplyTilt(float touchTiltAngleDelta, float& out_tilt) const;
116  void ApplyPanCityMode(float deltaSeconds, const v2& touchPanPixelDelta, dv3& out_interestPointEcef) const;
117  void ApplyPanGlobeMode(float deltaSeconds, const v2& touchPanPixelDelta, dv3& out_interestPointEcef) const;
118  float ClampedDistanceToInterest(float distanceToInterest) const;
119 
120  void SetRenderCameraTransforms();
121  void SetRenderCameraViewTransform(float pitchRadians);
122  void SetRenderCameraProjectionTransform(float verticalFovRadians);
123 
124  const Eegeo::Rendering::EnvironmentFlatteningService& m_environmentFlatteningService;
125  const Streaming::ResourceCeilingProvider& m_resourceCeilingProvider;
126  const GlobeCameraTouchController& m_touchController;
127 
128  GlobeCameraControllerConfiguration m_configuration;
129  Camera::RenderCamera m_camera;
130  GlobeCameraModeTransition m_globeModeTransition;
131  GlobeCameraTerrainFollower m_terrainFollower;
132 
133  Mode m_mode;
134  bool m_snapToTerrain;
135  bool m_isVerticallyLocked;
136  Space::EcefTangentBasis m_interestBasis;
137  float m_distanceToInterest;
138 
139  float m_tiltDegrees;
140 
141  IGlobeCameraDistanceBasedPitchControl* m_pDistanceBasedPitchControl;
142  IGlobeCameraDistanceBasedFovControl* m_pDistanceBasedFovControl;
143  IGlobeCameraScreenSpaceOffsetControl* m_pScreenSpaceOffsetControl;
144 
145  GlobeCameraTouchSettings m_touchSettings;
146  };
147  }
148  }
149 }