ofxMarchingCubes

Hi,
made an addon implementing the marching cubes algorithm.
its based on this paper by Paul Bourke http://local.wasp.uwa.edu.au/~pbourke/g-…-olygonise/

theres an example here: http://vimeo.com/7823987
and the addon can be downloaded here: ruicode.googlecode.com

cheers

Rui

niiiice. metaballs here I come.

great, thanks for posting rui.

WOw this is unreal - nice work. I saw this example, how would you implement this kind of input with your addon.

Say have a cloud of points and then create a shape from that. Are you just dragging and adding a point then creating a shape. ?

no, marching cubes does not work like that (or lets say iso surfaces in general) You rather have to think of it as an energy field, so if you want to visualize your points for instance as metaballs you also need a density value for each one of the points. But you are not limited to metaballs. for instance you could just feed noise values to the cubeGrid and visualize 3D perln noise or whatever you feel like. Or voxelclouds which display a model for example.

I have no idea how ruis addon handles the input though :slight_smile:

Rui,
Would you mind explain how you did the previous video:
http://vimeo.com/3873744

or maybe posting and example, im interested.

T

Hi Vanderlin

refering to the first post you made, you dont pass a point cloud, the marching cubes will generate all the triangles for you.
the way it works is something like this,
you have a grid of cubes (think rubik’s cube), for each vertice of the cubes you set an iso value and then you set a global threshold value for your entire mesh. The algorithm will analise all cubes and if all vertices of a cube are below the threshold then that cube is completely inside the shape and no triangle is generated, if all vertices are above the threshld then the cube is completely outside the mesh and no triangle is generated. if some of the vertices are above the threshold and some are below then it will generate a triangle interpolated according to the iso values of the cube’s vertices. (hope that makes sense…)
so to create shapes you have to set the iso values of each cubes vertices and then set a threshold value. its not intuitive at all! if anyone has ideas how to make this more user friendly i’d love to hear.

for example to create a metaball you set the vertice’s values according to the distance of a point in space (or several points and just add all the values).

that example where i’m drawing with the mouse was done in processing some time ago. I wanted to make a marching cubes library for processing which i never released because Toxi’s Volumetric Utils library is so much better hehe
i’ll post that processing code in ruisource.googlecode.com and when i get some time ill rewrite it in OF as well.

cheers

Rui

updated this addon,
cleaned the syntax a little (made some typedef’s on some really ugly 3dimensional stl::vector arrays) and added support to export STL models (dependent on ofxSTL)
the new version is here: http://code.google.com/p/ruicode/downloads/list

cheers

Rui

hi Rui,

im starting to look into doing some 3d printing and think your ofxMarchingCubes + ofxSTL is the perfect combo for the job - really great work man!

i was having a little problem with loading and saving of STL files which ended up being a issue with setting the correct path, ofToDataPath() fixes it.

if anyone else is having the same problem, just change the path = ofToDataPath(fileName, true) in the following methods.

  
  
void ofxSTLBinaryWriter :: writeFile(string fileName, const vector<ofxSTLFacet>& facets);  
void ofxSTLASCIIWriter :: writeFile(string fileName, const vector<ofxSTLFacet>& facets);  
ofxSTLImporter :: loadSTL(string path);  
  

Hi Rui,

I just updated this addon to work with the current OF (i.e. eliminated the need for ofx3dUtils, used ofBox, etc) and cleaned up the example a bit (using OF helpers instead of gl ones, added an Xcode project file, etc.). I put it on Github (with all due credit to you of course):

https://github.com/atduskgreg/ofxMarchingCubes

I’m happy to contribute this pack to your google code repo if you’d prefer or to help maintain it on GH. I’m going to work on a simpler (i.e. non-metaball example) now as well.

Thanks for this great code!