Marching Cubes - Cal Poly CSC 471
by Erik Toraason
What is it?
This is a marching cube project that I did for my CPE 471 graphics class. In it I take the implicit equation of a surface and apply the equation to a grid of cubes. Based on the position of each edge on each cube you can decide if it lies inside or outside of the surface. Basically an isovalue is computed so that anything less than 0 would be inside the surface and anything above 0 would be outside the surface. Based on these isovalues, if the values of all eight corners are not the same than obviously the surface cut through the cube. From here, a meash of triangles is made to represent the surface of intersection. Putting all these triangles together gives a representation of the implicit surface. I added flat shading which involves computing the normals per face. Also, I have a cube mode which allows the user to see aech of the cubes drawn without any slices made into the cube. I have a light source that has a couple of materials and a virtual trackball to rotate the object. There are 4 possible implicit equations that are included and each one can be shown as filled or wireframe.
  • References

The tables I used as well as many of the ideas and some of the code in the algorithm are from Paul Bourke who is an accredited programmer, whose work on marching cubes can be found all over online. http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
Instructions
The instructions are quite simple. They are:
  • "w" to switch between wireframe and filled
  • "m" to switch between regular cube mode and marching cube mode
  • "c" to switch materials
  • "l" to toggle the light
  • "r" to turn on the trackball
  • "q" to quit
Screenshots
Demos
Executable in zip: marching_cubes.zip