Beispiel #1
0
        public void setdata_sets_data_from_the_top_left_of_a_larger_array()
        {
            var p = new Patch(3, 3);
            var f = Get4x4Heights();

            p.SetData(f, 4, 4, 0, 0, new Vector2(0f, 0f));

            Assert.IsTrue(Math.Abs(45 - p.Vertices.Select(v => v.Position.Y).Sum()) < 0.1, string.Format("expected sum of 45, got {0}", p.Vertices.Select(v => v.Position.Y).Sum()));
        }
Beispiel #2
0
        public void setdata_sets_texcoords_correctly_for_top_left_patch()
        {
            var p = new Patch(3, 3);
            var f = Get4x4Heights();

            p.SetData(f, 4, 4, 1, 1, new Vector2(0f, 0f));

            Assert.IsTrue(Math.Abs(p.Vertices[0].TextureCoordinate.X) < 0.001f);
            Assert.IsTrue(Math.Abs(p.Vertices[0].TextureCoordinate.Y) < 0.001f);

            Assert.IsTrue(Math.Abs((2f / 256f) - p.Vertices[8].TextureCoordinate.X) < 0.001f);
            Assert.IsTrue(Math.Abs((2f / 256f) - p.Vertices[8].TextureCoordinate.Y) < 0.001f);
        }
Beispiel #3
0
        public void setupindices_works()
        {
            var p = new Patch(3, 3);
            p.SetupIndices();

            Assert.AreEqual(3, p.Index[0]);
            Assert.AreEqual(0, p.Index[1]);
            Assert.AreEqual(4, p.Index[2]);
            Assert.AreEqual(1, p.Index[3]);

            Assert.AreEqual(7, p.Index[8]);
            Assert.AreEqual(4, p.Index[9]);
            Assert.AreEqual(8, p.Index[10]);
            Assert.AreEqual(5, p.Index[11]);
        }