private void ParseLine(string keyword, string data) { switch (keyword) { case "v": if (isLastLineAFace) { graphObject.Groups.Add(group); group = new Group(); isLastLineAFace = false; } group.Vertices.Add(VertexParser.Parse(data)); break; case "vt": group.VertexTextures.Add(VertexTextureParser.Parse(data)); break; case "vn": group.VertexNormals.Add(VertexNormalParser.Parse(data)); break; case "f": group.Faces.Add(FaceParser.Parse(data)); isLastLineAFace = true; break; default: break; } }
public void AddVertCoords(IEnumerable <string> vertices) { var tmpVertex = vertices.ToArray(); try { if (tmpVertex.Length != 3) { throw new ArgumentException(); } var vert3 = VertexParser.Parse(tmpVertex[0], tmpVertex[1], tmpVertex[2]); VertCoords.Add(vert3); } catch { _vertCoordsDamaged.Add(VertCoords.Count, string.Join(" ", vertices)); VertCoords.Add(Vector3.Zero); } }
public void AddTextCoords(IEnumerable <string> vertices) { string[] tmpVertex = vertices.ToArray(); try { if (tmpVertex.Length != 2 && tmpVertex.Length != 3) { throw new ArgumentException(); } Vector2 vert2 = VertexParser.Parse(tmpVertex[0], tmpVertex[1]); TexCoords.Add(vert2); } catch { texCoordsDamaged.Add(TexCoords.Count, String.Join(" ", vertices)); //Console.WriteLine(String.Join(" ", vertexes)); TexCoords.Add(Vector2.Zero); } }
public void AddNormals(IEnumerable <string> vertices) { string[] tmpVertex = vertices.ToArray(); try { if (tmpVertex.Length != 3) { throw new ArgumentException(); } Vector3 vert3 = VertexParser.Parse(tmpVertex[0], tmpVertex[1], tmpVertex[2]); Normals.Add(vert3); } catch { normalsDamaged.Add(Normals.Count, String.Join(" ", vertices)); //Console.WriteLine(String.Join(" ", vertexes)); Normals.Add(Vector3.Zero); } }