Exemplo n.º 1
0
        public void RowConstructor()
        {
            var expected = GetTestMatrix();
            var actual   = new MatrixFloat4x4(expected.Row0, expected.Row1, expected.Row2, expected.Row3);

            Asserts.AreEqual(expected, actual, "ctor 1");
        }
Exemplo n.º 2
0
        public void Create()
        {
            var M2x2 = new MatrixFloat2x2(1, 2, 3, 4);
            var M3x3 = new MatrixFloat3x3(1, 2, 3, 4, 5, 6, 7, 8, 9);
            var M4x4 = new MatrixFloat4x4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);

            using (var obj = SKUniform.Create("name", M2x2)) {
                Asserts.AreEqual(M2x2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value");
                Asserts.AreEqual(M2x2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value");
                var tmp2 = new MatrixFloat2x2(9, 8, 7, 6);
                obj.MatrixFloat2x2Value = tmp2;
                Asserts.AreEqual(tmp2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value second");
                Asserts.AreEqual(tmp2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value second");
            }

            using (var obj = SKUniform.Create("name", M3x3)) {
                Asserts.AreEqual(M3x3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value");
                Asserts.AreEqual(M3x3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value");
                var tmp3 = new MatrixFloat3x3(9, 8, 7, 6, 5, 4, 3, 2, 1);
                obj.MatrixFloat3x3Value = tmp3;
                Asserts.AreEqual(tmp3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value second");
                Asserts.AreEqual(tmp3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value second");
            }

            using (var obj = SKUniform.Create("name", M4x4)) {
                Asserts.AreEqual(M4x4, obj.MatrixFloat4x4Value, "13  MatrixFloat4x4Value");
                Asserts.AreEqual(M4x4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b FloatMatrix4Value");
                var tmp4 = new MatrixFloat4x4(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6);
                obj.MatrixFloat4x4Value = tmp4;
                Asserts.AreEqual(tmp4, obj.MatrixFloat4x4Value, "13 MatrixFloat4x4Value second");
                Asserts.AreEqual(tmp4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b MatrixFloat4x4Value second");
            }
        }
        public void ProjectionMatrix()
        {
            using (var obj = new MDLCamera()) {
                Assert.AreEqual(0.1f, obj.NearVisibilityDistance, 0.0001f, "NearVisibilityDistance");
                Assert.AreEqual(1000f, obj.FarVisibilityDistance, 0.0001f, "FarVisibilityDistance");
                Assert.AreEqual(54f, obj.FieldOfView, 0.0001f, "FieldOfView");
                var initialProjectionMatrix = new Matrix4(
                    1.308407f, 0, 0, 0,
                    0, 1.962611f, 0, 0,
                    0, 0, -1.0002f, -1,
                    0, 0, -0.20002f, 0
                    );
                Asserts.AreEqual(initialProjectionMatrix, obj.ProjectionMatrix, 0.0001f, "Initial");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)initialProjectionMatrix), obj.ProjectionMatrix4x4, 0.0001f, "Initial 4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)initialProjectionMatrix), CFunctions.GetMatrixFloat4x4(obj, "projectionMatrix"), 0.0001f, "Initial native");

                obj.NearVisibilityDistance = 1.0f;
                var modifiedProjectionMatrix = new Matrix4(
                    1.308407f, 0, 0, 0,
                    0, 1.962611f, 0, 0,
                    0, 0, -1.002002f, -1,
                    0, 0, -2.002002f, 0
                    );
                Asserts.AreEqual(modifiedProjectionMatrix, obj.ProjectionMatrix, 0.0001f, "Second");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)modifiedProjectionMatrix), obj.ProjectionMatrix4x4, 0.0001f, "Second 4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)modifiedProjectionMatrix), CFunctions.GetMatrixFloat4x4(obj, "projectionMatrix"), 0.0001f, "Second native");
            }
        }
Exemplo n.º 4
0
        public void ElementConstructor()
        {
            var expected = GetTestMatrix();
            var actual   = new MatrixFloat4x4(expected.M11, expected.M12, expected.M13, expected.M14,
                                              expected.M21, expected.M22, expected.M23, expected.M24,
                                              expected.M31, expected.M32, expected.M33, expected.M34,
                                              expected.M41, expected.M42, expected.M43, expected.M44);

            Asserts.AreEqual(expected, actual, "ctor 1");
        }
Exemplo n.º 5
0
        public void Multiply()
        {
            var inputL     = GetTestMatrix();
            var inputR     = GetTestMatrix();
            var inputSimdL = (MatrixFloat4x4)inputL;
            var inputSimdR = (MatrixFloat4x4)inputR;
            var expected   = Matrix4.Mult(inputL, inputR);
            var actual     = MatrixFloat4x4.Multiply(inputSimdL, inputSimdR);

            Asserts.AreEqual(expected, actual, "multiply");
        }
Exemplo n.º 6
0
        public void Identity()
        {
            var identity = new MatrixFloat4x4 {
                M11 = 1f,
                M22 = 1f,
                M33 = 1f,
                M44 = 1f,
            };

            Asserts.AreEqual(identity, MatrixFloat4x4.Identity, "identity");
            Asserts.AreEqual(Matrix4.Identity, MatrixFloat4x4.Identity, "opentk identity");
        }
Exemplo n.º 7
0
        public void TransposeStatic_ByRef()
        {
            var input     = GetTestMatrix();
            var inputSimd = (MatrixFloat4x4)input;

            Matrix4        expected;
            MatrixFloat4x4 actual;

            Matrix4.Transpose(ref input, out expected);
            MatrixFloat4x4.Transpose(ref inputSimd, out actual);
            Asserts.AreEqual(expected, actual, "transpose out/ref");
        }
        public void CreateGlobalTransformTest()
        {
            Matrix4        m4;
            MatrixFloat4x4 m4x4;

            using (var obj = new MDLObject()) {
                m4 = MDLTransform.CreateGlobalTransform(obj, 0);
                Asserts.AreEqual((Matrix4)MatrixFloat4x4.Transpose(CFunctions.MDLTransform_CreateGlobalTransform(obj, 0)), m4, "CreateGlobalTransform");

                m4x4 = MDLTransform.CreateGlobalTransform4x4(obj, 0);
                Asserts.AreEqual(CFunctions.MDLTransform_CreateGlobalTransform(obj, 0), m4, "CreateGlobalTransform4x4");
            }
        }
Exemplo n.º 9
0
        public virtual Matrix4 [] GetNMatrix4Values()
        {
            var count    = ElementCount;
            var timesArr = new Matrix4 [(int)count];
            int typeSize = Marshal.SizeOf(typeof(Matrix4));

            unsafe {
                fixed(Matrix4 *arrptr = timesArr)
                MDLMemoryHelper.FetchValues(typeSize, (IntPtr)arrptr, count, _GetFloat4x4Array);
            }

            return(timesArr);
        }
Exemplo n.º 10
0
        public virtual Matrix4 [] GetNMatrix4Values()
        {
            var count    = TimeSampleCount;
            var timesArr = new Matrix4 [(int)count];

            unsafe {
                int typeSize = sizeof(Matrix4);

                fixed(Matrix4 *arrptr = timesArr)
                MDLMemoryHelper.FetchValues(typeSize, (IntPtr)arrptr, count, _GetFloat4x4Array);
            }

            return(timesArr);
        }
Exemplo n.º 11
0
        public void Multiply_ByRef()
        {
            var            inputL     = GetTestMatrix();
            var            inputR     = GetTestMatrix();
            var            inputSimdL = (MatrixFloat4x4)inputL;
            var            inputSimdR = (MatrixFloat4x4)inputR;
            Matrix4        expected;
            MatrixFloat4x4 actual;

            Matrix4.Mult(ref inputL, ref inputR, out expected);
            MatrixFloat4x4.Multiply(ref inputSimdL, ref inputSimdR, out actual);

            Asserts.AreEqual(expected, actual, "multiply");
        }
Exemplo n.º 12
0
        public void TransposeStatic()
        {
            var input     = GetTestMatrix();
            var inputSimd = (MatrixFloat4x4)input;

            var expected = Matrix4.Transpose(input);
            var actual   = MatrixFloat4x4.Transpose(inputSimd);

            Asserts.AreEqual(expected, actual, "transpose");

            input     = GetTestMatrix();
            inputSimd = (MatrixFloat4x4)input;
            Matrix4.Transpose(ref input, out expected);
            MatrixFloat4x4.Transpose(ref inputSimd, out actual);
            Asserts.AreEqual(expected, actual, "transpose out/ref");
        }
Exemplo n.º 13
0
        public void GetRotationMatrixTest()
        {
            var matrix = Matrix4.Identity;
            var V3     = new Vector3(1, 0, 0);

            using (var obj = new MDLTransform(matrix)) {
                obj.SetRotation(V3, 0);
                var expected = new MatrixFloat4x4(
                    1, 0, 0, 0,
                    0, (float)Math.Cos(1.0f), (float)-Math.Sin(1.0f), 0,
                    0, (float)Math.Sin(1.0f), (float)Math.Cos(1.0f), 0,
                    0, 0, 0, 1
                    );
                Asserts.AreEqual((Matrix4)MatrixFloat4x4.Transpose(expected), obj.GetRotationMatrix(0), 0.00001f, "GetRotationMatrix");
                Asserts.AreEqual(expected, obj.GetRotationMatrix4x4(0), 0.00001f, "GetRotationMatrix4x4");
                Asserts.AreEqual(expected, CFunctions.MDLTransform_GetRotationMatrix(obj, 0), 0.00001f, "GetRotationMatrix4x4 native");
            }
        }
Exemplo n.º 14
0
 public static void AreEqual(MatrixFloat4x4 expected, Matrix4 actual, string message)
 {
     AreEqual(expected.M11, actual.M11, message + " (M11)");
     AreEqual(expected.M21, actual.M21, message + " (M21)");
     AreEqual(expected.M31, actual.M31, message + " (M31)");
     AreEqual(expected.M41, actual.M41, message + " (M41)");
     AreEqual(expected.M12, actual.M12, message + " (M12)");
     AreEqual(expected.M22, actual.M22, message + " (M22)");
     AreEqual(expected.M32, actual.M32, message + " (M32)");
     AreEqual(expected.M42, actual.M42, message + " (M42)");
     AreEqual(expected.M13, actual.M13, message + " (M13)");
     AreEqual(expected.M23, actual.M23, message + " (M23)");
     AreEqual(expected.M33, actual.M33, message + " (M33)");
     AreEqual(expected.M43, actual.M43, message + " (M43)");
     AreEqual(expected.M14, actual.M14, message + " (M14)");
     AreEqual(expected.M24, actual.M24, message + " (M24)");
     AreEqual(expected.M34, actual.M34, message + " (M34)");
     AreEqual(expected.M44, actual.M44, message + " (M44)");
 }
        public void Properties()
        {
            using (var obj = new MDLStereoscopicCamera()) {
                Assert.AreEqual(63f, obj.InterPupillaryDistance, "InterPupillaryDistance");
                Assert.AreEqual(0f, obj.LeftVergence, "LeftVergence");
                Assert.AreEqual(0f, obj.RightVergence, "RightVergence");
                Assert.AreEqual(0f, obj.Overlap, "Overlap");

                var mat1 = new Matrix4(
                    1, 0, 0, 0,
                    0, 1, 0, 0,
                    0, 0, 1, 0,
                    -0.63f, 0, 0, 1);
                Asserts.AreEqual(mat1, obj.LeftViewMatrix, "LeftViewMatrix");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat1), obj.LeftViewMatrix4x4, "LeftViewMatrix4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat1), CFunctions.GetMatrixFloat4x4(obj, "leftViewMatrix"), "LeftViewMatrix4x4 native");

                var mat2 = new Matrix4(
                    1, 0, 0, 0,
                    0, 1, 0, 0,
                    0, 0, 1, 0,
                    0.63f, 0, 0, 1);
                Asserts.AreEqual(mat2, obj.RightViewMatrix, "RightViewMatrix");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat2), obj.RightViewMatrix4x4, "RightViewMatrix4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat2), CFunctions.GetMatrixFloat4x4(obj, "rightViewMatrix"), "RightViewMatrix4x4 native");

                var mat3 = new Matrix4(
                    1.308407f, 0, 0, 0,
                    0, 1.962611f, 0, 0,
                    0, 0, -1.0002f, -1,
                    0, 0, -0.20002f, 0);
                Asserts.AreEqual(mat3, obj.LeftProjectionMatrix, 0.0001f, "LeftProjectionMatrix");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat3), obj.LeftProjectionMatrix4x4, 0.0001f, "LeftProjectionMatrix4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat3), CFunctions.GetMatrixFloat4x4(obj, "leftProjectionMatrix"), 0.0001f, "LeftProjectionMatrix4x4 native");

                Asserts.AreEqual(mat3, obj.RightProjectionMatrix, 0.0001f, "RightProjectionMatrix");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat3), obj.RightProjectionMatrix4x4, 0.0001f, "RightProjectionMatrix4x4");
                Asserts.AreEqual(MatrixFloat4x4.Transpose((MatrixFloat4x4)mat3), CFunctions.GetMatrixFloat4x4(obj, "rightProjectionMatrix"), 0.0001f, "RightProjectionMatrix4x4 native");
            }
        }
