private void parseGroup(String[] _line, int _i) { String[] nextLine = null; int j = _i; j++; if (_line[0].Equals("g")) { bool isGroup = false; for (int k = _i; k < j + 5; k++) { if (k < _fileInArray.Count - 1) { nextLine = _fileInArray[k]; // Prüfe ob nächste zeile kein Vektor ist if (nextLine[0].Equals("f")) { isGroup = true; break; } } } if (isGroup) { Mesh mesh = new Mesh(_line[1]); _meshes.Add(_line[1], mesh); _lastMesh = mesh; } } }
public void addMesh(Mesh mesh) { _meshes.Add(mesh); }
private void parseFaces(String[] _line, Mesh _mesh) { String[] vertex1 = null; String[] vertex2 = null; String[] vertex3 = null; if (_mesh != null) { if (_line[0].Equals("f")) { if (_line.Length == 4) { vertex1 = _line[1].Split('/'); vertex2 = _line[2].Split('/'); vertex3 = _line[3].Split('/'); if (vertex1.Length >= 3 && vertex2.Length >= 2 && vertex3.Length >= 3) { if (_vertices.Count > 0 && _uvs.Count > 0 && _normals.Count > 0) { double[] v1_pos = _vertices[(int.Parse(vertex1[0]) - 1)]; double[] v1_uv = _uvs[(int.Parse(vertex1[1]) - 1)]; double[] v1_normal = _normals[(int.Parse(vertex1[2]) - 1)]; double[] v2_pos = _vertices[(int.Parse(vertex2[0]) - 1)]; double[] v2_uv = _uvs[(int.Parse(vertex2[1]) - 1)]; double[] v2_normal = _normals[(int.Parse(vertex2[2]) - 1)]; double[] v3_pos = _vertices[(int.Parse(vertex3[0]) - 1)]; double[] v3_uv = _uvs[(int.Parse(vertex3[1]) - 1)]; double[] v3_normal = _normals[(int.Parse(vertex3[2]) - 1)]; Vertex v1 = new Vertex(v1_pos, v1_uv, v1_normal); Vertex v2 = new Vertex(v2_pos, v2_uv, v2_normal); Vertex v3 = new Vertex(v3_pos, v3_uv, v3_normal); Face f = new Face(v1, v2, v3); _mesh.AddFace(f); } } } } } }