Marching cube algorithm problem

Recommended Posts

Hi,

I'm trying to make a voxel terrain with Marching cube.

[code]
class GridCell{
public:
float val[8];
Vector3f pos[8];
};[/code]

Whats the value of val[8] what does it mean where does it come from.

I'm using info from.
[url="http://paulbourke.net/geometry/polygonise/"]http://paulbourke.net/geometry/polygonise/[/url]
Hope someone can help me out :-).

Share on other sites
val[8] are the isovalues of your surface at the eight vertices in a grid cube.

I'm not familiar with voxel terrain, however, in 3D animation and medical imaging your isovalues come from Metaball/Blobby algorithms and CT/MRI machines respectively. In other words, there's a computational step / algorithm you compute prior to marching cubes which generates a nice block of 3D data for you. This data becomes your isovalues in your grid of cubes. Then, you pick a target isovalue, run marching cubes against that target value, and it will generate a surface corresponding to that value from your data block.

Share on other sites
Ty very much for the reply :-).

But i still dont get this. What are the values for val and how do i calculate them. To use them in this function.

[code]D3DXVECTOR3 VoxelTerrain::VertexInterp(float isolevel, D3DXVECTOR3 p1, D3DXVECTOR3 p2, float valp1, float valp2) {
float mu;
D3DXVECTOR3 p;

mu = (isolevel - valp1) / (valp2 - valp1);
p = p1 + (p2 - p1) * mu;

return(p);
}[/code]

ty

Share on other sites
nvm got it working. The problem was that i was working with bools thanks for the help

Share on other sites
Hidden
val contains the input data to the algorithm. Try evaluating a function like [url="http://en.wikipedia.org/wiki/Metaballs"]a metaball one[/url] at each point in a 3D grid and using that data.

[quote name='Sneezy' timestamp='1307558830' post='4821017']
Hi,

I'm trying to make a voxel terrain with Marching cube.

[code]
class GridCell{
public:
float val[8];
Vector3f pos[8];
};[/code]

Whats the value of val[8] what does it mean where does it come from.

I'm using info from.
[url="http://paulbourke.net/geometry/polygonise/"]http://paulbourke.ne...try/polygonise/[/url]
Hope someone can help me out :-).
[/quote]

The isovalue is what the value should stand for and I believe the Algorithm details (second paragraph) later on in the page describe what they are trying do in the example

Share on other sites
Hi,

I'm trying to do the same sort of thing, but I'm getting a bit confused by the terminology. What exactly is an isovalue?

I currently have a cloud of points and a bounding box containing them. I intend to divide the bounding box into equal sized cubes, loop through the lot of them, eliminate the ones that don't contain any points and use the rest as input for the Polygonise function. Unfortunately, that only gives me input for XYZ p[8] in the GridCell and I don't know where to get the rest of the input.

EDIT: I should probably explain that I'm attempting to get an approximation of a convex hull that surrounds the cloud of points. I realise I won't get a perfect convex hull, but my goal is to get as close as I can. I'm hoping to get something like the nearest point on a grid to where the convex hull would be. Something that would be acceptable as a collision mesh. Edited by CodeReaver

Share on other sites
EDIT: The edit button showed up, but now I can't delete. Edited by CodeReaver

Create an account

Register a new account

• Forum Statistics

• Total Topics
628342
• Total Posts
2982177

• 9
• 24
• 9
• 9
• 13