Example #1
0
        private static ColoredTriangleSoup ComputeSoup(string data, int numVertices, int numFaces)
        {
            string[] lines
            = data.Trim().Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries);
              List<string> filteredList = new List<string>();
              foreach (string line in lines)
            if (line.Trim() != "")
              filteredList.Add(line.Trim());

              // Find vector3's first
              Vector3[] vs = new Vector3[numVertices];
              for (int v = 0; v < vs.Length; v++)
            vs[v] = ParseVector3(filteredList[v]);

              ColoredTriangleSoup soup = new ColoredTriangleSoup();
              for (int f = 0; f < numFaces; f++)
              {
            int i, j, k;
            FindFaceIndices(filteredList[f+numVertices], out i, out j, out k);
            ColoredTriangle tri = new ColoredTriangle(Color.White,
              new Triangle(vs[i], vs[j], vs[k]));
            soup.Add(tri);
              }

              return soup;
        }
Example #2
0
 private static ColoredTriangle ScaleTriangle(ColoredTriangle tri, float side)
 {
     return new ColoredTriangle(
     tri.Color,
     new Triangle(
     Vector3.Mult(tri.Triangle.P1, side),
     Vector3.Mult(tri.Triangle.P2, side),
     Vector3.Mult(tri.Triangle.P3, side)));
 }
 public void NullTriangleNotOK()
 {
     ColoredTriangle tri = new ColoredTriangle(Color.Black, null);
 }
 public void Equals2()
 {
     ColoredTriangle ct1 = new ColoredTriangle(Color.White, TriangleFixture.ConstructTriangle());
       ColoredTriangle ct2 = new ColoredTriangle(Color.Blue, TriangleFixture.ConstructTriangle());
       Assert.AreNotEqual(ct1, ct2);
 }
 public void AccessTriangle()
 {
     Triangle tri = TriangleFixture.ConstructTriangle();
       ColoredTriangle ct = new ColoredTriangle(Color.White, tri);
       Assert.AreEqual(tri, ct.Triangle);
 }