diff --git a/Cargo.lock b/Cargo.lock index 30e24c1..e135a48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.25.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3" +checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" [[package]] name = "lazy_static" diff --git a/Cargo.toml b/Cargo.toml index 52d3d26..a424253 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/wld/fragments/t18_skeleton_piece_track_def.rs b/src/wld/fragments/t18_skeleton_piece_track_def.rs index 72284e4..07e4d34 100644 --- a/src/wld/fragments/t18_skeleton_piece_track_def.rs +++ b/src/wld/fragments/t18_skeleton_piece_track_def.rs @@ -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()) + } +}