From 93fe5f44c4df5d18911cca936e9a8a6313540c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Nor=C3=A9n?= Date: Sun, 11 Sep 2016 13:07:04 -0400 Subject: [PATCH] Add flip_y_up_to_z_up method to Matrix4 This is for converting between models which often come in a y-up coordinate system (maya) and game which often use a z-up system. Math from http://stackoverflow.com/questions/22571364/threejs-matrix-from-z-up-coordinate-system-to-y-up-coordinate-system --- src/matrix.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/matrix.rs b/src/matrix.rs index 9d3acdf8..bf0a959c 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -299,6 +299,18 @@ impl Matrix4 { S::zero(), S::one()) } + + /// Create a matrix which flips the y and z coordnates. + /// + /// This is used to transform from a y-up coordinate system to + /// a z-up coordinate systems. + #[inline] + pub fn flip_y_up_to_z_up() -> Matrix4 { + Matrix4::new(S::one(), S::zero(), S::zero(), S::zero(), + S::zero(), S::zero(), S::one(), S::zero(), + S::zero(), -S::one(), S::zero(), S::zero(), + S::zero(), S::zero(), S::zero(), S::one()) + } } impl Zero for Matrix2 {