Skip to main content

MarchingCubes

A static class in Root.Township, the global namespace.

Static marching cubes mesher: turns a cell of eight density values into triangles at an iso level. Used by the cave MarchingCubesPlugin.

Fields​

3 private and internal fields
MemberWhat it is
private static int[] edgeMapsTableLookup of which cube edges the surface crosses for each corner pattern.
private static MarchingCubes.Point4[] edgeOffsetsFor each of the 12 edges, its offset and axis as a Point4, used as a vertex key.
private static int[,] triTableLookup of the triangles to build for each corner pattern, ended by -1.

Methods​

MemberWhat it is
static void Polygonise(MarchingCubes.GridCell grid, float isolevel, List<MarchingCubes.Triangle> triangles, Vector3[] vertlist)Adds the triangles for one grid cell to triangles, with edge keys so shared vertices can be merged.
static Vector3 VertexInterp(float isolevel, Vector3 p1, Vector3 p2, float valp1, float valp2)Returns the point between two corners where the density crosses the iso level.