Mesh simplification for Marching Cubes algorithm?

In the picture you can see the blue wireframe of marching cubes, I drew in the red lines, they represent what I want to accomplish.

Essentially I want to reduce the number of triangles used to accomplish the flat surfaces of the marching cubes algorithm.

Here is another picture to show the shear mad number of triangle that make up a couple flat surface’s.

That’s interesting… makes me wanna implement marching cubes…

The problem with unity meshes is that they are not easily traversable as they are built for speed and don’t have stuff like references to neighboring tris etc. which would help, but maybe you can build some helper classes that allow you to do this and also mark tris etc.

Now… what you would do is start at a triangle and recursively(doesn’t have to be implemented that way of course) visit all neighbors with the same (float precision!) normal and gather them all in a group - also mark them, so they wont get visited on the next iteration when you start from an yet unused triangle.

So… we’re having a group of triangles, all connected and complanar. Start with a triangle somewhere and create a bigger and bigger polygon(pink line) by removing the edge to the next neighbor. Here you may need to watch out that you don’t break into triangles you already used.

You won’t have holes very often like in the example, but if you do, the internal edge connecting the outside with the holes can look very ugly, but some simple rules like always traversing open neighboring triangles ordered by x,y,z will prevent the worst.

After that, traverse all the edges of the new polygon and remove all collinear verts we don’t need (blue line). And retriangulate (orange)

Take a look at “greedy mesh” algorithms, and especially take a look (heh, 52 pages and counting!) at this thread:

After playing Minecraft…