All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CameraHelpers.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Camera.h"
6 #include "Space.h"
7 #include "Geometry.h"
8 #include "VectorMathDecl.h"
9 
10 namespace Eegeo
11 {
12  namespace Camera
13  {
14  namespace CameraHelpers
15  {
25  void CalculateLookAt(
26  const dv3& interestPointEcef,
27  const v3& interestBasisFoward,
28  float pitchRadians,
29  float distanceCameraToInterest,
30  dv3& out_cameraLocation,
31  v3& out_cameraDirection,
32  v3& out_cameraUp);
33 
39  void CalculateCameraOrientation(const v3& viewDirection, const v3& upAxis, m33& out_cameraOrientation);
40 
48  float GetAbsoluteBearingRadians(const dv3& pointEcef, const v3& headingDirection);
49 
56  void GetScreenPickRay(const RenderCamera& renderCamera, float screenPixelX, float screenPixelY, dv3& out_rayDirection);
57 
66  bool TryGetScreenPickIntersectionWithEarthCentredSphere(const RenderCamera& renderCamera, float screenPixelX, float screenPixelY, double sphereRadius, dv3& out_ecefIntersectionPoint);
67 
73  void EcefTangentBasisFromPointAndHeading(const dv3& pointEcef, float absoluteHeadingDegrees, Space::EcefTangentBasis& out_basis);
74 
80  v3 CameraRelativePoint(const dv3& pointEcef, const dv3& cameraOrigin);
81 
90  void GetAltitudeInterpolatedNearFar(float absoluteCameraAltitude, float approxTerrainAltitude, float approxTerrainAltitudeDelta, const double scalingFunctionAltitudeThreshold, float& out_nearDistance, float& out_farDistance);
91 
97  v3 GetScreenPositionFromLatLong(const Eegeo::Space::LatLong& latLong, const RenderCamera& renderCamera);
98 
104  v3 GetScreenPositionFromLatLongAlt(const Eegeo::Space::LatLongAltitude& latLongAlt, const RenderCamera& renderCamera);
105 
111  v3 GetScreenPositionFromEcef(const dv3& ecefPosition, const RenderCamera& renderCamera);
112 
113  Geometry::Ray ScreenPointToRay(const v2& screenPoint, const v2& screenDimensions, const m44& inverseViewProjectionMatrix, const dv3& viewOriginEcef);
114 
115  dv3 ScreenPointToRayDirection(const v2& screenPoint, const v2& screenDimensions, const m44& inverseViewProjectionMatrix);
116 
117  v3 ClipCoordToScreenPoint(const v4& clipCoord, const v2& screenDimensions);
118 
119  bool TryScreenProject(
120  const dv3& pointEcef,
121  const dv3& cameraOriginEcef,
122  const m44& viewProjectionMatrix,
123  const v2& screenDimensions,
124  v3& out_screenPoint);
125 
126  v3 ScreenProjectWithDefaultHomogeneousW(
127  const dv3& pointEcef,
128  const dv3& cameraOriginEcef,
129  const m44& viewProjectionMatrix,
130  const v2& screenDimensions,
131  const float defaultHomogeneousW = 0.1f);
132 
133  float VerticalFieldOfViewFromProjection(const m44& projectionMatrix);
134 
135  float NearClipDistanceFromProjection(const m44& projectionMatrix);
136 
137  float FarClipDistanceFromProjection(const m44& projectionMatrix);
138 
139  CameraState BuildCameraStateFromRenderCamera(const RenderCamera& camera, const dv3& cameraInterestPointEcef);
140  }
141  }
142 }