Up to date
This page is up to date for Godot 4.1
.
If you still find outdated information, please open an issue.
Projection¶
A 4×4 matrix for 3D projective transformations.
Description¶
A 4x4 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.
Properties¶
|
||
|
||
|
||
|
Constructors¶
Projection ( ) |
|
Projection ( Projection from ) |
|
Projection ( Transform3D from ) |
|
Projection ( Vector4 x_axis, Vector4 y_axis, Vector4 z_axis, Vector4 w_axis ) |
Methods¶
create_depth_correction ( bool flip_y ) static |
|
create_fit_aabb ( AABB aabb ) static |
|
create_for_hmd ( int eye, float aspect, float intraocular_dist, float display_width, float display_to_lens, float oversample, float z_near, float z_far ) static |
|
create_frustum ( float left, float right, float bottom, float top, float z_near, float z_far ) static |
|
create_frustum_aspect ( float size, float aspect, Vector2 offset, float z_near, float z_far, bool flip_fov=false ) static |
|
create_light_atlas_rect ( Rect2 rect ) static |
|
create_orthogonal ( float left, float right, float bottom, float top, float z_near, float z_far ) static |
|
create_orthogonal_aspect ( float size, float aspect, float z_near, float z_far, bool flip_fov=false ) static |
|
create_perspective ( float fovy, float aspect, float z_near, float z_far, bool flip_fov=false ) static |
|
create_perspective_hmd ( float fovy, float aspect, float z_near, float z_far, bool flip_fov, int eye, float intraocular_dist, float convergence_dist ) static |
|
determinant ( ) const |
|
flipped_y ( ) const |
|
get_aspect ( ) const |
|
get_far_plane_half_extents ( ) const |
|
get_fov ( ) const |
|
get_lod_multiplier ( ) const |
|
get_pixels_per_meter ( int for_pixel_width ) const |
|
get_projection_plane ( int plane ) const |
|
get_viewport_half_extents ( ) const |
|
get_z_far ( ) const |
|
get_z_near ( ) const |
|
inverse ( ) const |
|
is_orthogonal ( ) const |
|
jitter_offseted ( Vector2 offset ) const |
|
perspective_znear_adjusted ( float new_znear ) const |
Operators¶
operator != ( Projection right ) |
|
operator * ( Projection right ) |
|
operator * ( Vector4 right ) |
|
operator == ( Projection right ) |
|
operator [] ( int index ) |
Constants¶
PLANE_NEAR = 0
The index value of the projection's near clipping plane.
PLANE_FAR = 1
The index value of the projection's far clipping plane.
PLANE_LEFT = 2
The index value of the projection's left clipping plane.
PLANE_TOP = 3
The index value of the projection's top clipping plane.
PLANE_RIGHT = 4
The index value of the projection's right clipping plane.
PLANE_BOTTOM = 5
The index value of the projection bottom clipping plane.
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.
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.
Property Descriptions¶
Vector4 w = Vector4(0, 0, 0, 1)
The projection matrix's W vector (column 3). Equivalent to array index 3
.
Vector4 x = Vector4(1, 0, 0, 0)
The projection matrix's X vector (column 0). Equivalent to array index 0
.
Vector4 y = Vector4(0, 1, 0, 0)
The projection matrix's Y vector (column 1). Equivalent to array index 1
.
Vector4 z = Vector4(0, 0, 1, 0)
The projection matrix's Z vector (column 2). Equivalent to array index 2
.
Constructor Descriptions¶
Projection Projection ( )
Constructs a default-initialized Projection set to IDENTITY.
Projection Projection ( Projection from )
Constructs a Projection as a copy of the given Projection.
Projection Projection ( Transform3D from )
Constructs a Projection as a copy of the given Transform3D.
Projection Projection ( Vector4 x_axis, Vector4 y_axis, Vector4 z_axis, Vector4 w_axis )
Constructs a Projection from four Vector4 values (matrix columns).
Method Descriptions¶
Projection create_depth_correction ( bool flip_y ) static
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
.
Projection create_fit_aabb ( AABB aabb ) static
Creates a new Projection that scales a given projection to fit around a given AABB in projection space.
Projection create_for_hmd ( int eye, float aspect, float intraocular_dist, float display_width, float display_to_lens, float oversample, float z_near, float z_far ) static
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.
Projection create_frustum ( float left, float right, float bottom, float top, float z_near, float z_far ) static
Creates a new Projection that projects positions in a frustum with the given clipping planes.
Projection create_frustum_aspect ( float size, float aspect, Vector2 offset, float z_near, float z_far, bool flip_fov=false ) static
Creates a new Projection tha