Camera3d
Extends: Camera
Properties
fieldOfViewDegrees(float) — The horizontal field of view at zoom 1. The one in use is getEffectiveFieldOfViewDegrees().rollDegrees(float) — Rotation about the camera's own forward/view axis, in degrees. Positive = rightpitchMode(string) —BGE.CameraPitchMode: how the pitch inorientationis shown. With "shear", the viewmaxDrawDistance(float) — How far (world units) in front of the camera your game wants to draw. ThedrawDistanceFadeFraction(float) — The far end of the draw distance over which objects fade out instead of poppingfog(BGE.Fog) — Distance fog (see BGE.Fog). Off by default.drawDistanceTransitionSeconds(float) — Seconds a change in draw distance (a quality level change, or a newfadeDistanceScaleLimit(float) — The most a Drawable.fadeDistanceScale counts for (0: no limit). The Renderer sets it eachfrustumNormals(CameraFrustumNormals)frustrumConvergence(BGE.Math.Vector)hasLevelForward(boolean) — the forward direction levelled onto the ground (unit x and z), unless looking straightlevelForwardX(float)levelForwardZ(float)frustumRays(CameraFrustumRays)name(string)
Constructor
new Camera3d(): Camera3dInstance 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
isMovingThisFrame(): boolean
Returns
boolean
onCameraMovement(): void
Returns
void
recomputeFrustum(recomputeNormals: boolean): void
Parameters
recomputeNormals(boolean)
Returns
void
getViewForward(): BGE.Math.Vector
The direction projections look along: orientation, or with pitchMode "shear" its level part (the pitch is shown by getPitchShiftY() instead). Don't change the vector returned.
Returns
BGE.Math.Vector
getPitchShiftY(): float
How far down (pixels) a shear camera moves the image for its pitch: focal length x tan(pitch), looking up positive, held to +-60 degrees. 0 with pitchMode "rotate".
Returns
float
getRollViewSize(): float
The side of the square a roll composite must have (drawn level, then turned about the image centre onto the frame) to cover the frame at any roll: the frame's diagonal, or under shear twice the distance from the moved image centre to the farthest corner.
Returns
float
getPrincipalY(): float
The canvas row the view direction passes through: the frame's middle, moved by getPitchShiftY() under shear.
Returns
float
distanceFromCameraFront(point: BGE.Math.Vector): float
Parameters
point(BGE.Math.Vector)
Returns
float
groundDistanceAhead(point: BGE.Math.Vector): float
Parameters
point(BGE.Math.Vector)
Returns
float
getFrontPlaneNormal(): BGE.Math.Vector
The near plane's normal, and a point on it below: distanceFromCameraFront(p) is (p - point) . normal, for inlining over many points.
Returns
BGE.Math.Vector
getFrontPlanePoint(): BGE.Math.Vector
Returns
BGE.Math.Vector
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
getSphereInViewVerdict(sphere: BGE.Math.BoundingSphere): integer
Parameters
sphere(BGE.Math.BoundingSphere)
Returns
integer
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
getEffectiveFieldOfViewDegrees(): float
The horizontal field of view in use: fieldOfViewDegrees narrowed by the zoom, as a lens with zoom times the focal length sees it (2 * atan(tan(fov / 2) / zoom)). Exactly fieldOfViewDegrees at zoom 1.
Returns
float— degrees
projectPointsWithDepth(
points: Array.<BGE.Math.Vector>,
out: Array.<float>,
markBehind?: boolean,
): 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 pointsout(Array.<float>) — cleared, then filled with x, y, depth for each point in turnmarkBehind(boolean, optional, default: false) — give a point behind the camera x 0, y 0 and depth BGE.PROJECTED_BEHIND_CAMERA_DEPTH, instead of stopping
Returns
boolean— false, leavingoutincomplete, as soon as a point won't project (never when markBehind is true)
projectOutlineCutAtNear(
points: Array.<BGE.Math.Vector>,
out: Array.<float>,
): boolean
projectPointsWithDepth() for a convex outline, cut where it crosses camera z BGE.QuadColumnNearZ(), as model faces are cut when drawn, so no point projects more than ~64x off center.
Parameters
points(Array.<BGE.Math.Vector>) — world points in order around the outlineout(Array.<float>) — cleared, then filled with x, y, depth for each point of the cut outline
Returns
boolean— false when none of it is in front of that z
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. With pitchMode "rotate" only: doesn't apply a shear camera's pitch shift.
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
getNearDepth(): float
The depth (see viewDepth()) of the near plane models are cut back to: focal length / 64, as BGE.QuadColumnNearZ()
Returns
float
viewDepth(point: BGE.Math.Vector): float
How far ahead of the eye point is, along the view direction: the depth perspective divides by. Unlike distanceFromCameraFront(), measured from the eye itself.
Parameters
point(BGE.Math.Vector) — world position
Returns
float— negative behind the eye
pixelsPerWorldUnitAtDepth(depth: float): float
Canvas pixels per world unit at depth ahead of the eye: focal length / depth.
Parameters
depth(float) — see viewDepth()
Returns
float— 0 at or nearer than the near plane (getNearDepth()), where it would blow up
pixelsPerWorldUnitAt(point: BGE.Math.Vector): float
Parameters
point(BGE.Math.Vector)
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. With pitchMode "rotate" only: doesn't apply a shear camera's pitch shift.
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>— With pitchMode "rotate" only: doesn't apply a shear camera's pitch shift.
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
getTrueVerticalFOV(): float
The vertical field of view the projection actually shows, for the frame's aspect ratio
Returns
float— degrees
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
getPlaneDrawDistanceForTexelScale(texelScale: float): float
How far a DrawablePlane whose texels each cover texelScale world units draws. The device cap limits the plane's bitmaps, which are sized in texels, so a coarser plane can reach that much farther. A texel scale of 1 or less is getPlaneDrawDistance().
Parameters
texelScale(float) — world units per texel
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
fixesDrawDistance(): boolean
Returns
boolean
farDistanceChangedThisFrame(): boolean
Returns
boolean
isDrawDistanceTransitioning(): boolean
Returns
boolean
getDistanceFadeAlpha(
point: BGE.Math.Vector,
distanceScale?: float,
): float
Parameters
point(BGE.Math.Vector)distanceScale(float, optional, default: "1.0")
Returns
float
isPerspective(): boolean
Returns
boolean
supportsOcclusionCulling(): boolean
Returns
boolean
fadesWithDistance(): boolean
Returns
boolean
getDistanceFadeAlphaForPoints(
points: Array.<BGE.Math.Vector>,
distanceScale?: float,
): float
Parameters
points(Array.<BGE.Math.Vector>)distanceScale(float, optional, default: "1.0")
Returns
float
getDistanceFadeAlphaForSphere(
sphere: BGE.Math.BoundingSphere,
distanceScale?: float,
): float
Parameters
sphere(BGE.Math.BoundingSphere)distanceScale(float, optional, default: "1.0")
Returns
float
projectionChangedThisFrame(): boolean
Returns
boolean
onProjectionChange(): void
Returns
void