Sign in to follow this  
MaartenDeNef

Marching cube algorithm problem

Recommended Posts

MaartenDeNef    1368
Hi,

I'm trying to make a voxel terrain with Marching cube.
I have read some info about this. But i still can't figure out what they mean with this.

[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 this post


Link to post
Share on other sites
SapphireStorm    140
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 this post


Link to post
Share on other sites
MaartenDeNef    1368
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 this post


Link to post
Share on other sites
Adam_42    3629
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.

Share this post


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

I'm trying to make a voxel terrain with Marching cube.
I have read some info about this. But i still can't figure out what they mean with this.

[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 this post


Link to post
Share on other sites
CodeReaver    131
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this