Marching Cubes

I had a stab at Marching Cubes implementation over the weekend.

Basically, in the past I implemented simplex-based surface construction but never really touched marching cubes because of that huge polygon table they require.

Here’s the question, though…

Textbook implementation of the algorithm says that the foundation of the algorithm is 15 basic cubes which are then rotated. This is on wikipedia.

What I found is that the actual number of base cubes is smaller

And the rest are derived from rotation, combination and inversion of them. Basically as long as cubes do not have “adjacent” features (meaning there’s no element in cube A that shares an edge with an element on cube B), they can be combined into one.

The number of base figures is 8. “cube0”, “cube1”, “cube3”, “cube15”, “cube23”, “cube27” and “cube29”. The last two actually are mirror version of the same shape and cannot be created through rotation.

Has anyone come across this piece of information? I do not recall encountering a mention of combining the base cube codes and their geometries.

I believe the reason you usually do not take into account rotation and mirroring is that for an efficient implementation you need a super fast look-up table for those. You don’t wanna compute them at runtime etc.

The table has to be built first, and that is done through rotation of basic elements. Because you aren’t going to polygonize all 256 variants by hand. ANd that’s what I was talking about.

The screenshots demonstrate visualized generated table for all possible states. The code builds the table, using basic elements.