godot::builtin

Struct Transform3D

#[repr(C)]
pub struct Transform3D { pub basis: Basis, pub origin: Vector3, }
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:

[ a.x  b.x  c.x  o.x ]
[ a.y  b.y  c.y  o.y ]
[ a.z  b.z  c.z  o.z ]

§All matrix types

DimensionOrthogonal basisAffine transformProjective transform
2DTransform2D (2x3)
3DBasis (3x3)Transform3D (3x4)Projection (4x4)

§Godot docs

Transform3D (stable)

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§

§

impl Transform3D

pub const IDENTITY: Transform3D = _

The identity transform, with no translation, rotation or scaling applied. When applied to other data structures, IDENTITY performs no transformation.

Godot equivalent: Transform3D.IDENTITY

pub const FLIP_X: Transform3D = _

Transform3D with mirroring applied perpendicular to the YZ plane.

Godot equivalent: Transform3D.FLIP_X

pub const FLIP_Y: Transform3D = _

Transform3D with mirroring applied perpendicular to the XZ plane.

Godot equivalent: Transform3D.FLIP_Y

pub const FLIP_Z: Transform3D = _

Transform3D with mirroring applied perpendicular to the XY plane.

Godot equivalent: Transform3D.FLIP_Z

pub const fn new(basis: Basis, origin: Vector3) -> Transform3D

Create a new transform from a Basis and a Vector3.

Godot equivalent: Transform3D(Basis basis, Vector3 origin)

pub const fn from_cols( a: Vector3, b: Vector3, c: Vector3, origin: Vector3, ) -> Transform3D

Create a new transform from 4 matrix-columns.

Godot equivalent: Transform3D(Vector3 x_axis, Vector3 y_axis, Vector3 z_axis, Vector3 origin), see Basis for why it’s changed

pub fn from_projection(proj: &Projection) -> Transform3D

Constructs a Transform3D from a Projection by trimming the last row of the projection matrix.

Godot equivalent: Transform3D(Projection from)

pub fn affine_inverse(&self) -> Transform3D

Returns the inverse of the transform, under the assumption that the transformation is composed of rotation, scaling and translation.

pub fn interpolate_with(&self, other: &Transform3D, weight: f32) -> Transform3D

Returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).

pub fn is_finite(&self) -> bool

Returns true if this transform is finite by calling is_finite on the basis and origin.

pub fn looking_at( &self, target: Vector3, up: Vector3, use_model_front: bool, ) -> Transform3D

pub fn orthonormalized(&self) -> Transform3D

Returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).

Godot equivalent: Transform3D.orthonormalized()

pub fn rotated(&self, axis: Vector3, angle: f32) -> Transform3D

Returns a copy of the transform rotated by the given angle (in radians). This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the left, i.e., R * X. This can be seen as transforming with respect to the global/parent frame.

Godot equivalent: Transform2D.rotated()

pub fn rotated_local(&self, axis: Vector3, angle: f32) -> Transform3D

Returns a copy of the transform rotated by the given angle (in radians). This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the right, i.e., X * R. This can be seen as transforming with respect to the local frame.

Godot equivalent: Transform2D.rotated_local()

pub fn scaled(&self, scale: Vector3) -> Transform3D

Returns a copy of the transform scaled by the given scale factor. This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the left, i.e., S * X. This can be seen as transforming with respect to the global/parent frame.

Godot equivalent: Transform2D.scaled()

pub fn scaled_local(&self, scale: Vector3) -> Transform3D

Returns a copy of the transform scaled by the given scale factor. This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the right, i.e., X * S. This can be seen as transforming with respect to the local frame.

Godot equivalent: Transform2D.scaled_local()

pub fn translated(&self, offset: Vector3) -> Transform3D

Returns a copy of the transform translated by the given offset. This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the left, i.e., T * X. This can be seen as transforming with respect to the global/parent frame.

Godot equivalent: Transform2D.translated()

pub fn translated_local(&self, offset: Vector3) -> Transform3D

Returns a copy of the transform translated by the given offset. This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the right, i.e., X * T. This can be seen as transforming with respect to the local frame.

