Camera utility functions. More...
Functions | |
void | CalculateLookAt (const dv3 &interestPointEcef, const v3 &interestBasisFoward, float pitchRadians, float distanceCameraToInterest, dv3 &out_cameraLocation, v3 &out_cameraDirection, v3 &out_cameraUp) |
calculate a coordinate frame for positioning and orienting a camera to look towards an interest point More... | |
void | CalculateCameraOrientation (const v3 &viewDirection, const v3 &upAxis, m33 &out_cameraOrientation) |
create a rotation matrix suitable for orienting a camera More... | |
float | GetAbsoluteBearingRadians (const dv3 &pointEcef, const v3 &headingDirection) |
calculate an absolute bearing in radians from an ECEF point and heading direction More... | |
v3 | GetScreenPositionFromLatLong (const Eegeo::Space::LatLong &latLong, const RenderCamera &renderCamera) |
project a latitude and longitude coordinate in the 3D world to a screen coordinate More... | |
v3 | GetScreenPositionFromLatLongAlt (const Eegeo::Space::LatLongAltitude &latLongAlt, const RenderCamera &renderCamera) |
project a latitude, longitude & altitude coordinate in the 3D world to a screen coordinate More... | |
v3 | GetScreenPositionFromEcef (const dv3 &ecefPosition, const RenderCamera &renderCamera) |
project an ECEF coordinate in the 3D world to a screen coordinate More... | |
void | GetScreenPickRay (const RenderCamera &renderCamera, float screenPixelX, float screenPixelY, dv3 &out_rayDirection) |
create a ray in ECEF coordinates passing through camera origin and a screen at pixel coordinates More... | |
bool | TryGetScreenPickIntersectionWithEarthCentredSphere (const RenderCamera &renderCamera, float screenPixelX, float screenPixelY, double sphereRadius, dv3 &out_ecefIntersectionPoint) |
Attempt to find the intersection point of a sphere centred at ECEF origin, with a ray from camera origin and passing through a point defined in screenspace. More... | |
void | EcefTangentBasisFromPointAndHeading (const dv3 &pointEcef, float absoluteHeadingDegrees, Space::EcefTangentBasis &out_basis) |
Create an Ecef tangent space coordinate frame from a point and a bearing angle. More... | |
v3 | CameraRelativePoint (const dv3 &pointEcef, const dv3 &cameraOrigin) |
calculate the single-precision vector to translate from cameraOrigin to pointEcef More... | |
void | GetAltitudeInterpolatedNearFar (float absoluteCameraAltitude, float approxTerrainAltitude, float approxTerrainAltitudeDelta, const double scalingFunctionAltitudeThreshold, float &out_nearDistance, float &out_farDistance) |
calculate a recommended near and far clipping plane distance based on camera altitude and height of terrain to ensure everything is within the frustum More... | |
Geometry::Ray | ScreenPointToRay (const v2 &screenPoint, const v2 &screenDimensions, const m44 &inverseViewProjectionMatrix, const dv3 &viewOriginEcef) |
dv3 | ScreenPointToRayDirection (const v2 &screenPoint, const v2 &screenDimensions, const m44 &inverseViewProjectionMatrix) |
v3 | ClipCoordToScreenPoint (const v4 &clipCoord, const v2 &screenDimensions) |
bool | TryScreenProject (const dv3 &pointEcef, const dv3 &cameraOriginEcef, const m44 &viewProjectionMatrix, const v2 &screenDimensions, v3 &out_screenPoint) |
v3 | ScreenProjectWithDefaultHomogeneousW (const dv3 &pointEcef, const dv3 &cameraOriginEcef, const m44 &viewProjectionMatrix, const v2 &screenDimensions, const float defaultHomogeneousW) |
float | VerticalFieldOfViewFromProjection (const m44 &projectionMatrix) |
float | NearClipDistanceFromProjection (const m44 &projectionMatrix) |
float | FarClipDistanceFromProjection (const m44 &projectionMatrix) |
CameraState | BuildCameraStateFromRenderCamera (const RenderCamera &camera, const dv3 &cameraInterestPointEcef) |
Camera utility functions.
void Eegeo::Camera::CameraHelpers::CalculateCameraOrientation | ( | const v3 & | viewDirection, |
const v3 & | upAxis, | ||
m33 & | out_cameraOrientation | ||
) |
create a rotation matrix suitable for orienting a camera
viewDirection | view direction of camera in ECEF space |
upAxis | up direction of camera in ECEF space. |
out_cameraOrientation | [out] resultant camera model-to-world rotation matrix |
void Eegeo::Camera::CameraHelpers::CalculateLookAt | ( | const dv3 & | interestPointEcef, |
const v3 & | interestBasisFoward, | ||
float | pitchRadians, | ||
float | distanceCameraToInterest, | ||
dv3 & | out_cameraLocation, | ||
v3 & | out_cameraDirection, | ||
v3 & | out_cameraUp | ||
) |
calculate a coordinate frame for positioning and orienting a camera to look towards an interest point
interestPointEcef | location of camera interest point in ECEF coordinates |
interestBasisFoward | direction vector defining the azimuth orientation of the camera direction |
pitchRadians | elevation angle in radians between the Earth tangent plane at interest point and the camera view direction |
distanceCameraToInterest | desired distance in metres from camera origin to interest point |
out_cameraLocation | [out] Camera origin in ECEF coordinates |
out_cameraDirection | [out] Camera view direction in ECEF space |
out_cameraUp | [out] Camera up direction in ECEF space |
v3 Eegeo::Camera::CameraHelpers::CameraRelativePoint | ( | const dv3 & | pointEcef, |
const dv3 & | cameraOrigin | ||
) |
calculate the single-precision vector to translate from cameraOrigin to pointEcef
pointEcef | point in ECEF coordinates |
cameraOrigin | camera origin location in ECEF coordinates |
void Eegeo::Camera::CameraHelpers::EcefTangentBasisFromPointAndHeading | ( | const dv3 & | pointEcef, |
float | absoluteHeadingDegrees, | ||
Space::EcefTangentBasis & | out_basis | ||
) |
Create an Ecef tangent space coordinate frame from a point and a bearing angle.
pointEcef | point in ECEF coordinates |
absoluteHeadingDegrees | bearing angle in degrees, clockwise from North |
out_basis | [out] resultant EcefTangentBasis located at pointEcef, and oriented to that out_basis.GetForward() points in the direction specified by bearing angle |
float Eegeo::Camera::CameraHelpers::GetAbsoluteBearingRadians | ( | const dv3 & | pointEcef, |
const v3 & | headingDirection | ||
) |
calculate an absolute bearing in radians from an ECEF point and heading direction
pointEcef | point in ECEF coordinates |
headingDirection | direction vector in ECEF space defining an orientation at pointECEF. The heading is projected onto the Earth tangent plane at pointECEF. The bearing angle is the angle between the resultant direction, and a vector on the tangent plane pointing towards the North Pole |
void Eegeo::Camera::CameraHelpers::GetAltitudeInterpolatedNearFar | ( | float | absoluteCameraAltitude, |
float | approxTerrainAltitude, | ||
float | approxTerrainAltitudeDelta, | ||
const double | scalingFunctionAltitudeThreshold, | ||
float & | out_nearDistance, | ||
float & | out_farDistance | ||
) |
calculate a recommended near and far clipping plane distance based on camera altitude and height of terrain to ensure everything is within the frustum
The | altitude in meters of the camera |
The | approximate altitude of the highest terrain in the scene |
The | difference between the highest and lowest terrain in the scene |
Altitude | at which the method for scaling the near/far bounds changes (Default 15000m) |
out_nearDistance | [out] resultant recommended Near value based on the provided altitudes |
out_farDistance | [out] resultant reecommended Far value based on the provided altitudes |
void Eegeo::Camera::CameraHelpers::GetScreenPickRay | ( | const RenderCamera & | renderCamera, |
float | screenPixelX, | ||
float | screenPixelY, | ||
dv3 & | out_rayDirection | ||
) |
create a ray in ECEF coordinates passing through camera origin and a screen at pixel coordinates
renderCamera | camera object defining world, view and projection camera transforms |
screenPixelX | horizonal screen coordinate in pixels |
screenPixelY | vertical screen coordinate in pixels |
out_rayDirection | [out] resultant ray direction. The ray origin is renderCamera.GetEcefLocation() |
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromEcef | ( | const dv3 & | ecefPosition, |
const RenderCamera & | renderCamera | ||
) |
project an ECEF coordinate in the 3D world to a screen coordinate
The | ECEF coordinate in the world to project to screen |
The | RenderCamera used to display the world. |
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromLatLong | ( | const Eegeo::Space::LatLong & | latLong, |
const RenderCamera & | renderCamera | ||
) |
project a latitude and longitude coordinate in the 3D world to a screen coordinate
The | LatLong coordinate in the world to project to screen |
The | RenderCamera used to display the world. |
v3 Eegeo::Camera::CameraHelpers::GetScreenPositionFromLatLongAlt | ( | const Eegeo::Space::LatLongAltitude & | latLongAlt, |
const RenderCamera & | renderCamera | ||
) |
project a latitude, longitude & altitude coordinate in the 3D world to a screen coordinate
The | LatLongAlt coordinate in the world to project to screen |
The | RenderCamera used to display the world. |
bool Eegeo::Camera::CameraHelpers::TryGetScreenPickIntersectionWithEarthCentredSphere | ( | const RenderCamera & | renderCamera, |
float | screenPixelX, | ||
float | screenPixelY, | ||
double | sphereRadius, | ||
dv3 & | out_ecefIntersectionPoint | ||
) |
Attempt to find the intersection point of a sphere centred at ECEF origin, with a ray from camera origin and passing through a point defined in screenspace.
renderCamera | camera object defining world, view and projection camera transforms |
screenPixelX | horizonal screen coordinate in pixels |
screenPixelY | vertical screen coordinate in pixels |
sphereRadius | radius of sphere in metres, typically Eegeo::Space::EarthConstants::Radius for the Earth |
out_ecefIntersectionPoint | [out] intersection point between ray and sphere, in ECEF space |