Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Projection
Une matrice 4×4 pour les transformations projectives 3D.
Description
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.
Note: In a boolean context, a projection will evaluate to false if it's equal to IDENTITY. Otherwise, a projection will always evaluate to true.
Note
Il y a des différences notables dans l'utilisation de cette API en C#. Voir Différences de l'API C# par rapport à GDScript pour plus d'informations.
Propriétés
|
||
|
||
|
||
|
Constructeurs
Projection(from: Projection) |
|
Projection(from: Transform3D) |
|
Projection(x_axis: Vector4, y_axis: Vector4, z_axis: Vector4, w_axis: Vector4) |
Méthodes
create_depth_correction(flip_y: bool) static |
|
create_fit_aabb(aabb: AABB) static |
|
create_for_hmd(eye: int, aspect: float, intraocular_dist: float, display_width: float, display_to_lens: float, oversample: float, z_near: float, z_far: float) static |
|
create_frustum(left: float, right: float, bottom: float, top: float, z_near: float, z_far: float) static |
|
create_frustum_aspect(size: float, aspect: float, offset: Vector2, z_near: float, z_far: float, flip_fov: bool = false) static |
|
create_light_atlas_rect(rect: Rect2) static |
|
create_orthogonal(left: float, right: float, bottom: float, top: float, z_near: float, z_far: float) static |
|
create_orthogonal_aspect(size: float, aspect: float, z_near: float, z_far: float, flip_fov: bool = false) static |
|
create_perspective(fovy: float, aspect: float, z_near: float, z_far: float, flip_fov: bool = false) static |
|
create_perspective_hmd(fovy: float, aspect: float, z_near: float, z_far: float, flip_fov: bool, eye: int, intraocular_dist: float, convergence_dist: float) 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(for_pixel_width: int) const |
|
get_projection_plane(plane: int) const |
|
get_viewport_half_extents() const |
|
get_z_far() const |
|
get_z_near() const |
|
inverse() const |
|
is_orthogonal() const |
|
jitter_offseted(offset: Vector2) const |
|
perspective_znear_adjusted(new_znear: float) const |
Opérateurs
operator !=(right: Projection) |
|
operator *(right: Projection) |
|
operator *(right: Vector4) |
|
operator ==(right: Projection) |
|
operator [](index: int) |
Énumérations
enum Planes: 🔗
Planes PLANE_NEAR = 0
The index value of the projection's near clipping plane.
Planes PLANE_FAR = 1
The index value of the projection's far clipping plane.
Planes PLANE_LEFT = 2
The index value of the projection's left clipping plane.
Planes PLANE_TOP = 3
The index value of the projection's top clipping plane.
Planes PLANE_RIGHT = 4
The index value of the projection's right clipping plane.
Planes PLANE_BOTTOM = 5
The index value of the projection bottom clipping plane.
Constantes
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.
Descriptions des propriétés
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.
Descriptions des constructeurs
Projection Projection() 🔗
Construit une Projection initialisé par défaut à IDENTITY.
Note : En C#, cela construit une Projection identique à ZERO.
Projection Projection(from: Projection)
Construit une Projection comme une copie de la Projection donnée.
Projection Projection(from: Transform3D)
Construit une Projection comme une copie de la Transform3D donnée.
Projection Projection(x_axis: Vector4, y_axis: Vector4, z_axis: Vector4, w_axis: Vector4)
Construit une Projection à partir de quatre valeurs Vector4 (colonnes de la matrice).
Descriptions des méthodes
Projection create_depth_correction(flip_y: bool) static 🔗
Crée une nouvelle Projection qui projette des positions allant d'une plage de profondeur de -1 à 1 à une plage qui va de 0 à 1 et retourne les positions projetées verticalement, selon 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(eye: int, aspect: float, intraocular_dist: float, display_width: float, display_to_lens: float, oversample: float, z_near: float, z_far: float) static 🔗
Crée une nouvelle Projection pour la projection de positions sur un écran monté sur la tête (Head Mounted Display) avec le rapport d'aspect X:Y, la distance entre les yeux, la largeur de l'écran, la distance à la lentille, le facteur de suréchantillonnage et les plans de coupe de profondeur donnés.
eye crée la projection de l'œil gauche lorsqu'elle est fixée à 1, ou l'œil droit lorsqu'elle est fixée à 2.
Projection create_frustum(left: float, right: float, bottom: float, top: float, z_near: float, z_far: float) static 🔗
Crée une nouvelle Projection qui projette des positions dans un frustum avec les plans de coupe donnés.
Projection create_frustum_aspect(size: float, aspect: float, offset: Vector2, z_near: float, z_far: float, flip_fov: bool = false) static 🔗
Crée un nouveau Projection qui projette des positions dans un frustum avec la taille, le rapport d'aspect X:Y, le décalage, et les plans de coupe donnés.
flip_fov détermine si le champ de vision de la projection est renversé sur sa diagonale.
Projection create_light_atlas_rect(rect: Rect2) static 🔗
Crée une nouvelle Projection qui projette des positions sur le Rect2 donné.
Projection create_orthogonal(left: float, right: float, bottom: float, top: float, z_near: float, z_far: float) static 🔗
Crée une nouvelle Projection qui projette des positions à l'aide d'une projection orthogonale avec les plans de coupe donnés.
Projection create_orthogonal_aspect(size: float, aspect: float, z_near: float, z_far: float, flip_fov: bool = false) static 🔗
Crée une nouvelle Projection qui projette des positions à l'aide d'une projection orthogonale avec la taille, le rapport d'aspect X:Y et les plans de coupe donnés.
flip_fov détermine si le champ de vision de la projection est inversé sur sa diagonale.
Projection create_perspective(fovy: float, aspect: float, z_near: float, z_far: float, flip_fov: bool = false) static 🔗
Crée une nouvelle Projection qui projette des positions à l'aide d'une projection de perspective avec le champ de vision en Y (en degrés), le rapport d'aspect X:Y et les plans de coupe donnés.
flip_fov détermine si le champ de vision de la projection est inversé sur sa diagonale.
Projection create_perspective_hmd(fovy: float, aspect: float, z_near: float, z_far: float, flip_fov: bool, eye: int, intraocular_dist: float, convergence_dist: float) static 🔗
Crée une nouvelle Projection qui projette des positions en utilisant une projection de perspective avec le champ de vision en Y (en degrés), le rapport d'aspect X:Y et les distances de coupe donnés. La projection est ajustée pour un écran monté sur la tête (Head Mounted Display) avec la distance entre les yeux et la distance à un point sur lequel se focaliser donnés.
eye crée la projection de l'œil gauche lorsqu'elle est fixée à 1, ou l'œil droit lorsqu'elle est fixée à 2.
flip_fov détermine si le champ de vision de la projection est inversé sur sa diagonale.
Renvoie une valeur scalaire qui est le facteur signé par lequel les aires sont redimensionnées par cette matrice. Si le signe est négatif, la matrice retourne l’orientation de la zone.
Le déterminant peut être utilisé pour calculer l’inversibilité d’une matrice ou pour résoudre des systèmes linéaires d'équations impliquant la matrice, ainsi que d’autres applications.
Projection flipped_y() const 🔗
Renvoie une copie de cette Projection avec les signes des valeurs de la colonne Y retournés.
Renvoie le rapport d'aspect X:Y de la vue de cette Projection.
Vector2 get_far_plane_half_extents() const 🔗
Renvoie les dimensions du plan de coupe lointain de la projection, divisées par deux.
Renvoie le champ de vision horizontal de la projection (en degrés).
float get_fovy(fovx: float, aspect: float) static 🔗
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.
float get_lod_multiplier() const 🔗
Returns the factor by which the visible level of detail is scaled by this Projection.
int get_pixels_per_meter(for_pixel_width: int) const 🔗
Returns for_pixel_width divided by the viewport's width measured in meters on the near plane, after this Projection is applied.
Plane get_projection_plane(plane: int) const 🔗
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.
Vector2 get_viewport_half_extents() const 🔗
Returns the dimensions of the viewport plane that this Projection projects positions onto, divided by two.
Returns the distance for this Projection beyond which positions are clipped.
Returns the distance for this Projection before which positions are clipped.
Projection inverse() const 🔗
Returns a Projection that performs the inverse of this Projection's projective transformation.
Returns true if this Projection performs an orthogonal projection.
Projection jitter_offseted(offset: Vector2) const 🔗
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.
Projection perspective_znear_adjusted(new_znear: float) const 🔗
Returns a Projection with the near clipping distance adjusted to be new_znear.
Note: The original Projection must be a perspective projection.
Descriptions des opérateurs
bool operator !=(right: Projection) 🔗
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 operator *(right: Projection) 🔗
Returns a Projection that applies the combined transformations of this Projection and right.
Vector4 operator *(right: Vector4) 🔗
Projects (multiplies) the given Vector4 by this Projection matrix.
bool operator ==(right: Projection) 🔗
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.
Vector4 operator [](index: int) 🔗
Returns the column of the Projection with the given index.
Indices are in the following order: x, y, z, w.