All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
RouteSimulationGlobeCameraController.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Routes.h"
6 #include "Terrain.h"
7 #include "Collision.h"
8 #include "Rendering.h"
9 #include "RouteSimulationGlobeCameraControllerConfig.h"
10 #include "TerrainRayPicker.h"
11 #include "VectorMathDecl.h"
12 #include "GlobeCamera.h"
13 #include "Space.h"
14 #include "IInterestPointProvider.h"
15 #include "CameraState.h"
16 
17 namespace Eegeo
18 {
19  namespace Routes
20  {
21  namespace Simulation
22  {
23  namespace Camera
24  {
26  {
27  public:
28  enum RouteSimulationGlobeCameraControllerOrientationMode
29  {
30  UnlockedOrientation,
31  LockedToAbsoluteHeading,
32  LockedToCurrentLinkDirection
33  };
34 
35  private:
36  const RouteSimulationSession* m_pRouteSimulationSession;
39 
40  const Rendering::EnvironmentFlatteningService& m_environmentFlatteningService;
43 
44  float m_followDistanceMeters;
45  bool m_touchZoomEnabled;
46  bool m_tiltEnabled;
47  float m_followHeadingDegrees;
48  RouteSimulationGlobeCameraControllerOrientationMode m_orientationMode;
49  float m_headingVelocity;
50 
51  float m_deltaSecondsAccumulator;
52  float m_collisionDistance;
53  float m_collisionTimer;
54 
55 
56  public:
59  const Resources::Terrain::Heights::TerrainHeightProvider& terrainHeightProvider,
60  const Collision::ICollisionBvhProvider& collisionMeshResourceProvider,
61  const Rendering::EnvironmentFlatteningService& environmentFlatteningService,
63 
65 
67 
68  Eegeo::Camera::RenderCamera GetRenderCamera() const;
69 
70  bool IsActive() const { return m_pRouteSimulationSession != NULL; }
71 
72  RouteSimulationGlobeCameraControllerOrientationMode GetOrientationMode() const;
73 
74  void SetTouchZoomEnabled(bool enabled);
75 
76  void SetTiltEnabled(bool enabled);
77 
78  void SetFollowDistance(float followDistanceMetres);
79 
80  void LockFollowHeadingDegrees(float followHeadingDegrees);
81 
82  void LockFollowHeadingToCurrentLinkDirection();
83 
84  void SetOrientationMode(RouteSimulationGlobeCameraControllerOrientationMode mode);
85 
86  void UnlockFollowHeading();
87 
88  void Update(float dt);
89 
90  void UpdateScreenProperties(const Eegeo::Rendering::ScreenProperties& screenProperties);
91 
92  void StartFollowingSession(const RouteSimulationSession* routeSimulationSession);
93 
94  void StopFollowingSession();
95 
96  void SetView(double interestLatitudeDegrees,
97  double interestLongitudeDegrees,
98  float headingDegrees,
99  float distanceToInterest);
100 
101  void SetProjection(float fovRadians,
102  float nearClipDistance,
103  float farClipDistance);
104 
105  bool IsTouchZoomEnabled() const { return m_touchZoomEnabled; }
106 
107  bool IsTiltEnabled() const { return m_tiltEnabled; }
108 
109  float GetFollowDistanceMetres() const { return m_followDistanceMeters; }
110 
111  float GetDistanceToInterest() const;
112 
113  dv3 GetEcefInterestPoint() const;
114 
115  Eegeo::Camera::CameraState GetCameraState() const;
116 
117  private:
118 
119  void UpdateCameraInteractionSettings();
120 
121  void ComputeBasisFromHeading(const dv3& ecefPos, Space::EcefTangentBasis& interestBasis);
122 
123  void UpdateBasisFromLinkDirection(float deltaSeconds, const dv3& desiredInterestPos, Space::EcefTangentBasis& out_interestBasis);
124 
125  bool TryIntersectCameraRayWithTerrain(double& out_intersectionDist);
126 
127  float ClampedFollowDistance(float in) const;
128 
129  void ForceUnlockedOrientationIfGlobeMode();
130 
131  void UpdateInterestBasis(float deltaTime);
132  };
133  }
134  }
135  }
136 }