by Kyle J Burgess (github.com/kyy13)
mc-mesher is a lightweight marching cubes mesh generator for c
, c++
, c#
, and Unity
.
details
- Generate 3D Marching Cubes meshes from a 3D scalar field and custom ISO level.
- Produces mesh indices, vertices, and normal vector data
- Choose between face normal vectors, and vertex normal vectors.
- Trace rays through a scalar field used to generate a mesh without requiring the mesh to be generated first; detects collision with the mesh and returns the point of intersection. This method will detect collision much faster than ray tracing implementations operating on the mesh data itself.
details
- mc-mesher is designed to produce indexed marching cubes meshes with minimal vertices.
- Meshes generated with face normals tend to be much larger due to the inability to index vertices that share the same position, because they have different normal vectors.
- Mesh generation functions have
O(X*Y*Z)
time complexity where X, Y, and Z refer to the dimensions of the scalar field used to produce the mesh. - Meshes with face normals have
O(1)
temporary memory usage. - Meshes with vertex normals have
O(X*Y)
temporary memory usage.
details
- Download the latest release from the releases page.
- Drop the DLL into the your Assets folder
- Drop the mc_mesher.cs wrapper file into your Assets folder.
details
- There are precompiled binaries available on the releases page.
- See the build scripts in the scripts folder for examples on how to build with cmake.
The scripts are setup to targetmingw-w64
for64-bit windows
.
- A working
c++17
(or higher) compiler. CMake
version 3.7 or higher
- Run cmake with DCMAKE_BUILD_TYPE=Release to generate the build files
- Run make to compile
mc-mesher uses lookup tables modified from the transvoxel algorithm [1].
[1] Lengyel, Eric. “Voxel-Based Terrain for Real-Time Virtual Simulations”. PhD diss., University of California at Davis, 2010.