Godot equivalent: Transform2D.translated()

Trait Implementations§

§

impl ApproxEq for Transform3D

§

fn approx_eq(&self, other: &Transform3D) -> bool

Returns if the two transforms are approximately equal, by comparing basis and origin separately.

§

impl ArrayElement for Transform3D

§

impl Clone for Transform3D

§

fn clone(&self) -> Transform3D

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Transform3D

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Transform3D

§

fn default() -> Transform3D

Returns the “default value” for a type. Read more
§

impl Display for Transform3D

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value with the given formatter. Read more

The output is similar to Godot’s, but calls the columns a/b/c instead of X/Y/Z. See Basis for why.

§

impl Export for Transform3D

§

fn export_hint() -> PropertyHintInfo

The export info to use for an exported field of this type, if no other export info is specified.
§

fn as_node_class() -> Option<ClassName>

If this is a class inheriting Node, returns the ClassName; otherwise None. Read more
§

impl From<Basis> for Transform3D

§

fn from(basis: Basis) -> Transform3D

Create a new transform with origin (0,0,0) from this basis.

§

impl From<Transform3D> for Projection

§

fn from(trans: Transform3D) -> Projection

Converts to this type from the input type.
§

impl FromGodot for Transform3D

§

fn try_from_godot( via: <Transform3D as GodotConvert>::Via, ) -> Result<Transform3D, ConvertError>

Converts the Godot representation to this type, returning Err on failure.
§

fn from_godot(via: Self::Via) -> Self

⚠️ Converts the Godot representation to this type. Read more
§

fn try_from_variant(variant: &Variant) -> Result<Self, ConvertError>

Performs the conversion from a Variant, returning Err on failure.
§

fn from_variant(variant: &Variant) -> Self

⚠️ Performs the conversion from a Variant. Read more
§

impl GodotConvert for Transform3D

§

type Via = Transform3D

The type through which Self is represented in Godot.
§

impl Mul<Aabb> for Transform3D

§

fn mul(self, rhs: Aabb) -> <Transform3D as Mul<Aabb>>::Output

Transforms each coordinate in rhs.position and rhs.end() individually by this transform, then creates an Aabb containing all of them.

§

type Output = Aabb

The resulting type after applying the * operator.
§

impl Mul<Plane> for Transform3D

§

type Output = Plane

The resulting type after applying the * operator.
§

fn mul(self, rhs: Plane) -> <Transform3D as Mul<Plane>>::Output

Performs the * operation. Read more
§

impl Mul<Vector3> for Transform3D

§

type Output = Vector3

The resulting type after applying the * operator.
§

fn mul(self, rhs: Vector3) -> <Transform3D as Mul<Vector3>>::Output

Performs the * operation. Read more
§

impl Mul<f32> for Transform3D

§

type Output = Transform3D

The resulting type after applying the * operator.
§

fn mul(self, rhs: f32) -> <Transform3D as Mul<f32>>::Output

Performs the * operation. Read more
§

impl Mul for Transform3D

§

type Output = Transform3D

The resulting type after applying the * operator.
§

fn mul(self, rhs: Transform3D) -> <Transform3D as Mul>::Output

Performs the * operation. Read more
§

impl PartialEq for Transform3D

§

fn eq(&self, other: &Transform3D) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl ToGodot for Transform3D

§

type ToVia<'v> = <Transform3D as GodotConvert>::Via

Target type of to_godot(), which differs from Via for pass-by-reference types.
§

fn to_godot(&self) -> <Transform3D as ToGodot>::ToVia<'_>

Converts this type to the Godot type by reference, usually by cloning.
§

fn to_variant(&self) -> Variant

Converts this type to a Variant.
§

impl Var for Transform3D

§

fn get_property(&self) -> <Transform3D as GodotConvert>::Via

§

fn set_property(&mut self, value: <Transform3D as GodotConvert>::Via)

§

fn var_hint() -> PropertyHintInfo

Specific property hints, only override if they deviate from GodotType::property_info, e.g. for enums/newtypes.
§

impl Copy for Transform3D

§

impl GodotType for Transform3D

§

impl StructuralPartialEq for Transform3D

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.