Class ViewSpacePose
Turns a ViewSpacePoint into a Unity world position on the map's marker plane.
public static class ViewSpacePose
- Inheritance
-
objectViewSpacePose
Remarks
Assumes a full-screen pixel rect (cam.aspect == Screen.width /
Screen.height), a symmetric frustum, and no lens shift or custom
projectionMatrix - the same camera shape
MapViewTransform itself assumes throughout.
Methods
ToWorld(Camera, ViewSpacePoint, float)
World position for a projected view-space point, placed at the depth law markers already use (Depth(double, double)).
public static Vector3 ToWorld(Camera cam, ViewSpacePoint p, float planeDistance)
Parameters
camCameraCamera the point is posed against.
pViewSpacePointCamera-frame point from ProjectToViewSpace(MercatorPoint, double).
planeDistancefloatDistance from the camera the map plane sits at, in Unity world units.
Returns
- Vector3
World position. On a perspective
cam, finite for everyp, including one behind the camera or past the far view-distance cap - nothing there divides by Depth. An orthographic camera has no "behind the camera" plane in that sense; atDepth <= 0it falls back to the same finite perspective formula rather than the true (undefined there) parallel-projection answer - see remarks.
Remarks
Perspective: offsetPx * unityDepth - p.X * p.CameraDistance
/ p.Depth times planeDistance * p.Depth / p.CameraDistance
- cancels
DepthandCameraDistanceentirely, so nothing divides byDepth. Orthographic's world-per-pixel scale does not depend on depth, so it has nothing to canceloffsetPx's own divide with - unavoidable, and undefined atDepth <= 0, hence the perspective fallback there.