Hi,
I have tried applying a DelaunayTriangulator on a set of points and generating
the wireframe and the solid model, from the triangles that the
DelaunayTriangulator generates. The wireframe model looks really great, but the
solid one has the same color on all the faces, so I cannot distinguish it as an
3D object. What should I set in order to see the 3D model, not just a big chunk
of the same color?
The code I used looks like this:
Code:
char* fileName = argv[1];
//read the points
osg::Vec3Array* points = new osg::Vec3Array();
unsigned nPoints = ReadFile(fileName,points);
if (nPoints == -1)
return 0;
osg::Geometry* geometry = new osg::Geometry();
// Generate the triangles
osg::ref_ptr<osgUtil::DelaunayTriangulator> triangulation = new
osgUtil::DelaunayTriangulator(points);
triangulation->triangulate();
//set the points and triangles
geometry->setVertexArray(points);
geometry->addPrimitiveSet(triangulation->getTriangles());
//set the color
osg::Vec4Array * colors = new osg::Vec4Array(1);
colors->push_back(osg::Vec4d(0.0,1.0,0.0,1.0));
geometry->setColorArray(colors);
geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
//create geode and add the geometry
osg::Geode* geode = new osg::Geode();
geode->addDrawable(geometry);
//create StateSet and add it to the geode
osg::StateSet *set = new osg::StateSet();
set->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
set->setMode(GL_LIGHTING, osg::StateAttribute::ON);
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
set->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
geode->setStateSet(set);
//view the result
osgViewer::Viewer viewer;
viewer.setSceneData(geode);
viewer.setUpViewInWindow(100, 100, 800, 600);
viewer.run();
Thank you!
Cheers,
Nadia
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=14462#14462
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org