Example #1
0
        public override Vertex Interpolate(Vertex other, float t)
        {
            var pos = Vector3.Lerp(Position, other.Position, t);
            var norm = Vector3.Lerp(Normal, other.Normal, t);

            var colorVertex = other as ColorVertex;
            Color color = colorVertex == null ? Color : Color.Lerp(Color, (colorVertex).Color, t);

            return new ColorVertex(pos, norm, color);
        }
Example #2
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);
        }
Example #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);
        }
Example #4
0
 public override Vertex Interpolate(Vertex other, float t)
 {
     var b = base.Interpolate(other, t);
     return new VertexTest(b.Position, b.Normal);
 }
Example #5
0
 public virtual Vertex Interpolate(Vertex other, float t)
 {
     return new Vertex(Vector3.Lerp(Position, other.Position, t), Vector3.Lerp(Normal, other.Normal, t));
 }
Example #6
0
 public Polygon(Vertex a, Vertex b, Vertex c)
     :this(new[] { a, b, c })
 {
 }