Exemplo n.º 16
0
 public static void SetLocalTransform4x4(this IMDLTransformComponent This, MatrixFloat4x4 transform)
 {
     SetLocalTransform(This, (Matrix4)MatrixFloat4x4.Transpose(transform));
 }
Exemplo n.º 17
0
 public static MatrixFloat4x4 GetMatrix4x4(this IMDLTransformComponent self)
 {
     return(MatrixFloat4x4.Transpose((MatrixFloat4x4)self.Matrix));
 }
Exemplo n.º 18
0
 public static MatrixFloat4x4 CreateGlobalTransform4x4(MDLObject obj, double atTime)
 {
     return(MatrixFloat4x4.Transpose((MatrixFloat4x4)CreateGlobalTransform(obj, atTime)));
 }
Exemplo n.º 19
0
        public void Ctors()
        {
            SKTexture      texture;
            Vector2        V2;
            Vector3        V3;
            Vector4        V4;
            Matrix2        M2;
            Matrix3        M3;
            Matrix4        M4;
            MatrixFloat2x2 M2x2;
            MatrixFloat3x3 M3x3;
            MatrixFloat4x4 M4x4;

            using (var obj = new SKUniform("name")) {
                var M4Zero = new Matrix4(Vector4.Zero, Vector4.Zero, Vector4.Zero, Vector4.Zero);
                Assert.AreEqual("name", obj.Name, "1 Name");
                Assert.AreEqual(SKUniformType.None, obj.UniformType, "1 UniformType");
                Assert.IsNull(obj.TextureValue, "1 TextureValue");
                Assert.AreEqual(0.0f, obj.FloatValue, "1 FloatValue");
                Asserts.AreEqual(Vector2.Zero, obj.FloatVector2Value, "1 FloatVector2Value");
                Asserts.AreEqual(Vector3.Zero, obj.FloatVector3Value, "1 FloatVector3Value");
                Asserts.AreEqual(Vector4.Zero, obj.FloatVector4Value, "1 FloatVector4Value");
                Asserts.AreEqual(Matrix2.Zero, obj.FloatMatrix2Value, "1 FloatMatrix2Value");
                Asserts.AreEqual(Matrix3.Zero, obj.FloatMatrix3Value, "1 FloatMatrix3Value");
                Asserts.AreEqual(M4Zero, obj.FloatMatrix4Value, "1 FloatMatrix4Value");

                texture = SKTexture.FromImageNamed("basn3p08.png");
                V2      = new Vector2(1, 2);
                V3      = new Vector3(3, 4, 5);
                V4      = new Vector4(6, 7, 8, 9);
                M2      = new Matrix2(1, 2, 3, 4);
                M3      = new Matrix3(1, 2, 3, 4, 5, 6, 7, 8, 9);
                M4      = new Matrix4(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
                M2x2    = (MatrixFloat2x2)M2;
                M3x3    = (MatrixFloat3x3)M3;
                M4x4    = (MatrixFloat4x4)M4;

                obj.TextureValue = texture;
                Assert.AreEqual(texture, obj.TextureValue, "2 TextureValue");

                obj.FloatValue = 0.5f;
                Assert.AreEqual(0.5f, obj.FloatValue, "2 FloatValue");

                obj.FloatVector2Value = V2;
                Asserts.AreEqual(V2, obj.FloatVector2Value, "2 FloatVector2Value");

                obj.FloatVector3Value = V3;
                Asserts.AreEqual(V3, obj.FloatVector3Value, "2 FloatVector3Value");

                obj.FloatVector4Value = V4;
                Asserts.AreEqual(V4, obj.FloatVector4Value, "2 FloatVector4Value");

                obj.FloatMatrix2Value = M2;
                Asserts.AreEqual(M2, obj.FloatMatrix2Value, "2 FloatMatrix2Value");

                obj.FloatMatrix3Value = M3;
                Asserts.AreEqual(M3, obj.FloatMatrix3Value, "2 FloatMatrix3Value");

                obj.FloatMatrix4Value = M4;
                Asserts.AreEqual(M4, obj.FloatMatrix4Value, "2 FloatMatrix4Value");
            }

            bool hasSimdConstructors = TestRuntime.CheckXcodeVersion(8, 0);

            using (var obj = new SKUniform("name", texture)) {
                Assert.AreEqual(texture, obj.TextureValue, "3 TextureValue");
            }

            using (var obj = new SKUniform("name", 3.1415f)) {
                Assert.AreEqual(3.1415f, obj.FloatValue, "4 FloatValue");
            }

            using (var obj = new SKUniform("name", V2)) {
                Asserts.AreEqual(V2, obj.FloatVector2Value, "5 FloatVector2Value");
            }

            using (var obj = new SKUniform("name", V3)) {
                Asserts.AreEqual(V3, obj.FloatVector3Value, "6 FloatVector3Value");
            }

            using (var obj = new SKUniform("name", V4)) {
                Asserts.AreEqual(V4, obj.FloatVector4Value, "7 FloatVector4Value");
            }

            using (var obj = new SKUniform("name", M2)) {
                Asserts.AreEqual(M2, obj.FloatMatrix2Value, "8 FloatMatrix2Value");
                Asserts.AreEqual(M2, MatrixFloat2x2.Transpose(CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value")), "8b FloatMatrix2Value");
            }

            using (var obj = new SKUniform("name", M3)) {
                Asserts.AreEqual(M3, obj.FloatMatrix3Value, "9 FloatMatrix3Value");
                Asserts.AreEqual(M3, MatrixFloat3x3.Transpose(CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value")), "9b FloatMatrix3Value");
            }

            using (var obj = new SKUniform("name", M4)) {
                Asserts.AreEqual(M4, obj.FloatMatrix4Value, "10 FloatMatrix4Value");
                Asserts.AreEqual(M4, MatrixFloat4x4.Transpose(CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value")), "10b FloatMatrix4Value");
            }

            using (var obj = new SKUniform("name", M2x2)) {
                Asserts.AreEqual(M2x2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value");
                Asserts.AreEqual(M2x2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value");
                var tmp2 = new MatrixFloat2x2(9, 8, 7, 6);
                obj.MatrixFloat2x2Value = tmp2;
                Asserts.AreEqual(tmp2, obj.MatrixFloat2x2Value, "11 MatrixFloat2x2Value second");
                Asserts.AreEqual(tmp2, CFunctions.GetMatrixFloat2x2(obj, "matrixFloat2x2Value"), "11b MatrixFloat2x2Value second");
            }

            using (var obj = new SKUniform("name", M3x3)) {
                Asserts.AreEqual(M3x3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value");
                Asserts.AreEqual(M3x3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value");
                var tmp3 = new MatrixFloat3x3(9, 8, 7, 6, 5, 4, 3, 2, 1);
                obj.MatrixFloat3x3Value = tmp3;
                Asserts.AreEqual(tmp3, obj.MatrixFloat3x3Value, "12 MatrixFloat3x3Value second");
                Asserts.AreEqual(tmp3, CFunctions.GetMatrixFloat3x3(obj, "matrixFloat3x3Value"), "12b MatrixFloat3x3Value second");
            }

            using (var obj = new SKUniform("name", M4x4)) {
                Asserts.AreEqual(M4x4, obj.MatrixFloat4x4Value, "13  MatrixFloat4x4Value");
                Asserts.AreEqual(M4x4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b FloatMatrix4Value");
                var tmp4 = new MatrixFloat4x4(9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6);
                obj.MatrixFloat4x4Value = tmp4;
                Asserts.AreEqual(tmp4, obj.MatrixFloat4x4Value, "13 MatrixFloat4x4Value second");
                Asserts.AreEqual(tmp4, CFunctions.GetMatrixFloat4x4(obj, "matrixFloat4x4Value"), "13b MatrixFloat4x4Value second");
            }
        }
Exemplo n.º 20
0
 public static MatrixFloat4x4 GetLocalTransform4x4(this IMDLTransformComponent This, double time)
 {
     return(MatrixFloat4x4.Transpose((MatrixFloat4x4)GetLocalTransform(This, time)));
 }
Exemplo n.º 21
0
        public void Ctors()
        {
            Matrix4 id = Matrix4.Identity;
            var     V3 = new Vector3(1, 2, 3);

            using (var obj = new MDLTransform(id)) {
                Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation");
                Asserts.AreEqual(Vector3.One, obj.Scale, "Scale");
                Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation");
                Asserts.AreEqual(id, obj.Matrix, "Matrix");
                if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    Asserts.AreEqual(false, obj.ResetsTransform, "ResetsTransform");
                }

                obj.Translation = V3;
                Asserts.AreEqual(V3, obj.Translation, "Translation 2");
            }

            if (TestRuntime.CheckXcodeVersion(8, 0))
            {
                using (var obj = new MDLTransform(id, true)) {
                    Asserts.AreEqual(Vector3.Zero, obj.Translation, "Translation");
                    Asserts.AreEqual(Vector3.One, obj.Scale, "Scale");
                    Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation");
                    Asserts.AreEqual(id, obj.Matrix, "Matrix");
                    Asserts.AreEqual(true, obj.ResetsTransform, "ResetsTransform");

                    obj.Translation = V3;
                    Asserts.AreEqual(V3, obj.Translation, "Translation 2");
                }
            }

            using (var obj = new MDLTransform(id)) {
                V3       *= 2;
                obj.Scale = V3;
                Asserts.AreEqual(V3, obj.Scale, "Scale 2");
            }

            using (var obj = new MDLTransform(id)) {
                V3          *= 2;
                obj.Rotation = V3;
                Asserts.AreEqual(V3, obj.Rotation, "Rotation 2");
            }

            using (var obj = new MDLTransform(id)) {
                V3          *= 2;
                obj.Rotation = V3;
                Asserts.AreEqual(V3, obj.Rotation, "Rotation 2");
            }

            var m4 = new Matrix4(
                4, 0, 0, 0,
                0, 3, 0, 0,
                0, 0, 2, 0,
                2, 3, 4, 1);

            using (var obj = new MDLTransform(m4)) {
                Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 3");
                Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 3");
                Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 3");
                Asserts.AreEqual(m4, obj.Matrix, 0.0001f, "Matrix 3");
            }

            var m4x4 = new MatrixFloat4x4(
                4, 0, 0, 2,
                0, 3, 0, 3,
                0, 0, 2, 4,
                0, 0, 0, 1);

            using (var obj = new MDLTransform(m4x4)) {
                Asserts.AreEqual(Vector3.Zero, obj.Rotation, "Rotation 4");
                Asserts.AreEqual(new Vector3(4, 3, 2), obj.Scale, "Scale 4");
                Asserts.AreEqual(new Vector3(2, 3, 4), obj.Translation, "Translation 4");
                Asserts.AreEqual(m4x4, obj.GetMatrix4x4(), 0.0001f, "Matrix4x4 4");
                Asserts.AreEqual(m4x4, CFunctions.GetMatrixFloat4x4(obj, "matrix"), 0.0001f, "Matrix4x4-native 4");
            }
        }
Exemplo n.º 22
0
 public static void SetMatrix4x4(this IMDLTransformComponent self, MatrixFloat4x4 value)
 {
     self.Matrix = (Matrix4)MatrixFloat4x4.Transpose(value);
 }