TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class CameraViewport in Tinman.AddOns.Components

Default implementation of the ICameraViewportDepth interface.

sealed class CameraViewport implements ICameraViewportDepth
  INearAtZero

Remarks

A perspective projection is used, see PerspectiveFov. Use the Width, Height, NearAtZero and ZRange properties to configure the projection matrix. The field-of-view angle and view matrices are taken from the camera (see Camera).

Public / Attributes

Camera

The Camera object.

public property Camera { get }
type Camera
value [not-null] The Camera object.
implements ICameraViewport.Camera

Center

Returns the screen coordinates that represent the camera direction.

public property Center { get }
type Vec2F
value The screen coordinates that represent the camera direction.
implements ICameraViewport.Center

Remarks:

Usually, this is the center of the screen, but might be a different location, for example to compensate for GUI overlays.

CenterOffset

Specifies the screen center offset to use.

public property CenterOffset { get set }
type Vec2F
value The screen center offset, in pixels.

Remarks:

Defaults to Zero.

See also:

Widget.UserInterfaceCenterOffset

Height

Returns the viewport height, in screen pixels.

public property Height { get set }
type int32
value [>0] The viewport height.
implements ICameraViewport.Height

Remarks:

Defaults to 768.

MatrixProjection

The current projection matrix.

public property MatrixProjection { get }
type Mat4D
value The projection matrix.

See also:

Camera.MatrixPerspective

MatrixView

The current view matrix.

public property MatrixView { get }
type Mat4D
value The view matrix.

See also:

Camera.MatrixView

MatrixViewLocal

The current view matrix (camera-centric).

public property MatrixViewLocal { get }
type Mat4D
value The view matrix.

See also:

Camera.MatrixViewLocal

MatrixViewProjection

The current view-projection matrix.

public property MatrixViewProjection { get }
type Mat4D
value The view-projection matrix.

See also:

MatrixView
MatrixProjection

MatrixViewProjectionInverse

The current inverse view-projection matrix.

public property MatrixViewProjectionInverse { get }
type Mat4D
value The inverse view-projection matrix.

See also:

MatrixViewProjection

MatrixViewProjectionLocal

The current view-projection matrix (camera-centric).

public property MatrixViewProjectionLocal { get }
type Mat4D
value The view-projection matrix.

See also:

MatrixViewLocal
MatrixProjection

MatrixViewProjectionLocalInverse

The current inverse view-projection matrix (camera-centric).

public property MatrixViewProjectionLocalInverse { get }
type Mat4D
value The inverse view-projection matrix.

See also:

MatrixViewProjectionLocal

NearAtZero

Is the near-clipping plane mapped to 0 in clip-space (true), or is it mapped to -1 (false)?

public property NearAtZero { get set }
type bool
value The mapping behaviour for the near-clipping plane.
implements INearAtZero.NearAtZero

Remarks:

The default value is true.

Width

Returns the viewport width, in screen pixels.

public property Width { get set }
type int32
value [>0] The viewport width.
implements ICameraViewport.Width

Remarks:

Defaults to 1024.

ZLog

Use logarithmic depth values?

public property ZLog { get set }
type bool
value true to use logarithmic depth values, false to use linear ones.

Remarks:

When set to true, the normalized depth value zLog is computed like this:

zLog = max(1, z + 1) / log(zFar + 1)
where z is the denormalized depth value of the point and zFar is the denormalized depth value of the far plane.

Defaults to false.

ZRange

The depth range to use for computing normalized depth values in the range [0..1].

public property ZRange { get set }
type RangeD
value The depth range:
Start is the denormalized depth value of Near,
End is the denormalized depth value of Far
implements ICameraViewportDepth.ZRange

Remarks:

Defaults to [0.001..20000000].

Public / Constructors

CameraViewport

Creates a new instance of CameraViewport.

public constructor CameraViewport (Camera camera)
params camera [not-null] The camera object.

Public / Methods

DepthDenormalize

Denormalizes the given depth value.

[Pure]
public method DepthDenormalize (float32 z)
type float64
params z The normalized depth value, in the range [0..1].
returns The denormalized depth value (see ZRange).
implements ICameraViewportDepth.DepthDenormalize

DepthNormalize

Normalizes the given depth value.

[Pure]
public method DepthNormalize (float64 z)
type float32
params z The denormalized depth value (see ZRange).
returns The normalized depth value, in the range [0..1].
implements ICameraViewportDepth.DepthNormalize

ScreenToWorld

Computes a viewport ray for the given screen coordinates.

[Pure]
public method ScreenToWorld (float32 pixelX, float32 pixelY, out Vec3D origin, out Vec3D direction)
params pixelX The screen X-coordinate (see PerspectiveRay).
  pixelY The screen Y-coordinate (see PerspectiveRay).
  origin Output of viewport ray origin, in world-space.
  direction Output of unit-length viewport ray direction, in world-space.
implements ICameraViewport.ScreenToWorld

Update

Updates the given view frustum, using the current view-projection matrix.

public method Update (ViewFrustum frustum, bool viewLocal = false)
params frustum [not-null] The view frustum to update.
  viewLocal true to use MatrixViewProjectionLocal, false to use MatrixViewProjection. Defaults to false.

WorldToScreen

Projects the given point onto the viewport plane.

[Pure]
public method WorldToScreen (float64 x, float64 y, float64 z)
type Vec2F
params x The point X-coordinate, in world-space.
  y The point Y-coordinate, in world-space.
  z The point Z-coordinate, in world-space.
returns The screen coordinates or Undefined if the given point is undefined or behind the viewport plane.
implements ICameraViewport.WorldToScreen

WorldToScreenDepth

Projects the given point onto the screen.

[Pure]
public method WorldToScreenDepth (float64 x, float64 y, float64 z, float64 offset = 0)
type Vec3F
params x The point X-coordinate, in world-space.
  y The point Y-coordinate, in world-space.
  z The point Z-coordinate, in world-space.
  offset Optional depth offset to use, given as a circle radius in screen-space. If positive, the projected depth will be decreased (i.e. nearer). If negative, the projected depth will be increased (i.e. farther). Default to 0.
returns The screen coordinates (see X and Y) and normalized depth value (see Z) in the range [0..1] or Undefined if the given point is undefined or behind the viewport plane.
implements ICameraViewportDepth.WorldToScreenDepth