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?
After further reading and research the explanation is quite simple.
First off all:
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.