# ofxMarchingCubes

Hi,
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

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

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

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)

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);