HI Radu, I wouldn't recommend using the SmoothingVisitor as it is written to handle conventional surfaces, tetrahedral meshes are very much a special case.
With modern GPU's there are alternatives to just doing a brute force approach of generating all the triangles and normals, so if you can target modern hardware that supports features like geometry shaders then it would probably be best to look at custom solution just for this case. I haven't tried it before but if I were to tackle a tetrahedral mesh right now I'd create an osg::Geometry with all the vertices you require without duplicates and then use osg::DrawElementsUShort/UInt to provide the primitives that reference these vertices. You would then need the four corners of the tetrahedra as input to the geometry shader and have it generate the 4 triangles required and the colours for each face by computing the normals of the triangles and then applying the lighting model. To get four vertices into geometry shader you'd probably need to use LINE_STRIP_ADJACENCY primitive type in osg::DrawElementsUShort/UInt. An example of geometry shaders in action can be seen in one of the code paths in osgforest example - here it converters a line segment representing the trunk into a quad. Robert. On 9 June 2014 21:40, Radu Marin Butoi <[email protected]> wrote: > Hello everyone, > > I am loading and displaying a tetrahedral mesh consisting of a list of > verticies and a list of tetrahedrons denoted by four indices of vertices. I > load these into a triangles primitive set as four triangles, one for each of > the faces of the tetra. > My first question is, is this method of representing a mesh inefficient? > There are two GL_TRIANGLEs for each of the interior triangles. The > performance seems to be fine. I have looked into libraries like VCG and > OpenMesh, but chose not to use them as I will need to only display and > select from the mesh, and no manipulation is needed. Also, I could not > figure out how to represent a VCG or OpenMesh mesh in a osg::Geometry. > One way to view the mesh in my application is as a solid. My second question > is how can I prevent this sort of effect from occurring (see attached, or > http://i.imgur.com/1t4xWy9.png)? I use a SmoothingVisitor to set normals > (and shading mode is set to flat), and since they are set per vertex the > normals do not point directly outwards. I've read around the mailing list > and it seems using BIND_PER_PRIMITIVE normal binding is deprecated and slow. > It was also mentioned to duplicate vertex entries and set different normals > like that, but I don't see how this would work on a mesh that is being > imported and built on the fly. > > Thank you, > Radu > > _______________________________________________ > 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

