private static void addIndex(Vertex vert) { ushort index = (ushort)vertices.IndexOf(vert); if (index == unchecked((ushort)-1)) { vertices.Add(vert); index = (ushort)(vertices.Count - 1); } indices.Add(index); }
private void MakeIndices(string[] lineParts) { string[] vertParts1 = lineParts[1].Split('/'); Vertex vert1 = new Vertex { position = positions[int.Parse(vertParts1[0]) - 1], textureCoord = textureCoords[int.Parse(vertParts1[1]) - 1], normal = normals[int.Parse(vertParts1[2]) - 1], }; addIndex(vert1); string[] vertParts2 = lineParts[2].Split('/'); Vertex vert2 = new Vertex { position = positions[int.Parse(vertParts2[0])-1], textureCoord = textureCoords[int.Parse(vertParts2[1]) - 1], normal = normals[int.Parse(vertParts2[2])-1], }; addIndex(vert2); string[] vertParts3 = lineParts[3].Split('/'); Vertex vert3 = new Vertex { position = positions[int.Parse(vertParts3[0])-1], textureCoord = textureCoords[int.Parse(vertParts3[1]) - 1], normal = normals[int.Parse(vertParts3[2])-1], }; addIndex(vert3); }