Пример #1
0
 void createIndices()
 {
     for (int x = 0; x < w - 1; x++)
         for (int z = 0; z < h - 1; z++)
         {
             int upperLeft = (z * w + x);
             int upperRight = (upperLeft + 1);
             int lowerLeft = (upperLeft + w);
             int lowerRight = (lowerLeft + 1);
             SmoothMeshTriangle fmt = new SmoothMeshTriangle(upperLeft, upperRight, lowerLeft, m, Name + x + "" + z);
             box = BBox.Join(box, fmt.GetBoundingBox());
             m.AddObject(fmt);
             SmoothMeshTriangle fmt2 = new SmoothMeshTriangle(lowerLeft, upperRight, lowerRight, m, Name + x + "" + z + "2");
             box = BBox.Join(box, fmt2.GetBoundingBox());
             m.AddObject(fmt2);
         }
 }
Пример #2
0
 void parseFaces()
 {
     for (int i = 0; i < lines.Length; i++)
     {
         if (lines[i][0] == 'f')
         {
             string[] w = lines[i].Replace("f ", "").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
             for (int j = 0; j < w.Length - 2; j++)
             {
                 if (hasNormals)
                 {
                     SmoothMeshTriangle fmt = new SmoothMeshTriangle(int.Parse(w[j]) - 1, int.Parse(w[j + 1]) - 1, int.Parse(w[j + 2]) - 1, ret, i + "" + j + "smsh" + "Mesh" + ret.Name);
                     ret.AddObject(fmt);
                 }
                 else
                 {
                     FlatMeshTriangle fmt = new FlatMeshTriangle(int.Parse(w[j]) - 1, int.Parse(w[j + 1]) - 1, int.Parse(w[j + 2]) - 1, ret, i + "" + j + "fmsh" + "Mesh" + ret.Name);
                     fmt.ComputeNormal(false);
                     ret.AddObject(fmt);
                 }
             }
         }
     }
 }
Пример #3
0
 static void getFaces(Mesh mesh, RElement ele)
 {
     bool hasNormals = ele.HasElement("Mesh.Normals");
     int i = -1;
     foreach (RElement xe in ele.GetElement(P.Obj.Mesh + ".Faces").Elements)
     {
         i++;
         string[] w = xe.Attributes["Indices"].Value.Replace(" ", "").Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         if (hasNormals)
         {
             SmoothMeshTriangle fmt = new SmoothMeshTriangle(int.Parse(w[0]), int.Parse(w[1]), int.Parse(w[2]), mesh, i + "" + "smsh" + "Mesh" + mesh.Name);
             mesh.AddObject(fmt);
         }
         else
         {
             FlatMeshTriangle fmt = new FlatMeshTriangle(int.Parse(w[0]), int.Parse(w[1]), int.Parse(w[2]), mesh, i + "" + "fmsh" + "Mesh" + mesh.Name);
             fmt.ComputeNormal(false);
             mesh.AddObject(fmt);
         }
     }
 }