marching cube in opengl

Started by
10 comments, last by luckyyyyyy 16 years, 1 month ago
hi guys... i have a big problem...i spent a lot of time on this topic...but i didn't get the right path... i want to draw triangular marching cube...(a famous marching cube algorithm) but i don't know how...which type of data is used in marching cube algorithm... i know...first of all we need to convert my model into slices...then draw voxels... but how to convert slices...and what type of data should be exported from slices for draw the voxels...means slices should be PNG(image formate) or ASCII data...???? or what kind of data should be exported for march the cube... i have a triangular model and i want to convert that model into voxel model... how can i convert my model into slices..??? i would appreciate you kind help... much thanks in advance...
Advertisement
Hello,

To be honest I'm not really sure what you mean, but when I was experimenting with marching cubes, I got a lot of help here.

kind regards
Uncle
yes...i already read that article and got a good concept...

please only tell me what kind of data is used in that article for marching cube...

is that ASCII data...means (XYZ vertices and indices) or other type...


i found a one file is there name(cell.gz) when i extract this file (9mb file size) exported. what type of that file...there is no extension of that file...

and also brother i couldn't compile this (http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/source/) opengl program...


it needs another files...

please if you have this compilable complete marching cube program...please give me or some references...


UncleRemus, you were working on marching cube...please sir i want to contact you...you can help me...if you have some time...please tell me your Email...




much thanks...
Lucky,

Marching Cubes uses a scalar field to denote the relative density across a 3D space.

Converting a mesh to a scalar field (aka voxel field) is not straight-forward. The most basic way would be to establish a regular grid, then step through it cell by cell. If the cell is "inside" of the mesh, you can mark it as being dense (a scalar value of 1). If the cell is "outside" of the mesh, you can mark it as being sparse (a scalar value of 0). The key thing with Marching Cubes is that the scalar field can have any value within the range of 0 to 1. So when you are converting your mesh to a grid, you will eventually also have to take into consideration that certain cells will be both "inside" and "outside" of the mesh, and that you will have to calculate the percentage that the cell is inside of the mesh, so that you can come up with a value that is appropriately in-between 0 and 1.

The main function of Marching Cubes is then to take this scalar field and convert it to a mesh.

My page has an example program:
http://cpp.criticaldamage.com/index.php/Marching_Cubes_Field_Tesselation

I am also wondering why you would want to take a mesh, convert it to a scalar field, then convert it back to a mesh using Marching Cubes. It seems like a lot of work, where the result is simply a mesh that looks bad compared to the original. The main purpose of Marching Cubes it to convert density data to a mesh, ex: information gained from sonography, tomography, seismology, implicit functions, etc.
much Thanks taby..

yes i can get a lot of concept from your example code...

my problem is this...

I have a triangular surface model data...(triangular vertices + indices)

i imported this data and draw in OpenGL...

now i want to draw that model with marching cube algorithm...

i read your volume text file...but i couldn't understand...from where did you get that file...and what is that data...i just understand header of that data file...(size of grids, resolution, data type etc)..

but what is lower data...from where did you export that data...


Please tell me ...how can i convert my triangular surface model into volume data...

means if i use your example program with my model data...how can i convert my model data as same as your (input.txt)...grid data..


please help me...

Thanks...
Hi Lucky,

The data beyond the header is the density information for the cells. I believe the header says that the grid is 10x10x10, so there should be 1000 density numbers after the header (one per cell). So the first density number should represent cell {0, 0, 0}, the second one should represent cell {0, 0, 1}, and the last one should represent cell {9, 9, 9}.

I exported this density data from a fluid simulation. Basically you are seeing a portion of the top of a cloud.

The first step to converting your model to a scalar field is finding out how to detect whether a point {x, y, z} is "inside" the model, or "outside". I'm not an expert at this, so I recommend that you create a new topic called something like "detecting whether a point is inside/outside a mesh". Once you have figured this out, come back to this thread and we can continue.

thanks you very much sir...

now i am clear...

actually sometime i thought about this kind of thing...and i studied some papers related to detection of points inside or outside of mesh...

i believe, i will do this in some coming days...then again...i will come back...

please sir guide me...otherwise it would be very difficult for me...

thanks a lot...
Sounds good. If you make a reply and I don't respond within a day or two, just send me a private message to remind me. :)
thanks taby...

yes... i will remind you...

i am trying to do your approach...( triangular surface mesh data(IDs, x,y,z) into 3D scalar volume data(density, dimensions, type of data, 0-1 array, etc)

but can you clear me one thing..???

i spent a lot of time for searching this kind of program or paper..in which anybody draw voxel with surface data(ID, x,y,z)...
but i did not find any material about this...

i saw, many author used marching cube for displaying 3D model...i saw a lot of images on the net...my question is this...what kind of data they use in marching cube algorithm...if they use scalar data as you described...from where they get that data...i think they must would have exported from somewhere/from some kind of software/or algorithm as you did in your program file...

like this... below link...
http://aycu19.webshots.com/image/46258/2004591242660400304_rs.jpg

in above link three model you can see...these model drawn with marching cube algorithm...how they draw these model...???from where they did get scalar data...if they use some kind of scanner then which scanner.???..if they produce scalar data themself..then which method they choose for displaying voxels...???
are they use your method as you explained above...detect inside or outside points...or anyother...


here is a one example... if you want draw a tooth model for some kind of simulation, not you anybody...and you have triangular surface data of that tooth, scanned from some kind of 3D scanner...

now you want to convert that model into voxel model(volume model)...

what will you do.??...means in your case...which method you choose for display your model as voxels...

now i think you can fully understand my problem...means we don't want to use any machine for exporting scalar data of tooth model...

in case of MetaBalls...its easy to create scalar field of sphere...many author did this...

but in my case ...i have a triangular surface(face) data of tooth...
please firstly you suggest me which method i need to choose for display surface model into voxel model...which method is suitable for tooth model...every tooth model have millions of vertices...

one is another method in which we convert surface model into slices and then draw into voxel model...

please suggest me...which method is suitable for me...

thanks...

[Edited by - luckyyyyyy on March 10, 2008 7:21:52 AM]
Lucky,

A common source of density data is tomography and imaging:
http://en.wikipedia.org/wiki/Magnetic_resonance_imaging

Rendering volumetric information (density data) is a fairly common topic these days, especially with fluid dynamics becoming so popular. Jos Stam and so many others have written good papers about raytracing semi-opaque materials.

Marching Cubes is used if you want to go one step further and compute the triangulated shell of the density. This can be used for things like collision detection, volume calculation, etc. Most importantly, having a set of triangles allows you to render the object using standard GLSL shaders (or even the fixed-function pipeline if you really must).

If a particular type of scanner generates a triangular mesh by default, then Marching Cubes is no longer necessary.

This topic is closed to new replies.

Advertisement