Giter Site home page Giter Site logo

mc-mesher's Introduction

mc-mesher

by Kyle J Burgess (github.com/kyy13)

disp

Summary

mc-mesher is a lightweight marching cubes mesh generator for c, c++, c#, and Unity.

Features

details

Mesh Generation

  • 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.

Algorithms

  • 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.

Performance

details

Notes

  • 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.

Quick Start

details

Unity Steps

  1. Download the latest release from the releases page.
  2. Drop the DLL into the your Assets folder
  3. Drop the mc_mesher.cs wrapper file into your Assets folder.

Build

details

Notes

  • 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 target mingw-w64 for 64-bit windows.

Requirements

  1. A working c++17 (or higher) compiler.
  2. CMake version 3.7 or higher

Steps

  1. Run cmake with DCMAKE_BUILD_TYPE=Release to generate the build files
  2. 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.

mc-mesher's People

Contributors

kyy13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mc-mesher's Issues

reduce temp cache size

alternate between cache maps for each z coordinate, in order to avoid huge memory cost for generating a mesh.

unity example update

should probably take a ref to Mesh instead of a MeshFilter for generate functions

mesh generator flags

MCM_VERTEX_NORMALS
MCM_FACE_NORMALS (use face instead of vertex)

MCM_WINDING_RHCS_CCW
MCM_WINDING_RHCS_CW
MCM_WINDING_LHCS_CCW
MCM_WINDING_LHCS_CW

MCM_VERTEX_EDGE_LERP

and a function that takes bytes instead of floats

McmGenerateMesh
McmGenerateMesh_U8

also add segment-intersect-mesh for early out detection

McmMeshIntersectsSegment()
McmMeshIntersectsSegment_U8()
McmMeshIntersectsRay()
McmMeshIntersectsRay_U8()

and contains point method...

McmMeshContainsPoint()
McmMeshContainsPoint_U8()

and cleanup function to clean clean a scalar field of voxel noise that isn't part of the surface. (optimize for compression)

McmCleanEmptyVoxels()
McmCleanEmptyVoxels_U8()

cleanup

exceptions: use throw enum.ToString()

enums: set explicit enum types

update build scripts

has personal paths and artifacts from previous sdl2 project... needs to be cleaned up and probly changed to *.bat

vn optimization

separate meshgen vn function, so that memBoundedOffets don't need to be recalculated in every iteration

edge identifier

mcmGenerateUniqueEdgeID(uniqueVertexID, vertexData)

where uniqueVertexID is calculated incrementally in main loops

ray intersection aabb

ray cast returns no intersection when positioned outside of mesh aabb. it should step ray to edge, then continue ray casting instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.