Inheritance #
Table of contents
-
var w: Vector4 = Vector4(0, 0, 0, 1) -
var x: Vector4 = Vector4(1, 0, 0, 0) -
var y: Vector4 = Vector4(0, 1, 0, 0) -
var z: Vector4 = Vector4(0, 0, 1, 0) -
static func create_depth_correction(flip_y: bool) -> Projection -
static func create_fit_aabb(aabb: AABB) -> Projection -
static func create_for_hmd(z_far: float) -> Projection -
static func create_frustum(z_far: float) -> Projection -
static func create_frustum_aspect(flip_fov: bool = false) -> Projection -
static func create_light_atlas_rect(rect: Rect2) -> Projection -
static func create_orthogonal(z_far: float) -> Projection -
static func create_orthogonal_aspect(flip_fov: bool = false) -> Projection -
static func create_perspective(flip_fov: bool = false) -> Projection -
static func create_perspective_hmd(convergence_dist: float) -> Projection -
const func determinant() -> float -
const func flipped_y() -> Projection -
const func get_aspect() -> float -
const func get_far_plane_half_extents() -> Vector2 -
const func get_fov() -> float -
static func get_fovy(aspect: float) -> float -
const func get_lod_multiplier() -> float -
const func get_pixels_per_meter(for_pixel_width: int) -> int -
const func get_projection_plane(plane: int) -> Plane -
const func get_viewport_half_extents() -> Vector2 -
const func get_z_far() -> float -
const func get_z_near() -> float -
const func inverse() -> Projection -
const func is_orthogonal() -> bool -
const func jitter_offseted(offset: Vector2) -> Projection -
const func perspective_znear_adjusted(new_znear: float) -> Projection -
const PLANE_NEAR = 0 enum Planes -
const PLANE_FAR = 1 enum Planes -
const PLANE_LEFT = 2 enum Planes -
const PLANE_TOP = 3 enum Planes -
const PLANE_RIGHT = 4 enum Planes -
const PLANE_BOTTOM = 5 enum Planes -
const IDENTITY = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1) -
const ZERO = Projection(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) -
Projection() -> Projection -
Projection(from: Projection) -> Projection -
Projection(from: Transform3D) -> Projection -
Projection(w_axis: Vector4) -> Projection -
enum Planes -
Projection != Projection -> bool -
Projection * Projection -> Projection -
Projection * Vector4 -> Vector4 -
Projection == Projection -> bool -
Projection[int] -> Vector4
Projection #
A 4×4 matrix for 3D projective transformations.
A 4×4 matrix used for 3D projective transformations. It can represent transformations such as translation, rotation, scaling, shearing, and perspective division. It consists of four Vector4 columns.
For purely linear transformations (translation, rotation, and scale), it is recommended to use Transform3D, as it is more performant and requires less memory.
Used internally as Camera3D's projection matrix.
Members #
var w: Vector4 = Vector4(0, 0, 0, 1)#
The projection matrix's W vector (column 3). Equivalent to array index 3.
var x: Vector4 = Vector4(1, 0, 0, 0)#
The projection matrix's X vector (column 0). Equivalent to array index 0.
var y: Vector4 = Vector4(0, 1, 0, 0)#
The projection matrix's Y vector (column 1). Equivalent to array index 1.
var z: Vector4 = Vector4(0, 0, 1, 0)#
The projection matrix's Z vector (column 2). Equivalent to array index 2.
Methods #
static func create_depth_correction(flip_y: bool) -> Projection#
Creates a new Projection that projects positions from a depth range of -1 to 1 to one that ranges from 0 to 1, and flips the projected positions vertically, according to flip_y.
static func create_fit_aabb(aabb: AABB) -> Projection#
Creates a new Projection that scales a given projection to fit around a given AABB in projection space.
static func create_for_hmd(z_far: float) -> Projection#
Creates a new Projection for projecting positions onto a head-mounted display with the given X:Y aspect ratio, distance between eyes, display width, distance to lens, oversampling factor, and depth clipping planes.
eye creates the projection for the left eye when set to 1, or the right eye when set to 2.
static func create_frustum(z_far: float) -> Projection#
Creates a new Projection that projects positions in a frustum with the given clipping planes.
static func create_frustum_aspect(flip_fov: bool = false) -> Projection#
Creates a new Projection that projects positions in a frustum with the given size, X:Y aspect ratio, offset, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
static func create_light_atlas_rect(rect: Rect2) -> Projection#
Creates a new Projection that projects positions into the given Rect2.
static func create_orthogonal(z_far: float) -> Projection#
Creates a new Projection that projects positions using an orthogonal projection with the given clipping planes.
static func create_orthogonal_aspect(flip_fov: bool = false) -> Projection#
Creates a new Projection that projects positions using an orthogonal projection with the given size, X:Y aspect ratio, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
static func create_perspective(flip_fov: bool = false) -> Projection#
Creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
static func create_perspective_hmd(convergence_dist: float) -> Projection#
Creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping distances. The projection is adjusted for a head-mounted display with the given distance between eyes and distance to a point that can be focused on.
eye creates the projection for the left eye when set to 1, or the right eye when set to 2.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
const func determinant() -> float#
Returns a scalar value that is the signed factor by which areas are scaled by this matrix. If the sign is negative, the matrix flips the orientation of the area.
The determinant can be used to calculate the invertibility of a matrix or solve linear systems of equations involving the matrix, among other applications.
const func flipped_y() -> Projection#
Returns a copy of this Projection with the signs of the values of the Y column flipped.
const func get_aspect() -> float#
Returns the X:Y aspect ratio of this Projection's viewport.
const func get_far_plane_half_extents() -> Vector2#
Returns the dimensions of the far clipping plane of the projection, divided by two.
const func get_fov() -> float#
Returns the horizontal field of view of the projection (in degrees).
static func get_fovy(aspect: float) -> float#
Returns the vertical field of view of the projection (in degrees) associated with the given horizontal field of view (in degrees) and aspect ratio.
Note: Unlike most methods of Projection, aspect is expected to be 1 divided by the X:Y aspect ratio.
const func get_lod_multiplier() -> float#
Returns the factor by which the visible level of detail is scaled by this Projection.
const func get_pixels_per_meter(for_pixel_width: int) -> int#
Returns the number of pixels with the given pixel width displayed per meter, after this Projection is applied.
const func get_projection_plane(plane: int) -> Plane#
Returns the clipping plane of this Projection whose index is given by plane.
plane should be equal to one of PLANE_NEAR, PLANE_FAR, PLANE_LEFT, PLANE_TOP, PLANE_RIGHT, or PLANE_BOTTOM.
const func get_viewport_half_extents() -> Vector2#
Returns the dimensions of the viewport plane that this Projection projects positions onto, divided by two.
const func get_z_far() -> float#
Returns the distance for this Projection beyond which positions are clipped.
const func get_z_near() -> float#
Returns the distance for this Projection before which positions are clipped.
const func inverse() -> Projection#
Returns a Projection that performs the inverse of this Projection's projective transformation.
const func is_orthogonal() -> bool#
Returns true if this Projection performs an orthogonal projection.
const func jitter_offseted(offset: Vector2) -> Projection#
Returns a Projection with the X and Y values from the given Vector2 added to the first and second values of the final column respectively.
const func perspective_znear_adjusted(new_znear: float) -> Projection#
Returns a Projection with the near clipping distance adjusted to be new_znear.
Note: The original Projection must be a perspective projection.
Annotations #
Constants #
const PLANE_NEAR = 0 enum Planes#
The index value of the projection's near clipping plane.
const PLANE_FAR = 1 enum Planes#
The index value of the projection's far clipping plane.
const PLANE_LEFT = 2 enum Planes#
The index value of the projection's left clipping plane.
const PLANE_TOP = 3 enum Planes#
The index value of the projection's top clipping plane.
const PLANE_RIGHT = 4 enum Planes#
The index value of the projection's right clipping plane.
const PLANE_BOTTOM = 5 enum Planes#
The index value of the projection bottom clipping plane.
const IDENTITY = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)#
A Projection with no transformation defined. When applied to other data structures, no transformation is performed.
const ZERO = Projection(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)#
A Projection with all values initialized to 0. When applied to other data structures, they will be zeroed.
Constructors #
Projection() -> Projection #
Constructs a default-initialized Projection identical to IDENTITY.
Note: In C#, this constructs a Projection identical to ZERO.
Projection(from: Projection) -> Projection #
Constructs a Projection as a copy of the given Projection.
Projection(from: Transform3D) -> Projection #
Constructs a Projection as a copy of the given Transform3D.
Projection(w_axis: Vector4) -> Projection #
Constructs a Projection from four Vector4 values (matrix columns).
Enums #
Planes#
enum Planes {
PLANE_NEAR = 0,
PLANE_FAR = 1,
PLANE_LEFT = 2,
PLANE_TOP = 3,
PLANE_RIGHT = 4,
PLANE_BOTTOM = 5,
} Notifications#
enum {
IDENTITY = Projection(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1),
ZERO = Projection(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
}Operators #
Projection != Projection -> bool#
Returns true if the projections are not equal.
Note: Due to floating-point precision errors, this may return true, even if the projections are virtually equal. An is_equal_approx method may be added in a future version of Godot.
Projection * Projection -> Projection#
Returns a Projection that applies the combined transformations of this Projection and right.
Projection * Vector4 -> Vector4#
Projects (multiplies) the given Vector4 by this Projection matrix.
Projection == Projection -> bool#
Returns true if the projections are equal.
Note: Due to floating-point precision errors, this may return false, even if the projections are virtually equal. An is_equal_approx method may be added in a future version of Godot.
Projection[int] -> Vector4#
Returns the column of the Projection with the given index.
Indices are in the following order: x, y, z, w.