Exemple #1
0
        public void ClonePolygon()
        {
            Vertex a = new Vertex(new Vector3(0, 0, 0), Vector3.Zero);
            Vertex b = new Vertex(new Vector3(0, 1, 0), Vector3.Zero);
            Vertex c = new Vertex(new Vector3(1, 0, 0), Vector3.Zero);

            Polygon abc = new Polygon(a, b, c);
            Polygon abc2 = abc.Clone();

            Assert.AreEqual(abc.Plane, abc2.Plane);
        }
Exemple #2
0
        public void UpwardNormals()
        {
            Polygon p = new Polygon(new[] //Wound anto clockwise
            {
                new Vertex(new Vector3(0,0,0), Vector3.Zero),
                new Vertex(new Vector3(0,0,1), Vector3.Zero),
                new Vertex(new Vector3(1,0,1), Vector3.Zero),
                new Vertex(new Vector3(1,0,0), Vector3.Zero),
            });

            Assert.AreEqual(Vector3.Up, p.Plane.Normal);
        }
Exemple #3
0
        public void NormalWinding()
        {
            Vertex a = new Vertex(new Vector3(0, 0, 0), Vector3.Zero);
            Vertex b = new Vertex(new Vector3(0, 1, 0), Vector3.Zero);
            Vertex c = new Vertex(new Vector3(1, 0, 0), Vector3.Zero);

            Polygon abc = new Polygon(a, b, c);
            Polygon cba = new Polygon(c, b, a);

            Vector3 abcNormal = Vector3.Cross(b.Position - a.Position, c.Position - a.Position);
            Assert.AreEqual(abcNormal, abc.Plane.Normal);

            Vector3 cbaNormal = Vector3.Cross(b.Position - c.Position, a.Position - c.Position);
            Assert.AreEqual(cbaNormal, cba.Plane.Normal);

            Assert.AreNotEqual(abc.Plane, cba.Plane);
            cba.Flip();
            Assert.AreEqual(abc.Plane, cba.Plane);
        }