public static IEnumerable <(IVertexBuilder A, IVertexBuilder B, IVertexBuilder C, Material Material)> EvaluateTriangles(this MeshPrimitive prim, MESHXFORM xform = null) { if (prim == null) { yield break; } if (xform != null && !xform.Visible) { yield break; } var triangles = prim.GetTriangleIndices(); if (!triangles.Any()) { yield break; } var vertices = prim.GetVertexColumns(xform); var vtype = vertices.GetCompatibleVertexType(); foreach (var t in triangles) { var a = vertices.GetVertex(vtype, t.A); var b = vertices.GetVertex(vtype, t.B); var c = vertices.GetVertex(vtype, t.C); yield return(a, b, c, prim.Material); } }
public static IEnumerable <(IVertexBuilder A, IVertexBuilder B, Material Material)> EvaluateLines(this MeshPrimitive prim, MESHXFORM xform = null) { if (prim == null) { yield break; } if (xform != null && !xform.Visible) { yield break; } var lines = prim.GetLineIndices(); if (!lines.Any()) { yield break; } var vertices = prim.GetVertexColumns(xform); var vtype = vertices.GetCompatibleVertexType(); foreach (var(la, lb) in lines) { var va = vertices.GetVertex(vtype, la); var vb = vertices.GetVertex(vtype, lb); yield return(va, vb, prim.Material); } }
public static IEnumerable <(IVertexBuilder A, Material Material)> EvaluatePoints(this MeshPrimitive prim, MESHXFORM xform = null) { if (prim == null) { yield break; } if (xform != null && !xform.Visible) { yield break; } var points = prim.GetPointIndices(); if (!points.Any()) { yield break; } var vertices = prim.GetVertexColumns(xform); var vtype = vertices.GetCompatibleVertexType(); foreach (var t in points) { var a = vertices.GetVertex(vtype, t); yield return(a, prim.Material); } }
public static IEnumerable <(IVertexBuilder A, IVertexBuilder B, IVertexBuilder C, Material Material)> EvaluateTriangles(this MeshPrimitive prim, MESHXFORM xform = null) { if (prim == null) { yield break; } if (xform != null && !xform.Visible) { yield break; } var vertices = prim.GetVertexColumns(); var triangles = prim.GetTriangleIndices(); if (!triangles.Any()) { yield break; } foreach (var xinst in Transforms.InstancingTransform.Evaluate(xform)) { var xvertices = xinst != null?vertices.WithTransform(xinst) : vertices; var vtype = vertices.GetCompatibleVertexType(); foreach (var(ta, tb, tc) in triangles) { var va = xvertices.GetVertex(vtype, ta); var vb = xvertices.GetVertex(vtype, tb); var vc = xvertices.GetVertex(vtype, tc); yield return(va, vb, vc, prim.Material); } } }