Hi Gianni, The SmoothingVisititor is really just a fallback for when no normals are provided with a model, the best way to get the precisely the result you want is to provider per vertex normals.
As for memory/GL efficiency, the most efficient way to the geometry to the GPU is to use index primitives via the osg::DrawElements* primitive set, this allows you to share vertex, normal, texture coordinate data etc. Robert. On 23 July 2014 13:59, Gianni Ambrosio <[email protected]> wrote: > 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 >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

