Ejemplo n.º 1
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");

                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");
            }
        }
Ejemplo n.º 2
0
        public void RotationMatrix()
        {
            using (var obj = new SKTransformNode()) {
                var zero = new MatrixFloat3x3();
                obj.RotationMatrix = zero;
                // In Swift, a rotated zero matrice also becomes the identity matrice.
                Asserts.AreEqual(MatrixFloat3x3.Identity, obj.RotationMatrix, "RotationMatrix");
                // Changing XRotation (or YRotation for that matter), makes the RotationMatrix change too
                obj.XRotation = (nfloat)(Math.PI / 2);
                var rotatedMatrix = new MatrixFloat3x3(
                    1, 0, 0,
                    0, 0, -1,
                    0, 1, 0
                    );
                Asserts.AreEqual(rotatedMatrix, obj.RotationMatrix, 0.000001f, "RotationMatrix a");
                Asserts.AreEqual(rotatedMatrix, CFunctions.GetMatrixFloat3x3(obj, "rotationMatrix"), 0.000001f, "RotationMatrix native a");

                // Got this matrix after setting both XRotation and YRotation to Pi/2
                rotatedMatrix = new MatrixFloat3x3(
                    0, 1, 0,
                    0, 0, -1,
                    -1, 0, 0
                    );
                obj.RotationMatrix = rotatedMatrix;
                Asserts.AreEqual(rotatedMatrix, obj.RotationMatrix, 0.000001f, "RotationMatrix b");
                Assert.AreEqual((nfloat)(Math.PI / 2), obj.XRotation, 0.000001f, "XRotation b");
                Assert.AreEqual(0, obj.YRotation, 0.000001f, "YRotation b");                  // Setting YRotation changes RotationMatrix, but setting RotationMatrix doesn't change YRotation.
            }
        }
Ejemplo n.º 3
0
        public void CreateEllipticalConeTest()
        {
            var V2 = new Vector2(1, 1);

            using (var obj = MDLMesh.CreateEllipticalCone(5, V2, 3, 1, MDLGeometryType.Triangles, true, null)) {
                Assert.IsNotNull(obj, "obj");
                if (TestRuntime.CheckXcodeVersion(8, 2))
                {
                    Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                        MaxBounds = new Vector3(0.433012783f, 4.5f, 0.5f), MinBounds = new Vector3(-0.433012783f, -0.5f, -0.25f)
                    }, obj.BoundingBox, "BoundingBox");
                    Assert.AreEqual(31, obj.VertexBuffers.Length, "VertexBuffers Count");
                }
                else if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                        MaxBounds = new Vector3(0.433012783f, 4.5f, 0.5f), MinBounds = new Vector3(-0.433012783f, -0.5f, -0.25f)
                    }, obj.BoundingBox, "BoundingBox");
                    Assert.AreEqual(3, obj.VertexBuffers.Length, "VertexBuffers Count");
                }
                else
                {
                    Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                        MaxBounds = new Vector3(0.866025448f, 0f, 1f), MinBounds = new Vector3(-0.866025388f, -5f, -0.50000006f)
                    }, obj.BoundingBox, "BoundingBox");
                    Assert.AreEqual(1, obj.VertexBuffers.Length, "VertexBuffers Count");
                }
                Assert.AreEqual(1, obj.Submeshes.Count, "Submeshes Count");
                Assert.AreEqual(13, obj.VertexCount, "VertexCount");
                Assert.AreEqual(31, obj.VertexDescriptor.Attributes.Count, "VertexDescriptor Attributes Count");
                Assert.AreEqual(31, obj.VertexDescriptor.Layouts.Count, "VertexDescriptor Layouts Count");
            }
        }
Ejemplo n.º 4
0
        public void Explicit_Operator_ToVector3()
        {
            var expected = GetTestVector();
            var actual   = (Vector3d)expected;

            Asserts.AreEqual(expected, actual, "ToVector3d");
        }
Ejemplo n.º 5
0
        public void ElementConstructor()
        {
            var expected = GetTestVector();
            var actual   = new NVector3d(expected.X, expected.Y, expected.Z);

            Asserts.AreEqual(expected, actual, "ctor 1");
        }
