Viewport¶
Namespace Nfty.Model.Render in assembly Nfty.Model.
The one mapping between normalized device coordinates and pixels. The rasterizer, the camera's pointer-anchored zoom and its pick-ray unprojection all go through here, so the viewport arithmetic exists exactly once and a change to it (a margin, a flipped axis) cannot reach one consumer and miss another.
Methods¶
NdcToScreen(Vector2, int, int)¶
NDC (x right, y up, both −1..1) to pixel coordinates (x right, y DOWN, origin at the top-left corner of the top-left pixel).
Parameters
ndc(Vector2) - Normalized device coordinates.width(int) - Viewport width in pixels.height(int) - Viewport height in pixels.
Returns. The position in pixels.
ScreenToNdc(Vector2, int, int)¶
The exact inverse of Viewport.NdcToScreen().
Parameters
screen(Vector2) - A position in pixels.width(int) - Viewport width in pixels.height(int) - Viewport height in pixels.
Returns. Normalized device coordinates.