Skip to content

Commit

Permalink
Helper methods for the bone matrices
Browse files Browse the repository at this point in the history
Given I target bevy as a game engine and bevy is stilll in glam 0.24, I think it is better to follow for now. Also add a few methods that can help with the bone calculation.

Formula is like: translation * rotation * scale
  • Loading branch information
anarelion committed Jan 11, 2024
1 parent ec85c1b commit 8e17a88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
bitbybit = "1.2"
bytes = "1.0"
compress = "0.2"
glam = "0.25"
glam = "0.24"
lazy_static = "1.4"
thiserror = "1.0"
tracing = "0.1"
14 changes: 14 additions & 0 deletions src/wld/fragments/t18_skeleton_piece_track_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,17 @@ pub struct WldSkeletonPieceTrackFrameTransform {
pub scale: f32,
pub model_matrix: glam::Mat4,
}

impl WldSkeletonPieceTrackFrameTransform {
pub fn scale_matrix(&self) -> glam::Mat4 {
glam::Mat4::from_scale(glam::Vec3::from((self.scale, self.scale, self.scale)))
}

pub fn rotation_matrix(&self) -> glam::Mat4 {
glam::Mat4::from_quat(glam::Quat::from_array(self.rotation.to_array()))
}

pub fn translation_matrix(&self) -> glam::Mat4 {
glam::Mat4::from_translation(self.translation.to_array().into())
}
}

0 comments on commit 8e17a88

Please sign in to comment.