Ejemplo n.º 6
0
        public void Explicit_Operator_FromVector3()
        {
            var expected = new Vector3d(2, 3, 7.7d);
            var actual   = (NVector3d)expected;

            Asserts.AreEqual(expected, actual, "FromVector3d");
        }
Ejemplo n.º 7
0
        public void Explicit_Operator_FromVector3()
        {
            var expected = new Vector3(2, 3, 7.7f);
            var actual   = (VectorFloat3)expected;

            Asserts.AreEqual(expected, actual, "FromVector3");
        }
Ejemplo n.º 8
0
        public void CreateCapsuleTest()
        {
            TestRuntime.AssertXcodeVersion(8, 0);

            Vector3  V3  = new Vector3(1, 2, 3);
            Vector2i V2i = new Vector2i(4, 5);

            using (var obj = MDLMesh.CreateCapsule(V3, V2i, MDLGeometryType.Triangles, true, 10, null)) {
                Assert.IsNotNull(obj, "obj");
                if (TestRuntime.CheckXcodeVersion(8, 2))
                {
                    Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                        MaxBounds = new Vector3(0.6f, 1.166666f, 1.8f), MinBounds = new Vector3(-0.6f, -0.83333f, -1.8f)
                    }, obj.BoundingBox, "BoundingBox");
                    Assert.AreEqual(122, obj.VertexCount, "VertexCount");
                }
                else
                {
                    Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                        MaxBounds = new Vector3(0.6f, 1.333333f, 1.8f), MinBounds = new Vector3(-0.6f, -1, -1.8f)
                    }, obj.BoundingBox, "BoundingBox");
                    Assert.AreEqual(152, obj.VertexCount, "VertexCount");
                }
                Assert.AreEqual(1, obj.Submeshes.Count, "Submeshes Count");
                Assert.AreEqual(3, obj.VertexBuffers.Length, "VertexBuffers Count");
                Assert.AreEqual(31, obj.VertexDescriptor.Attributes.Count, "VertexDescriptor Attributes Count");
                Assert.AreEqual(31, obj.VertexDescriptor.Layouts.Count, "VertexDescriptor Layouts Count");
            }
        }
        public void MDLMatrix4x4ArrayTest()
        {
            // NMatrix4

            var nMatrix4Arr = new MDLMatrix4x4Array((nuint)TestMatrices.NMatrix4Array.Length);

            nMatrix4Arr.SetValues(TestMatrices.NMatrix4Array);

            var retNMatrix4Arr = nMatrix4Arr.GetNMatrix4Values();

            for (int i = 0; i < retNMatrix4Arr.Length; i++)
            {
                Asserts.AreEqual(TestMatrices.NMatrix4Array [i], retNMatrix4Arr [i], $"retNMatrix4Arr iter: {i}");
            }

            // NMatrix4d

            var nMatrix4dArr = new MDLMatrix4x4Array((nuint)TestMatrices.NMatrix4dArray.Length);

            nMatrix4dArr.SetValues(TestMatrices.NMatrix4dArray);

            var retNMatrix4dArr = nMatrix4dArr.GetNMatrix4dValues();

            for (int i = 0; i < retNMatrix4dArr.Length; i++)
            {
                Asserts.AreEqual(TestMatrices.NMatrix4dArray [i], retNMatrix4dArr [i], $"retNMatrix4dArr iter: {i}");
            }
        }
Ejemplo n.º 10
0
 public static void AreEqual(MPSImageHistogramInfo expected, MPSImageHistogramInfo actual, string message)
 {
     Assert.AreEqual(expected.HistogramForAlpha, actual.HistogramForAlpha, $"{message} HistogramForAlpha expected: {expected} actual: {actual}");
     Asserts.AreEqual(expected.MaxPixelValue, actual.MaxPixelValue, $"{message} MaxPixelValue expected: {expected} actual: {actual}");
     Asserts.AreEqual(expected.MinPixelValue, actual.MinPixelValue, $"{message} MinPixelValue expected: {expected} actual: {actual}");
     Assert.AreEqual(expected.NumberOfHistogramEntries, actual.NumberOfHistogramEntries, $"{message} NumberOfHistogramEntries expected: {expected} actual: {actual}");
 }
