Marching Cubes created: May 2000, updated: November 2001 | ||||||
![]() ![]() // create MarchingCubes object and connect fields MarchingCubes *mcubes = new MarchingCubes(); mcubes->ref(); mcubes->data.setValue(dims, data); mcubes->isoValue = 1.0; // MarchingCubes gives the triangles with the // vertices ordered clockwise SoShapeHints *hints = new SoShapeHints(); hints->vertexOrdering. setValue(SoShapeHints::CLOCKWISE); root->addChild(hints); // connect the MarchingCubes points and // normals to an SoVertexProperty node SoVertexProperty *vprop = new SoVertexProperty(); vprop->ref(); vprop->vertex.connectFrom(&mcubes->points); vprop->normal.connectFrom(&mcubes->normals); // connect the indexes from MarchingCubes SoIndexedFaceSet *faceSet = new SoIndexedFaceSet(); faceSet->vertexProperty = vprop; faceSet->coordIndex.connectFrom(&mcubes->indexes); root->addChild(faceSet);Thanks to Gokhan Kisacikoglu, a vertex blending technique was added. The blending is nothing but a simple test to the closest voxel corner based on a percentage from the corner. Below is an example with the blending and without. Also a gif animation showing the blending can be foundhere.
TheMarchingCubesengine was used to create all the images on this page. Below are links to the MarchingCubes source code as well as an example which creates a sphere dataset and displays it with the engine node.(TheSFScalarFieldclass is needed by MarchingCubes.)
|