Re: [osg-users] triangulation

2009-06-26 Thread Nadia Comanici
Hi,

Besides adding the triangles, as a primitive set, you also have to set the 
vertex array dor the geometry, like this:


Code:
triangleGeometry-setVertexArray(points);



This should make it visible, but the surface will look flat, as the 
triangulation does not generate normals for the triangles; you could use the 
SmoothingVisitor to do this, so your code should look like this:


Code:
osg::Geometry* triangleGeometry = new osg::Geometry();
triangleGeometry-addPrimitiveSet(d);
triangleGeometry-setVertexArray(points);

osg::Geode* geode=new osg::Geode();
geode-addDrawable(triangleGeometry);

osgUtil::SmoothingVisitor sv;
geode-accept(sv); 



Cheers,
Nadia

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=14578#14578





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] triangulation

2009-02-12 Thread hemanth korrapati
Hi,

I am trying to triangulate some points. But when I try to render it i
am not getting any results.
Moreover I am able to get a valid size from the  totalDataSize function.
The code i am using is as follows:


int main(void)
{
osg::Group* root=new osg::Group();

osg::Vec3Array* points=new osg::Vec3Array();

std::ifstream datafile(data,std::ios::in);

double tempX,tempY,tempZ;
while(datafile  tempX  tempY  tempZ)
{
points-push_back(osg::Vec3d(tempX,tempY,tempZ));
}
std::cout  Reading data completed  std::endl;

osgUtil::DelaunayTriangulator* t=new osgUtil::DelaunayTriangulator();

t-setInputPointArray(points);
if(t-triangulate())
cout  Success  endl;

osg::DrawElementsUInt *d;

d=t-getTriangles();

cout  d-getTotalDataSize()endl;
cout  d-className()   endl;

osg::Geometry* triangleGeometry = new osg::Geometry();
triangleGeometry-addPrimitiveSet(d);
osg::Geode* geode=new osg::Geode();
geode-addDrawable(triangleGeometry);

root-addChild(geode);

osgViewer::Viewer viewer;

viewer.setUpViewAcrossAllScreens();

viewer.setSceneData(root);
viewer.run();

}


thank you
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org