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); }
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); }
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); }