Isovalue in Marching Cubes Algorithm

I was reading the article here: http://paulbourke.net/geometry/polygonise/.

Currently, I have a minecraft like terrain generated using simplex noise which I divided into 16x16 chunks that has a 32x32x128 blocks. Now, I want to use the noise I generated to the Polygonise function in marching cubes. But my problem is how can I compute the isovalue? I don't get it.

Anyone here knows a much more spoonfeed article. lol

EDIT:

Hey I found this on http://paulbourke.net/geometry/polygonise/marchingsource.cpp.

sSourcePoint[] has a value of 0.5, so it just center the object but what does the fResult += 0.5/(fDx*fDx + fDy*fDy + fDz*fDz) does? Omg, I'm intimidated with the codes.

GLfloat fSample1(GLfloat fX, GLfloat fY, GLfloat fZ)
{
        GLdouble fResult = 0.0;
        GLdouble fDx, fDy, fDz;
        fDx = fX - sSourcePoint[0].fX;
        fDy = fY - sSourcePoint[0].fY;
        fDz = fZ - sSourcePoint[0].fZ;
        fResult += 0.5/(fDx*fDx + fDy*fDy + fDz*fDz);

        fDx = fX - sSourcePoint[1].fX;
        fDy = fY - sSourcePoint[1].fY;
        fDz = fZ - sSourcePoint[1].fZ;
        fResult += 1.0/(fDx*fDx + fDy*fDy + fDz*fDz);

        fDx = fX - sSourcePoint[2].fX;
        fDy = fY - sSourcePoint[2].fY;
        fDz = fZ - sSourcePoint[2].fZ;
        fResult += 1.5/(fDx*fDx + fDy*fDy + fDz*fDz);

        return fResult;
}

Well, Paul's source is really "spoonfed". The comment before fSample1 says:

//fSample1 finds the distance of (fX, fY, fZ) from three moving points

Basically, he is creating a so called "metaballs" object, thus he needs to "blend" three distance functions (distances from fSourcePoint[i]) into one. To do so he takes the

Isovalue = 1/f[0] + 1/f[1] + 1/f[2]

where

f[i] = 1/DistFromCenterToSourcePoint[i].

The effect is simple - when you are far from each three points, the isovalue is almost zero. The closer to the point - the lesser the f[i] and the greater your isovalue.

The distance is a usual squared euclidean distance

dist(p1, p2) = sqrt( (p1.x - p2.x)^2 + (p1.y - p2.y)^2 + (p1.z - p2.z)^2)

To achieve "Minecraft-like" isosurfaces you need to use some other metric. Take a look at taxicab (aka Manhattan) metric:

dist1(p1, p2) = abs(p1.x - p2.x) + abs(p1.y - p2.y) + abs(p1.z - p2.z)

or the max-metric

distMax(p1, p2) = max( abs(p1.x - p2.x), abs(p1.y - p2.y), abs(p1.z - p2.z) )

The "spheres" in these metrics (ie, the sets satisfying the sphere's equation "dist = R") are cubes.

Invert them, calculate the sum (do it all in the fSample1 function), choose some typical isovalue with experiments and see the result.

链接地址: http://www.djcxy.com/p/37238.html

上一篇: DirectX / C ++:Marching Cubes Indexing

下一篇: Marching Cubes算法中的等值