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
impl Bone
Sourcepub fn new(transformation: Transformation, matrix_index: usize) -> Self
pub fn new(transformation: Transformation, matrix_index: usize) -> Self
Create a new bone with a given rest
Sourcepub fn borrow_transformation(&self) -> &Transformation
pub fn borrow_transformation(&self) -> &Transformation
Borrow the transformation
Sourcepub fn set_transformation(self, transformation: Transformation) -> Self
pub fn set_transformation(self, transformation: Transformation) -> Self
Set the transformation of the bone
Sourcepub fn derive_matrices(&mut self, is_root: bool, parent_mtb: &Mat4) -> &Mat4
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
Sourcepub fn borrow_mtb(&self) -> &Mat4
pub fn borrow_mtb(&self) -> &Mat4
Borrow the mtb Matrix (for test mainly)
Sourcepub fn borrow_ptb(&self) -> &Mat4
pub fn borrow_ptb(&self) -> &Mat4
Borrow the ptb Matrix (for test mainly)