Exemple #1
0
 /// <summary>
 /// Converts a <see cref="Fusee.Math.Core.Matrix4F"/> to an Array of double values. The row major order storage of the
 /// original matrix is converted to column major order (the matrix is transposed before exporting it to an Array).
 /// This way the returned array can be used in environments taking column major order
 /// matrices (like e.g. DirectX). Use ToArray[]RowOrder for converting the original matrix to environments taking
 /// row major order matrices (e.g. OpenGL).
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A double array containing 16 values in column major order [m11, m21, m31, ...].</returns>
 public static double[] Matrix4FToArrayDoubleColOrder(Fusee.Math.Core.Matrix4F value)
 {
     return(new double[] { value[0, 0], value[1, 0], value[2, 0], value[3, 0],
                           value[0, 1], value[1, 1], value[2, 1], value[3, 1],
                           value[0, 2], value[1, 2], value[2, 2], value[3, 2],
                           value[0, 3], value[1, 3], value[2, 3], value[3, 3] });
 }
Exemple #2
0
 /// <summary>
 /// Converts a <see cref="Fusee.Math.Core.Matrix4F"/> to an Array of floats. The row major order storage of the
 /// original matrix is converted to column major order (the matrix is transposed before exporting it to an Array).
 /// This way the returned array can be used in environments taking column major order
 /// matrices (like e.g. DirectX). Use ToArray[]RowOrder for converting the original matrix to environments taking
 /// row major order matrices (e.g. OpenGL).
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A float array containing 16 values in column major order [m11, m21, m31, ...].</returns>
 public static float[] Matrix4FToArrayFloatColOrder(Fusee.Math.Core.Matrix4F value)
 {
     return(new float[] { value[0, 0], value[1, 0], value[2, 0], value[3, 0],
                          value[0, 1], value[1, 1], value[2, 1], value[3, 1],
                          value[0, 2], value[1, 2], value[2, 2], value[3, 2],
                          value[0, 3], value[1, 3], value[2, 3], value[3, 3] });
 }
        /// <summary>
        /// Converts a <see cref="Microsoft.DirectX.Matrix"/> to <see cref="Fusee.Math.Core.Matrix4F"/>.
        /// </summary>
        /// <param name="value">The matrix value to convert.</param>
        /// <returns>A <see cref="Fusee.Math.Core.Matrix4F"/> value.</returns>
        public static Fusee.Math.Core.Matrix4F FromDirectX(Microsoft.DirectX.Matrix value)
        {
            Fusee.Math.Core.Matrix4F m = new Fusee.Math.Core.Matrix4F();
            // Since directx use column-major matrices we transpose the matrix.
            m[0,0] = value.M11;	m[0,1] = value.M21;	m[0,2] = value.M31;	m[0,2] = value.M41;
            m[1,0] = value.M12;	m[1,1] = value.M22;	m[1,2] = value.M32;	m[1,2] = value.M42;
            m[2,0] = value.M13;	m[2,1] = value.M23;	m[2,2] = value.M33;	m[2,2] = value.M43;
            m[3,0] = value.M14;	m[3,1] = value.M24;	m[3,2] = value.M34;	m[3,2] = value.M44;

            return m;
        }
Exemple #4
0
        /// <summary>
        /// Converts a <see cref="Microsoft.DirectX.Matrix"/> to <see cref="Fusee.Math.Core.Matrix4F"/>.
        /// </summary>
        /// <param name="value">The matrix value to convert.</param>
        /// <returns>A <see cref="Fusee.Math.Core.Matrix4F"/> value.</returns>
        public static Fusee.Math.Core.Matrix4F FromDirectX(Microsoft.DirectX.Matrix value)
        {
            Fusee.Math.Core.Matrix4F m = new Fusee.Math.Core.Matrix4F();
            // Since directx use column-major matrices we transpose the matrix.
            m[0, 0] = value.M11;     m[0, 1] = value.M21;     m[0, 2] = value.M31;     m[0, 2] = value.M41;
            m[1, 0] = value.M12;     m[1, 1] = value.M22;     m[1, 2] = value.M32;     m[1, 2] = value.M42;
            m[2, 0] = value.M13;     m[2, 1] = value.M23;     m[2, 2] = value.M33;     m[2, 2] = value.M43;
            m[3, 0] = value.M14;     m[3, 1] = value.M24;     m[3, 2] = value.M34;     m[3, 2] = value.M44;

            return(m);
        }
Exemple #5
0
        /// <summary>
        /// Converts a <see cref="Fusee.Math.Core.Matrix4F"/> to <see cref="Microsoft.DirectX.Matrix"/>.
        /// </summary>
        /// <param name="value">The matrix value to convert.</param>
        /// <returns>A <see cref="Microsoft.DirectX.Matrix"/> value.</returns>
        public static Microsoft.DirectX.Matrix ToDirectX(Fusee.Math.Core.Matrix4F value)
        {
            Microsoft.DirectX.Matrix m = new Microsoft.DirectX.Matrix();
            // Since directx use column-major matrices we transpose our matrix.
            m.M11 = value[0, 0]; m.M12 = value[1, 0]; m.M13 = value[2, 0];     m.M14 = value[3, 0];
            m.M21 = value[0, 1];     m.M22 = value[1, 1]; m.M23 = value[2, 1]; m.M24 = value[3, 1];
            m.M31 = value[0, 2];     m.M32 = value[1, 2];     m.M33 = value[2, 2]; m.M34 = value[3, 2];
            m.M41 = value[0, 3];     m.M42 = value[1, 3];     m.M43 = value[2, 3];     m.M44 = value[3, 3];

            return(m);
        }