public static void Write(string path, Octree octree) { Console.WriteLine("Building faces"); var verts = BuildFaces(octree); verts = verts.Select(x => x * 100).ToList(); Console.Error.WriteLine($"Writing {verts.Count} vertices"); using var sw = new StreamWriter(path, false); sw.WriteLine("solid marched"); for (var i = 0; i < verts.Count; i += 3) { var a = verts[i]; var b = verts[i + 1]; var c = verts[i + 2]; sw.WriteLine("facet normal 0 0 0"); sw.WriteLine("outer loop"); sw.WriteLine($"vertex {a.X} {a.Y} {a.Z}"); sw.WriteLine($"vertex {b.X} {b.Y} {b.Z}"); sw.WriteLine($"vertex {c.X} {c.Y} {c.Z}"); sw.WriteLine("endloop"); sw.WriteLine("endfacet"); } sw.WriteLine("endsolid marched"); }
static List <Vec3> BuildFaces(Octree octree) => octree.RootPath.Leaves.Select(leaf => {