Struct gdnative::core_types::Transform
source · [−]Expand description
Affine 3D transform (3x4 matrix).
Used for 3D linear transformations. Uses a basis + origin representation.
Expressed as a 3x4 matrix, this transform consists of 3 basis (column) vectors a
, b
, c
as well as an origin o
; more information in Self::from_basis_origin()
:
[ a.x b.x c.x o.x ]
[ a.y b.y c.y o.y ]
[ a.z b.z c.z o.z ]
See also Transform in the Godot API doc.
Fields
basis: Basis
The basis is a matrix containing 3 vectors as its columns. They can be interpreted as the basis vectors of the transformed coordinate system.
origin: Vector3
The new origin of the transformed coordinate system.
Implementations
sourceimpl Transform
impl Transform
sourcepub const IDENTITY: Transform = Self{ basis: Basis::IDENTITY, origin: Vector3::ZERO,}
pub const IDENTITY: Transform = Self{ basis: Basis::IDENTITY, origin: Vector3::ZERO,}
Identity transform; leaves objects unchanged when applied.
sourcepub const FLIP_X: Transform = Self{ basis: Basis::FLIP_X, origin: Vector3::ZERO,}
pub const FLIP_X: Transform = Self{ basis: Basis::FLIP_X, origin: Vector3::ZERO,}
Transform that mirrors along the X axis (perpendicular to the YZ plane).
sourcepub const FLIP_Y: Transform = Self{ basis: Basis::FLIP_Y, origin: Vector3::ZERO,}
pub const FLIP_Y: Transform = Self{ basis: Basis::FLIP_Y, origin: Vector3::ZERO,}
Transform that mirrors along the Y axis (perpendicular to the XZ plane).
sourcepub const FLIP_Z: Transform = Self{ basis: Basis::FLIP_Z, origin: Vector3::ZERO,}
pub const FLIP_Z: Transform = Self{ basis: Basis::FLIP_Z, origin: Vector3::ZERO,}
Transform that mirrors along the Z axis (perpendicular to the XY plane).
sourcepub const fn from_basis_origin(
basis_vector_a: Vector3,
basis_vector_b: Vector3,
basis_vector_c: Vector3,
origin: Vector3
) -> Transform
pub const fn from_basis_origin(
basis_vector_a: Vector3,
basis_vector_b: Vector3,
basis_vector_c: Vector3,
origin: Vector3
) -> Transform
Creates a new transform from three basis vectors and the coordinate system’s origin.
Each vector represents a basis vector in the transformed coordinate system.
For example, a
is the result of transforming the X unit vector (1, 0, 0)
.
The 3 vectors need to be linearly independent.
Basis vectors are stored as column vectors in the matrix, see also Basis::from_basis_vectors()
.
The construction Transform::from_basis_origin(a, b, c, o)
will create the following 3x4 matrix:
[ a.x b.x c.x o.x ]
[ a.y b.y c.y o.y ]
[ a.z b.z c.z o.z ]
sourcepub fn translated(&self, translation: Vector3) -> Transform
pub fn translated(&self, translation: Vector3) -> Transform
Returns this transform, with its origin moved by a certain translation
sourcepub fn xform(&self, v: Vector3) -> Vector3
pub fn xform(&self, v: Vector3) -> Vector3
Returns a vector transformed (multiplied) by the matrix.
sourcepub fn xform_inv(&self, v: Vector3) -> Vector3
pub fn xform_inv(&self, v: Vector3) -> Vector3
Returns a vector transformed (multiplied) by the transposed basis matrix.
Note: This results in a multiplication by the inverse of the matrix only if it represents a rotation-reflection.
sourcepub fn inverse(&self) -> Transform
pub fn inverse(&self) -> Transform
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation and translation (no scaling, use affine_inverse for transforms with scaling).
sourcepub fn affine_inverse(&self) -> Transform
pub fn affine_inverse(&self) -> Transform
Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.
sourcepub fn looking_at(&self, target: Vector3, up: Vector3) -> Transform
pub fn looking_at(&self, target: Vector3, up: Vector3) -> Transform
Returns a copy of the transform rotated such that its -Z axis points towards the target position.
The transform will first be rotated around the given up vector, and then fully aligned to the target by a further rotation around an axis perpendicular to both the target and up vectors.
Trait Implementations
sourceimpl CoerceFromVariant for Transform
impl CoerceFromVariant for Transform
fn coerce_from_variant(v: &Variant) -> Transform
sourceimpl<'de> Deserialize<'de> for Transform
impl<'de> Deserialize<'de> for Transform
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Transform, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Transform, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
sourceimpl Export for Transform
impl Export for Transform
sourcefn export_info(_hint: Option<<Transform as Export>::Hint>) -> ExportInfo
fn export_info(_hint: Option<<Transform as Export>::Hint>) -> ExportInfo
ExportInfo
given an optional typed hint.