I am trying to set the upper left block of a 4X4 matrix to a rotation matrix.
I have tried different flavours of:
let mut mat = Mat4::identity();
mat.set_column(3, &Vec4::new(trans.x, trans.y, trans.z, 1.0));
let slice = &mat.slice((0,0), (3,3));
slice = &rot.to_rotation_matrix().matrix().slice((0,0), (3,3));
Each one fails to compile with a different error because the types don't match.
The equivalent code in eigen that i am trying to replicate is:
Eigen::Quaternionf rotation = joint_animation.SampleRotation(t);
Eigen::Vector3f translation = joint_animation.SampleTranslation(t);
Eigen::Vector3f scale = joint_animation.SampleScaling(t);
Eigen::Matrix4f t_mat = skin.joint_matrices[i];
t_mat.block(0, 0, 3, 3) = (rotation).toRotationMatrix();
t_mat.row(0).head<3>() *= scale(0);
t_mat.row(1).head<3>() *= scale(1);
t_mat.row(2).head<3>() *= scale(2);
t_mat(0, 3) = translation[0];
t_mat(1, 3) = translation[1];
t_mat(2, 3) = translation[2];
BTW I aliased some nalgebra types:
pub type Quatf = na::UnitQuaternion<f32>;
pub type Mat2 = na::Matrix2<f32>;
pub type Mat3 = na::Matrix3<f32>;
pub type Mat4 = na::Matrix4<f32>;