Camera3d

Extends: Camera

Properties

  • fieldOfViewDegrees (float)
  • rollDegrees (float) — Rotation about the camera's own forward/view axis, in degrees. Positive = right
  • maxDrawDistance (float) — How far (world units) in front of the camera your game wants to draw. The
  • drawDistanceFadeFraction (float) — The far end of the draw distance over which objects fade out instead of popping
  • drawDistanceTransitionSeconds (float) — Seconds a change in draw distance (a quality level change, or a new
  • frustumNormals (CameraFrustumNormals)
  • frustrumConvergence (BGE.Math.Vector)
  • frustumRays (CameraFrustumRays)
  • name (string)

Constructor

new Camera3d(): Camera3d

Instance Methods

setTarget(targetPos: BGE.Math.Vector): void

Parameters

  • targetPos (BGE.Math.Vector)

Returns

  • void

rotate(rotation: BGE.Math.Vector): void

Parameters

  • rotation (BGE.Math.Vector)

Returns

  • void

checkMovement(): void

Returns

  • void

onCameraMovement(): void

Returns

  • void

recomputeFrustum(recomputeNormals: boolean): void

protected

Parameters

  • recomputeNormals (boolean)

Returns

  • void

distanceFromCameraFront(point: BGE.Math.Vector): float

Parameters

  • point (BGE.Math.Vector)

Returns

  • float

distanceFromFrustumSide( frustumSide: string, point: BGE.Math.Vector, ): float

Parameters

  • frustumSide (string)
  • point (BGE.Math.Vector)

Returns

  • float

isInView(point: BGE.Math.Vector): boolean

Parameters

  • point (BGE.Math.Vector)

Returns

  • boolean

isAnyInView(points: Array.<BGE.Math.Vector>): boolean

Parameters

  • points (Array.<BGE.Math.Vector>)

Returns

  • boolean

computeWorldToCameraMatrix(): void

Returns

  • void

getDrawMode(): BGE.SceneObjectDrawMode

Returns

toggleWireFrame(): void

Returns

  • void

worldPointToCanvasPoint( pWorld: BGE.Math.Vector, ): BGE.Math.Vector

Parameters

  • pWorld (BGE.Math.Vector)

Returns

  • BGE.Math.Vector

projectPointsWithDepth( points: Array.<BGE.Math.Vector>, out: Array.<float>, ): boolean

Projects many points at once, giving the same canvas point as worldPointToCanvasPoint() and the same depth as distanceFromCameraFront() for each, but faster.

Parameters

  • points (Array.<BGE.Math.Vector>) — world points
  • out (Array.<float>) — cleared, then filled with x, y, depth for each point in turn

Returns

  • boolean — false, leaving out incomplete, as soon as a point won't project

useDefaultCameraTarget(): void

Returns

  • void

getHorizonOfPlane_AI( plane: BGE.Math.Plane, ): Array.<BGE.Math.Vector>

Returns two screen-space points that define the visible horizon line of a plane. If the horizon does not intersect the camera frame, an empty array is returned.

Parameters

  • plane (BGE.Math.Plane)

Returns

  • Array.<BGE.Math.Vector> — Two points in screen space that define the horizon line of the plane, or an empty array if the plane is not visible.

findHorizonPoint( screenX: float, focalLength: float, nv: BGE.Math.Vector, ): BGE.Math.Vector

Parameters

  • screenX (float)
  • focalLength (float)
  • nv (BGE.Math.Vector)

Returns

  • BGE.Math.Vector

getFocalLength(): float

The camera's intrinsic focal length in pixels, derived from its real field of view and frame width. This is independent of any particular canvas size - see getFovDegreesForCanvasSize(), which uses it to answer "what FOV would a differently-sized canvas need to cover the same angular extent this camera actually sees."

Returns

  • float

getFovDegreesForCanvasSize(canvasSize: float): float

The (horizontal = vertical, meant for a square canvas) field of view a canvasSize x canvasSize canvas would need to cover the same angular extent as this camera's real field of view does for its own frame width, at the same focal length. Used by SceneObjectPlane to render its ground geometry into an enlarged canvas before rotating it for roll - see SceneObjectPlane.

Parameters

  • canvasSize (float)

Returns

  • float — degrees

getHorizonLine(plane: BGE.Math.Plane): Array.<BGE.Math.Vector>

Returns two screen-space points that define the visible horizon line of a plane. If the horizon does not intersect the camera frame, invalid is returned.

Parameters

  • plane (BGE.Math.Plane)

Returns

  • Array.<BGE.Math.Vector> — Two points in screen space that define the horizon line of the plane, or invalid if the plane is not visible.

getLevelHorizonLine( plane: BGE.Math.Plane, canvasSize: float, ): Array.<BGE.Math.Vector>

The horizon line as seen by an unrolled (rollDegrees = 0) camera at this camera's real position/orientation, against a canvasSize x canvasSize square canvas rather than the real frame - useful for a Mode-7-style renderer that needs a plane's horizon position in an enlarged, unrolled view before applying roll as a final image rotation. Not currently called anywhere in this engine (SceneObjectPlane computes each ground slice's own position via true perspective projection instead, and no longer needs an explicit horizon position) - kept as public Camera3d API.

Parameters

  • plane (BGE.Math.Plane)
  • canvasSize (float)

Returns

  • Array.<BGE.Math.Vector>

cameraPointToScreenPoint( pCamera: BGE.Math.Vector, ): BGE.Math.Vector

Converts from float (-1 to 1) screen space with (0,0) as the center of the screen to pixel coordinates

Parameters

  • pCamera (BGE.Math.Vector)

Returns

  • BGE.Math.Vector

getVerticalFOV(): float

Returns

  • float

getLevelUpVector(): BGE.Math.Vector

The "level" (rollDegrees = 0) up vector - see getUpVector() for the roll-aware version most callers want. SceneObjectPlane uses this one directly, since its ground rendering computes its own geometry against an unrolled view and applies roll as a final image rotation instead (see SceneObjectPlane).

Returns

  • BGE.Math.Vector

getLevelRightVector(): BGE.Math.Vector

The "level" (rollDegrees = 0) right vector - see getLevelUpVector().

Returns

  • BGE.Math.Vector

getUpVector(): BGE.Math.Vector

Returns

  • BGE.Math.Vector

getRightVector(): BGE.Math.Vector

Returns

  • BGE.Math.Vector

getPlaneDrawDistance(): float

How far a DrawablePlane (ground/terrain) draws: the farthest any quality level would draw objects, so objects always fade out on the ground - never past its edge. Doesn't change with the level, so the horizon stays put.

Returns

  • float

getEffectiveMaxDrawDistance(): float

The draw distance the renderer actually uses: drawDistanceOverride if set, otherwise maxDrawDistance * drawDistanceScale, then capped for this device.

Returns

  • float

getCurrentDrawDistance(): float

The draw distance actually used for clipping and fading this frame. Follows getEffectiveMaxDrawDistance(), easing toward it over drawDistanceTransitionSeconds whenever it changes.

Returns

  • float

snapDrawDistance(): void

Jumps straight to the target draw distance, skipping any transition in progress - e.g. after a camera cut, where easing the horizon would look odd.

Returns

  • void

advanceDrawDistance(dt: float): void

Moves the current draw distance toward its target by dt seconds' worth of the transition. Called every frame by checkMovement(); only call it yourself in tests.

Parameters

  • dt (float) — elapsed seconds (clamped to 0-0.1)

Returns

  • void

farDistanceChangedThisFrame(): boolean

Returns

  • boolean

isDrawDistanceTransitioning(): boolean

Returns

  • boolean

getDistanceFadeAlpha(point: BGE.Math.Vector): float

Parameters

  • point (BGE.Math.Vector)

Returns

  • float

supportsOcclusionCulling(): boolean

Returns

  • boolean

fadesWithDistance(): boolean

Returns

  • boolean

getDistanceFadeAlphaForPoints( points: Array.<BGE.Math.Vector>, ): float

Parameters

  • points (Array.<BGE.Math.Vector>)

Returns

  • float

projectionChangedThisFrame(): boolean

protected

Returns

  • boolean

onProjectionChange(): void

protected

Returns

  • void