alloy::model::transform

Struct Transform

source
pub struct Transform { /* private fields */ }
Expand description

A transform represents the transformation matrix of a model

This type only implements Clone and not Copy because it is a large type that is more efficient to pass by reference. If you need to create a new transform that is a copy of an existing transform, you can use the Clone trait to do so.

Implementations§

source§

impl Transform

source

pub const IDENTITY: Self = _

Represents the Identity transformation.

source

pub const fn new( translation: Vector3, rotation: Quaternion, scale: Vector3, ) -> Self

Creates a new transform with the given position, rotation, and scale

§Parameters
  • translation - The translation of the transform
  • rotation - The rotation of the transform
  • scale - The scale of the transform
source

pub const fn from_translation(translation: Vector3) -> Self

Creates a new transform representing just the translation

§Parameters
  • translation - The translation of the transform
source

pub const fn from_x_translation(x: f32) -> Self

Creates a new transform representing a translation only in the x direction.

§Parameters
  • x - The translation along the x-axis
source

pub const fn from_y_translation(y: f32) -> Self

Creates a new transform representing a translation only in the y direction.

§Parameters
  • y - The translation along the y-axis
source

pub const fn from_z_translation(z: f32) -> Self

Creates a new transform representing a translation only in the z direction.

§Parameters
  • z - The translation along the z-axis
source

pub const fn from_translation_vec3(translation: &Vec3) -> Self

Creates a new transform representing just the translation

§Parameters
  • translation - The translation of the transform
source

pub const fn from_rotation(rotation: Quaternion) -> Self

Creates a new transform representing just the rotation

§Parameters
  • rotation - The rotation of the transform
source

pub const fn from_rotation_vec4(rotation: &Vec4) -> Self

Creates a new transform representing just the rotation identified in a Vec4 encoded as a Quaternion.

§Parameters
  • rotation - The rotation of the transform
source

pub fn from_yaw_rotation<A: Angle>(angle: A) -> Self

Creates a new transform representing just a yaw rotation

§Parameters
  • angle - The yaw angle of the transform
source

pub fn from_pitch_rotation<A: Angle>(angle: A) -> Self

Creates a new transform representing just a pitch rotation

§Parameters
  • angle - The pitch angle of the transform
source

pub fn from_roll_rotation<A: Angle>(angle: A) -> Self

Creates a new transform representing just a roll rotation

§Parameters
  • angle - The roll angle of the transform
source

pub const fn from_scale(scale: Vector3) -> Self

Creates a new transform representing just the scale

§Parameters
  • scale - The scale of the transform
source

pub const fn from_scale_vec3(scale: &Vec3) -> Self

Creates a new transform representing just the scale

§Parameters
  • scale - The scale of the transform
source

pub const fn from_uniform_scale(scale: f32) -> Self

Creates a new transform representing a uniform scale

§Parameters
  • scale - The scale factor
source

pub const fn from_nonuniform_scale(x: f32, y: f32, z: f32) -> Self

Creates a new transform representing a non-uniform scale

§Parameters
  • x - The scale factor along the x-axis
  • y - The scale factor along the y-axis
  • z - The scale factor along the z-axis
source

pub const fn from_x_scale(x: f32) -> Self

Creates a new transform representing an x-scaled transform

§Parameters
  • x - The scale factor along the x-axis
source

pub const fn from_y_scale(y: f32) -> Self

Creates a new transform representing a y-scaled transform

§Parameters
  • y - The scale factor along the y-axis
source

pub const fn from_z_scale(z: f32) -> Self

Creates a new transform representing a z-scaled transform

§Parameters
  • z - The scale factor along the z-axis
source§

impl Transform

source

pub fn translation(&self) -> &Vec3

Returns the position of the transform

source

pub fn rotation(&self) -> &Quaternion

Returns the rotation of the transform

source

pub fn scale_direction(&self) -> &Vec3

Returns the scale direction of the transform

source§

impl Transform

source

pub fn set_translation(&mut self, translation: Vector3)

Sets the translation of the transform

§Parameters
  • translation - The translation of the transform
source

pub fn set_translation_vec3(&mut self, translation: &Vec3)

Sets the translation of the transform

§Parameters
  • translation - The translation of the transform
source

pub fn translate_x(&mut self, x: f32)

Sets the translation of the transform in the x direction

§Parameters
  • x - The translation along the x-axis
source

pub fn translate_y(&mut self, y: f32)

Sets the translation of the transform in the y direction

§Parameters
  • y - The translation along the y-axis
source

pub fn translate_z(&mut self, z: f32)

Sets the translation of the transform in the z direction

§Parameters
  • z - The translation along the z-axis
source

pub fn translate(&mut self, translation: &Vec3)

Translates the transform by the given vector

§Parameters
  • translation - The translation to apply
source§

impl Transform

source

pub fn set_rotation(&mut self, rotation: Quaternion)

Sets the rotation of the transform

source

pub fn rotate_yaw<A: Angle>(&mut self, angle: A)

Rotates the transform in the yaw direction by the given angle.

§Parameters
  • angle - The angle to rotate the transform by.
source

pub fn rotate_pitch<A: Angle>(&mut self, angle: A)

Rotates the transform in the pitch direction by the given angle.

§Parameters
  • angle - The angle to rotate the transform by.
source

pub fn rotate_roll<A: Angle>(&mut self, angle: A)

Rotates the transform in the roll direction by the given angle.

§Parameters
  • angle - The angle to rotate the transform by.
source

pub fn rotate_euler_angles<A: Angle>(&mut self, yaw: A, pitch: A, roll: A)

Rotates the transform by the given euler angles.

§Parameters
  • yaw - The yaw angle to rotate the transform by.
  • pitch - The pitch angle to rotate the transform by.
  • roll - The roll angle to rotate the transform by.
source

pub fn rotate(&mut self, rotation: &Quaternion)

Rotates the transform by the given quaternion.

§Parameters
  • rotation - The rotation to apply.
source§

impl Transform

source

pub fn set_scale(&mut self, scale: Vector3)

Sets the scale of the transform

§Parameters
  • scale - The scale to apply to the transform
source

pub fn scale(&mut self, scale: &Vec3)

Scales the transformation by the vector scale

§Parameters
  • scale - The scale to apply to the transform
source

pub fn scale_width(&mut self, width: f32)

Scales the width of the transform

§Parameters
  • width - The width to scale the transform by
source

pub fn scale_height(&mut self, height: f32)

Scales the height of the transform

§Parameters
  • height - The height to scale the transform by
source

pub fn scale_depth(&mut self, depth: f32)

Scales the depth of the transform

§Parameters
  • depth - The depth to scale the transform by
source

pub fn scale_uniform(&mut self, scale: f32)

Scales the transform uniformly by the given scale factor

§Parameters
  • scale - The scale factor to apply to the transform
source

pub fn scale_nonuniform(&mut self, x: f32, y: f32, z: f32)

Scales the transform non-uniformly by the given scale factors

§Parameters
  • x - The scale factor along the x-axis
  • y - The scale factor along the y-axis
  • z - The scale factor along the z-axis
source§

impl Transform

source

pub fn transform(&mut self) -> &Mat4

Computes and reutrns the transformation matrix of the transform

This function will only recompute the transformation matrix if the transform has been modified since the last time the transformation matrix was computed.

Trait Implementations§

source§

impl Clone for Transform

source§

fn clone(&self) -> Transform

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
source§

impl Debug for Transform

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Transform

source§

fn default() -> Self

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

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, 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.