/// Returns a matrix that converts to dst from Unity's axis conventions. public static Matrix4x4 GetFromUnity(AxisConvention dst) { // Solve for M: // M * (1, 0, 0) = ac.right (because 1,0,0 is Unity right) // M * (0, 1, 0) = ac.up // M * (0, 0, 1) = ac.forward return(new Matrix4x4(dst.right, dst.up, dst.forward, new Vector4(0, 0, 0, 1))); }
/// General-purpose conversion. public static Matrix4x4 GetToDstFromSrc(AxisConvention dst, AxisConvention src) { // It doesn't really matter which system we pivot through, so use Unity return(GetFromUnity(dst) * GetToUnity(src)); }
/// Returns a matrix that converts to Unity's axis conventions from src. public static Matrix4x4 GetToUnity(AxisConvention src) { // transpose == inverse since these conversions are all orthonormal. return(GetFromUnity(src).transpose); }