Struct Bone

Source
pub struct Bone {
    pub transformation: Transformation,
    pub matrix_index: usize,
    /* private fields */
}
Expand description

Each bone has a transformation with respect to its parent that is a translation (its origin relative to its parent origin), scale (in each direction, although a common scale for each coordinates is best), and an orientation of its contents provided by a quaternion (as a rotation).

A point in this bone’s space is then translate(rotate(scale(pt))) in its parent’s space. The bone’s children start with this transformation too.

From this the bone has a local bone-to-parent transform matrix and it has a local parent-to-bone transform matrix

At rest (where a mesh is skinned) there are two rest matrix variants Hence bone_relative = ptb * parent_relative

The skinned mesh has points that are parent relative, so animated_parent_relative(t) = btp(t) * ptb * parent_relative(skinned)

For a chain of bones Root -> A -> B -> C: bone_relative = C.ptb * B.ptb * A.ptb * mesh root = A.btp * B.btp * C.btp * C_bone_relative animated(t) = A.btp(t) * B.btp(t) * C.btp(t) * C.ptb * B.ptb * A.ptb * mesh

Fields§

§transformation: Transformation

rest transform - translation, scale, rotation

§matrix_index: usize

Index into matrix array to put this bones animated mtm

Implementations§

Source§

impl Bone

Source

pub fn new(transformation: Transformation, matrix_index: usize) -> Self

Create a new bone with a given rest

Source

pub fn borrow_transformation(&self) -> &Transformation

Borrow the transformation

Source

pub fn set_transformation(self, transformation: Transformation) -> Self

Set the transformation of the bone

Source

pub fn derive_matrices(&mut self, is_root: bool, parent_mtb: &Mat4) -> &Mat4

Derive matrices for the bone given a parent mesh-to-bone Mat4

Source

pub fn borrow_mtb(&self) -> &Mat4

Borrow the mtb Matrix (for test mainly)

Source

pub fn borrow_ptb(&self) -> &Mat4

Borrow the ptb Matrix (for test mainly)

Trait Implementations§

Source§

impl Debug for Bone

Source§

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

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

impl Display for Bone

Source§

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

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

impl DefaultIndentedDisplay for Bone

Auto Trait Implementations§

§

impl Freeze for Bone

§

impl RefUnwindSafe for Bone

§

impl Send for Bone

§

impl Sync for Bone

§

impl Unpin for Bone

§

impl UnwindSafe for Bone

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, O, T> IndentedDisplay<'a, O> for T

Source§

fn indent(&self, ind: &mut Indenter<'a, O>) -> Result<(), Error>

Display for humans with indent
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> ToString for T
where T: Display + ?Sized,

Source§

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.