private static Triangle ParseFace(string[] parts) { Triangle result = new Triangle(); if (parts[1].Contains("//")) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int normal = int.Parse(indexes[1]); result[i - 1] = new VertexInfo() { position = position, normal = normal, uv = -1 }; } } else if (parts[1].Contains("/")) { int components = parts[1].Split('/').Length; if (components == 2) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int uv = int.Parse(indexes[1]); result[i - 1] = new VertexInfo() { position = position, normal = -1, uv = uv }; } } else if (components == 3) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int uv = int.Parse(indexes[1]); int normal = int.Parse(indexes[2]); result[i - 1] = new VertexInfo() { position = position, normal = normal, uv = uv, }; } } } else { for (int i = 1; i < 4; i++) { int position = int.Parse(parts[i]); result[i - 1] = new VertexInfo() { position = position, normal = -1, uv = -1, }; } } return(result); }
public VertexInfo this[int index] { set { if (index == 0) { this.vertex0 = value; } else if (index == 1) { this.vertex1 = value; } else if (index == 2) { this.vertex2 = value; } else { throw new ArgumentException(); } } }
private static Triangle ParseFace(string[] parts) { Triangle result = new Triangle(); if (parts[1].Contains("//")) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int normal = int.Parse(indexes[1]); result[i - 1] = new VertexInfo() { position = position, normal = normal, uv = -1 }; } } else if (parts[1].Contains("/")) { int components = parts[1].Split('/').Length; if (components == 2) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int uv = int.Parse(indexes[1]); result[i - 1] = new VertexInfo() { position = position, normal = -1, uv = uv }; } } else if (components == 3) { for (int i = 1; i < 4; i++) { string[] indexes = parts[i].Split('/'); int position = int.Parse(indexes[0]); int uv = int.Parse(indexes[1]); int normal = int.Parse(indexes[2]); result[i - 1] = new VertexInfo() { position = position, normal = normal, uv = uv, }; } } } else { for (int i = 1; i < 4; i++) { int position = int.Parse(parts[i]); result[i - 1] = new VertexInfo() { position = position, normal = -1, uv = -1, }; } } return result; }