Ejemplo n.º 11
0
        public void GetRotationMatrixTest()
        {
#if NET
            var matrix = NMatrix4.Identity;
#else
            var matrix = Matrix4.Identity;
#endif
            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
                    );
#if NET
                Asserts.AreEqual(expected, obj.GetRotationMatrix(0), 0.00001f, "GetRotationMatrix");
#else
                Asserts.AreEqual((Matrix4)MatrixFloat4x4.Transpose(expected), obj.GetRotationMatrix(0), 0.00001f, "GetRotationMatrix");
                Asserts.AreEqual(expected, obj.GetRotationMatrix4x4(0), 0.00001f, "GetRotationMatrix4x4");
#endif
                Asserts.AreEqual(expected, CFunctions.MDLTransform_GetRotationMatrix(obj, 0), 0.00001f, "GetRotationMatrix4x4 native");
            }
        }
Ejemplo n.º 12
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");
            }
        }
Ejemplo n.º 13
0
        public void Constructors()
        {
            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogram(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");

                Assert.IsTrue(obj.ZeroHistogram, "ZeroHistogram");
                if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    // HistogramSizeForSourceFormat was introduced in iOS 9, but no matter which MTLPixelFormat value I pass in,
                    // the native histogramSizeForSourceFormat: function rudely aborts the entire process with an abrupt:
                    // > /BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalImage/MetalImage-39.3/MetalImage/Filters/MIHistogram.mm:103: failed assertion `[MPSImageHistogram histogramSizeForSourceFormat:] unsupported texture format: 114'
                    // I made sure the MTLPixelFormat values I tested with were also added in iOS 9, so that's not the problem.
                    // Conclusion: just avoid executing HistogramSizeForSourceFormat on anything below iOS 10.rm
                    Assert.AreEqual(3072, obj.GetHistogramSize(MTLPixelFormat.RGBA16Sint), "HistogramSizeForSourceFormat");
                }
                var crs = obj.ClipRectSource;
                Assert.AreEqual(0, crs.Origin.X, "ClipRectSource.Origin.X");
                Assert.AreEqual(0, crs.Origin.Y, "ClipRectSource.Origin.Y");
                Assert.AreEqual(0, crs.Origin.Z, "ClipRectSource.Origin.Z");
                Assert.AreEqual(-1, crs.Size.Depth, "ClipRectSource.Size.Depth");
                Assert.AreEqual(-1, crs.Size.Height, "ClipRectSource.Size.Height");
                Assert.AreEqual(-1, crs.Size.Width, "ClipRectSource.Size.Width");
            }
        }
Ejemplo n.º 14
0
 public static void AreEqual(MPSImageHistogramInfo expected, MPSImageHistogramInfo actual, string message)
 {
     Assert.AreEqual(expected.HistogramForAlpha, actual.HistogramForAlpha, message + " HistogramForAlpha");
     Asserts.AreEqual(expected.MaxPixelValue, actual.MaxPixelValue, message + " MaxPixelValue");
     Asserts.AreEqual(expected.MinPixelValue, actual.MinPixelValue, message + " MinPixelValue");
     Assert.AreEqual(expected.NumberOfHistogramEntries, actual.NumberOfHistogramEntries, message + " NumberOfHistogramEntries");
 }
Ejemplo n.º 15
0
        public void BoundingBoxTest()
        {
            MDLAxisAlignedBoundingBox box = new MDLAxisAlignedBoundingBox(
                new Vector3(4, 5, 6),
                new Vector3(1, 2, 3)
                );

            using (var data = new NSData()) {
                using (var obj = new MDLVoxelArray(data, box, 1.0f)) {
                    Asserts.AreEqual(box, obj.BoundingBox, "BoundingBox");

                    var extents = new MDLVoxelIndexExtent2(
                        new Vector4i(1, 2, 3, 4),
                        new Vector4i(5, 6, 7, 8));
                    var voxels = obj.GetVoxels(extents);
                    Assert.IsNull(voxels, "GetVoxels");

                    extents = obj.VoxelIndexExtent2;
                    Assert.That(extents.MaximumExtent.X, Is.EqualTo(-1).Or.EqualTo(0), "MaxX");
                    Assert.That(extents.MaximumExtent.Y, Is.EqualTo(-1).Or.EqualTo(0), "MaxY");
                    Assert.That(extents.MaximumExtent.Z, Is.EqualTo(-1).Or.EqualTo(0), "MaxZ");
                    Asserts.AreEqual(0, extents.MaximumExtent.W, "MaxW");
                    Asserts.AreEqual(0, extents.MinimumExtent.X, "MinX");
                    Asserts.AreEqual(0, extents.MinimumExtent.Y, "MinY");
                    Asserts.AreEqual(0, extents.MinimumExtent.Z, "MinZ");
                    Asserts.AreEqual(0, extents.MinimumExtent.W, "MinW");
                }
            }
        }
