Hi All,
I need to draw a surface. Looking at OSG examples I implemented it this way:
Code:
osg::Geometry* geometry = getGeometry();
osg::Vec3Array* vertices = new osg::Vec3Array;
GraphicVectorPtr graphicVector = road->graphicVector();
size_t count = graphicVector->count();
size_t addedPoints = 0;
vertices->reserve(count * 3);
for (size_t i = 0; i<count; ++i) {
const GraphicItem& item = (*graphicVector)[i];
if (item.points.size() == 9) {
vertices->push_back(osg::Vec3(item.points[0], item.points[1],
item.points[2]));
vertices->push_back(osg::Vec3(item.points[3], item.points[4],
item.points[5]));
vertices->push_back(osg::Vec3(item.points[6], item.points[7],
item.points[8]));
addedPoints+=3;
}
}
geometry->setVertexArray(vertices);
geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES,
0, addedPoints));
Now, first of all I would like to know if this is correct. I mean I want to
draw triangles and I don't want to waste memory.
The problem is that I see a basically flat surface. I tried then with a
SmoothingVisitor on the geometry and the flat surface problem is solved. So I
guess it was related to normals not set, right?
Now, since I don't like so much how the surface is rendered with the
SmoothingVisitor, is there a way of render the surface as it is drawn?
Regards,
Gianni
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60407#60407
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org