Struct Skeleton

Source
pub struct Skeleton {
    pub skeleton: Hierarchy<Bone>,
    pub roots: Vec<(usize, Recipe)>,
    pub temp_mat4s: Vec<Mat4>,
    pub max_index: usize,
}
Expand description

A set of related bones, with one or more roots

This corresponds to a skeleton (or a number thereof), with each bone appearing once in each skeleton. The bones form a hierarchy.

Fields§

§skeleton: Hierarchy<Bone>

The bones that make up the set, with the hierarchical relationships

§roots: Vec<(usize, Recipe)>

The roots of the bones and hierarchical recipes for traversal

§temp_mat4s: Vec<Mat4>

An array of matrices long enough for the one per level of traversal

§max_index: usize

Max bone index

Implementations§

Source§

impl Skeleton

Source

pub fn new() -> Self

Create a new set of bones

Source

pub fn add_bone( &mut self, transformation: Transformation, matrix_index: usize, ) -> usize

Add a bone with a given base Transformation relative to its parent (if it has one), and an index to a Vec of Mat4 that the bone pose will utilize

It returns the bone reference index

Source

pub fn relate(&mut self, parent: usize, child: usize)

Relate a parent bone to a child bone (by bone reference indices)

Source

pub fn resolve(&mut self)

Resolve the Skeleton by finding the roots, generating traversal hierarchy::Recipes for each root, allocating the required number of temporary Mat4s for the deepest of all the recipes, and finding the number of bone matrices required to be exported

Source

pub fn rewrite_indices(&mut self)

Rewrite the bone matrix indices from 0 if required

Each bone in the Skeleton is allocated the matrix index as it is reached through traversal from the roots of the Skeleton.

Source

pub fn derive_matrices(&mut self)

Derive the matrices (as specified by Bone) for every bone in the Skeleton after the bones have been resolved.

Source

pub fn iter_roots(&self) -> impl Iterator<Item = usize> + '_

Iterate through the root bone indices in the Skeleton

Trait Implementations§

Source§

impl Debug for Skeleton

Source§

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

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

impl Default for Skeleton

Source§

fn default() -> Self

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

impl Display for Skeleton

Source§

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

Display for humans with indent

Source§

impl<'a, Opt: IndentedOptions<'a>> IndentedDisplay<'a, Opt> for Skeleton

Source§

fn indent(&self, f: &mut Indenter<'a, Opt>) -> Result

Display for humans with indent

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