Ejemplo n.º 16
0
        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");
            }
        }
Ejemplo n.º 17
0
        public void RotationTest()
        {
            using (var obj = new GKAgent3D()) {
                var initial = new Matrix3(0, 0, 1,
                                          0, 1, 0,
                                          1, 0, 0);
                Asserts.AreEqual(initial, obj.Rotation, "Rotation");
                Asserts.AreEqual((MatrixFloat3x3)initial, obj.Rotation3x3, "Rotation3x3");

                var mat = new Matrix3(1, 2, 3,
                                      4, 5, 6,
                                      7, 8, 9);
                var mat3x3 = (MatrixFloat3x3)mat;

                obj.Rotation = mat;
                Asserts.AreEqual(mat, obj.Rotation, "Rotation after setter");
                var transposed3x3 = MatrixFloat3x3.Transpose((MatrixFloat3x3)mat);
                Asserts.AreEqual(transposed3x3, obj.Rotation3x3, "Rotation3x3 after setter");
                Asserts.AreEqual(transposed3x3, CFunctions.GetMatrixFloat3x3(obj, "rotation"), "Rotation3x3 after setter native");

                obj.Rotation3x3 = mat3x3;
                Asserts.AreEqual(mat3x3, obj.Rotation3x3, "Rotation3x3 after setter 3x3");
                Asserts.AreEqual(mat3x3, CFunctions.GetMatrixFloat3x3(obj, "rotation"), "Rotation3x3 after setter native 3x3");
            }
        }
Ejemplo n.º 18
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");
        }
Ejemplo n.º 19
0
        public void MDLAnimatedQuaternionTest()
        {
            // Quaternion
            TestRuntime.AssertXcodeVersion(11, 0);

            using (var animatedQuat = new MDLAnimatedQuaternion()) {
                var quat = new Quaternion(1.1f, 2.2f, 3.3f, 4.4f);

                animatedQuat.SetQuaternion(quat, 0);
                var returnedQuat = animatedQuat.GetFloatQuaternion(0);
                Asserts.AreEqual(quat, returnedQuat, "A");

                animatedQuat.Reset(TestMatrices.QuaternionArray, TestMatrices.GetTimesArray(TestMatrices.QuaternionArray.Length));
                var arr = animatedQuat.GetQuaternionValues(20);
                Asserts.AreEqual(TestMatrices.QuaternionArray, arr, "C1");
            }


            using (var animatedQuat = new MDLAnimatedQuaternion()) {
                var quatd = new Quaterniond(10.1, 20.2, 30.3, 40.4);

                animatedQuat.SetQuaternion(quatd, 0);
                Asserts.AreEqual(quatd, animatedQuat.GetDoubleQuaternion(0), 0.0001, "B");

                animatedQuat.Reset(TestMatrices.QuaterniondArray, TestMatrices.GetTimesArray(TestMatrices.QuaterniondArray.Length));
                var arrd = animatedQuat.GetQuaterniondValues(20);
                Asserts.AreEqual(TestMatrices.QuaterniondArray, arrd, "C2");
            }
        }
