/// <remarks>v0 is connected to v1 and v1 is connected to v2</remarks> private void AddFaceFrom(List <PolygonFace> faces, PolygonVertex v0, PolygonVertex v1, PolygonVertex v2) { //search face foreach (var face in faces) { if (face.Contains(v0) && face.Contains(v1) && face.Contains(v2)) { return; } } var normal = GetVertexNormal(v0, v1, v2); for (int i = 0; i < 3; i++) { var v3 = v2.Edges[i]; if (v3 == v1) { continue; // don't walk back } var normal2 = GetVertexNormal(v1, v2, v3); var dot = Vector3.Dot(normal, normal2); if (dot < 0.85f) { continue; } for (int k = 0; k < 3; k++) { var v4 = v3.Edges[k]; if (v4 == v2) { continue; // don't walk back } var normal3 = GetVertexNormal(v2, v3, v4); dot = Vector3.Dot(normal, normal3); if (dot < 0.85f) { continue; } for (int j = 0; j < 3; j++) { if (v0 == v4.Edges[j]) { var face = new PolygonFace(normal); face.Vertices.Add(v0); face.Vertices.Add(v1); face.Vertices.Add(v2); face.Vertices.Add(v3); face.Vertices.Add(v4); faces.Add(face); } } } } return; }
private void AddFace(PolygonFace face) { int i0 = this.CurrentVertex; Vector3 v0 = face.Vertices[0].Position; Vector3 normal = face.Normal; if (Vector3.Dot(v0, normal) < 0) { AddVertex(face.Vertices[4].Position, -face.Normal); AddVertex(face.Vertices[3].Position, -face.Normal); AddVertex(face.Vertices[2].Position, -face.Normal); AddVertex(face.Vertices[1].Position, -face.Normal); AddVertex(face.Vertices[0].Position, -face.Normal); } else { AddVertex(face.Vertices[0].Position, face.Normal); AddVertex(face.Vertices[1].Position, face.Normal); AddVertex(face.Vertices[2].Position, face.Normal); AddVertex(face.Vertices[3].Position, face.Normal); AddVertex(face.Vertices[4].Position, face.Normal); } var ia = i0 + 1; for(int i=2;i<face.Vertices.Count;i++) { int ib = ia + 1; AddIndex(i0); AddIndex(ia); AddIndex(ib); ia = ib; } }
private void AddFace(PolygonFace face) { int i0 = this.CurrentVertex; Vector3 v0 = face.Vertices[0].Position; Vector3 normal = face.Normal; if (Vector3.Dot(v0, normal) < 0) { AddVertex(face.Vertices[4].Position, -face.Normal); AddVertex(face.Vertices[3].Position, -face.Normal); AddVertex(face.Vertices[2].Position, -face.Normal); AddVertex(face.Vertices[1].Position, -face.Normal); AddVertex(face.Vertices[0].Position, -face.Normal); } else { AddVertex(face.Vertices[0].Position, face.Normal); AddVertex(face.Vertices[1].Position, face.Normal); AddVertex(face.Vertices[2].Position, face.Normal); AddVertex(face.Vertices[3].Position, face.Normal); AddVertex(face.Vertices[4].Position, face.Normal); } var ia = i0 + 1; for (int i = 2; i < face.Vertices.Count; i++) { int ib = ia + 1; AddIndex(i0); AddIndex(ia); AddIndex(ib); ia = ib; } }
public static void PolygonMode(PolygonFace face, PolygonMode mode) { Delegates.glPolygonMode(face, mode); }
public static extern void glPolygonMode(PolygonFace face, PolygonMode mode);
/// <remarks>v0 is connected to v1 and v1 is connected to v2</remarks> private void AddFaceFrom(List<PolygonFace> faces, PolygonVertex v0, PolygonVertex v1, PolygonVertex v2) { //search face foreach (var face in faces) { if (face.Contains(v0) && face.Contains(v1) && face.Contains(v2)) return; } var normal = GetVertexNormal(v0, v1, v2); for (int i = 0; i < 3; i++) { var v3 = v2.Edges[i]; if (v3 == v1) continue; // don't walk back var normal2 = GetVertexNormal(v1, v2, v3); var dot = Vector3.Dot(normal, normal2); if (dot < 0.85f) continue; for (int k = 0; k < 3; k++) { var v4 = v3.Edges[k]; if (v4 == v2) continue; // don't walk back var normal3 = GetVertexNormal(v2, v3, v4); dot = Vector3.Dot(normal, normal3); if (dot < 0.85f) continue; for (int j = 0; j < 3; j++) { if (v0 == v4.Edges[j]) { var face = new PolygonFace(normal); face.Vertices.Add(v0); face.Vertices.Add(v1); face.Vertices.Add(v2); face.Vertices.Add(v3); face.Vertices.Add(v4); faces.Add(face); } } } } return; }