Search code examples
c++algorithmgraphics3dmarching-cubes

C++ Marching Cubes Algorithm Explanation


I am trying to understand how the marching cubes algorithm works.

Source: http://paulbourke.net/geometry/polygonise/

What i don't understand is how do you calculate the "GRIDCELL" values. To be exact the

 double val[8];

part is not clear for me what it actually supposed to contain.

typedef struct {
   XYZ p[8];
   double val[8];
} GRIDCELL;

As i understand XYZ p[8]; are the vertex coordinates for the output cube. But what val[8]; is?


Solution

  • After further reading and research the explanation is quite simple.

    First off all:

    • A voxel represents a value on a regular grid in three-dimensional space.

    This value simply represents the so called "isosurface". Or in other words the density of the space.

    double val[8];
    

    To simplify: Basically this should be a value between -1.0f to 0.0f. Where -1.0f means solid and 0.0f empty space.

    For ISO values a perlin/simplex noise can be used for example.