Ejemplo n.º 20
0
        public void CreatePlaneTest()
        {
            var V2  = new Vector2(3, 3);
            var V2i = new Vector2i(3, 3);

            using (var obj = MDLMesh.CreatePlane(V2, V2i, MDLGeometryType.Triangles, null)) {
                Assert.IsNotNull(obj, "obj");
                Asserts.AreEqual(new MDLAxisAlignedBoundingBox {
                    MaxBounds = new Vector3(1.5f, 0, 1.5f), MinBounds = new Vector3(-1.5f, 0, -1.5f)
                }, obj.BoundingBox, "BoundingBox");
                Assert.AreEqual(1, obj.Submeshes.Count, "Submeshes Count");
#if MONOMAC
                var vb = 31;
#else
                int vb = 1;
                if (TestRuntime.CheckXcodeVersion(8, 2))
                {
                    vb = 31;
                }
                else if (TestRuntime.CheckXcodeVersion(8, 0))
                {
                    vb = 1;
                }
#endif
                Assert.AreEqual(vb, obj.VertexBuffers.Length, "VertexBuffers Count");
                Assert.AreEqual(16, obj.VertexCount, "VertexCount");
                Assert.AreEqual(31, obj.VertexDescriptor.Attributes.Count, "VertexDescriptor Attributes Count");
                Assert.AreEqual(31, obj.VertexDescriptor.Layouts.Count, "VertexDescriptor Layouts Count");
            }
        }
Ejemplo n.º 21
0
        public void Ctor()
        {
            var V2 = new Vector2i(123, 456);

            using (var obj = new MDLTexture(null, true, null, V2, 12, 2, MDLTextureChannelEncoding.Float16, false)) {
                Asserts.AreEqual(V2, obj.Dimensions, "dimensions");
            }
        }
Ejemplo n.º 22
0
        public void DimensionsTest()
        {
            var V2 = new Vector2i(123, 456);

            using (var txt = new MDLTexture()) {
                Asserts.AreEqual(Vector2i.Zero, txt.Dimensions, "a");
            }
        }
        public void ElementConstructor()
        {
            var expected = GetTestMatrix();
            var actual   = new MatrixFloat2x2(expected.R0C0, expected.R0C1,
                                              expected.R1C0, expected.R1C1);

            Asserts.AreEqual(expected, actual, "ctor 1");
        }
Ejemplo n.º 24
0
 public void Ctors()
 {
     using (var obj = new MDLVertexAttribute("name", MDLVertexFormat.Float3, 1, 2)) {
         Assert.AreEqual("name", obj.Name, "Name");
         Assert.AreEqual(MDLVertexFormat.Float3, obj.Format, "Format");
         Assert.AreEqual((nuint)1, obj.Offset, "Offset");
         Assert.AreEqual((nuint)2, obj.BufferIndex, "BufferIndex");
         Asserts.AreEqual(new Vector4(0, 0, 0, 1), obj.InitializationValue, "InitializationValue");
     }
 }
Ejemplo n.º 25
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");
        }
Ejemplo n.º 26
0
 public void BoundingBoxTest()
 {
     using (var obj = new MDLAsset()) {
         MDLAxisAlignedBoundingBox box = new MDLAxisAlignedBoundingBox(
             new Vector3(-1, -1, -1),
             new Vector3(0, 0, 0)
             );
         Asserts.AreEqual(box, obj.BoundingBox, "BoundingBox");
     }
 }
Ejemplo n.º 27
0
        public void TransposeInstance()
        {
            var expected = GetTestMatrix();
            var actual   = (MatrixFloat3x3)expected;

            expected.Transpose();
            actual.Transpose();

            Asserts.AreEqual(expected, actual, "transpose");
        }
        public void Constructors()
        {
            MPSImageHistogramInfo info = new MPSImageHistogramInfo();

            info.NumberOfHistogramEntries = 256;
            using (var obj = new MPSImageHistogramSpecification(MTLDevice.SystemDefault, ref info)) {
                var rv = obj.HistogramInfo;
                Asserts.AreEqual(info, rv, "HistogramForAlpha");
            }
        }
Ejemplo n.º 29
0
        public void RotationAtTimeTest()
        {
            var matrix = Matrix4.Identity;
            var V3     = new Vector3(1, 2, 3);

            using (var obj = new MDLTransform(matrix)) {
                obj.SetRotation(V3, 0);
                Asserts.AreEqual(V3, obj.GetRotation(0), "RotationAtTime");
            }
        }
        public void Identity()
        {
            var identity = new MatrixFloat2x2 {
                R0C0 = 1f,
                R1C1 = 1f,
            };

            Asserts.AreEqual(identity, MatrixFloat2x2.Identity, "identity");
            Asserts.AreEqual(Matrix2.Identity, MatrixFloat2x2.Identity, "opentk identity");
        }