Hi Preet,

I recently submitted a modification to Tesselator that allows to do that.

You have to modify the underlying gluTesselator Callbacks to use 
GLU_TESS_EDGE_FLAG
Here is an example.

void CALLBACK noStripCallback(GLboolean userData)
{
}

#include <osg/GLU>
class CustomTessellator : public osgUtil::Tessellator
{
public:
  virtual void beginTessellation()
  {
    reset();

    if (!_tobj) _tobj = osg::gluNewTess();
 
    osg::gluTessCallback(_tobj, GLU_TESS_VERTEX_DATA, 
(osg::GLU_TESS_CALLBACK) osgUtil::Tessellator::vertexCallback);
    osg::gluTessCallback(_tobj, GLU_TESS_BEGIN_DATA, 
(osg::GLU_TESS_CALLBACK) osgUtil::Tessellator::beginCallback);
    osg::gluTessCallback(_tobj, GLU_TESS_END_DATA, 
(osg::GLU_TESS_CALLBACK) osgUtil::Tessellator::endCallback);
    osg::gluTessCallback(_tobj, 
GLU_TESS_COMBINE_DATA,(osg::GLU_TESS_CALLBACK) 
osgUtil::Tessellator::combineCallback);
    osg::gluTessCallback(_tobj, GLU_TESS_ERROR_DATA, 
(osg::GLU_TESS_CALLBACK) osgUtil::Tessellator::errorCallback);
    //Here is the New TESS Callback :
    //Force to only creates triangles
    osg::gluTessCallback(_tobj, GLU_TESS_EDGE_FLAG, 
(osg::GLU_TESS_CALLBACK) noStripCallback);
    if (tessNormal.length()>0.0) osg::gluTessNormal(_tobj, tessNormal.x(), 
tessNormal.y(), tessNormal.z());
    osg::gluTessBeginPolygon(_tobj,this); 
  }

};

        Luc



De :
Preet <[email protected]>
A :
OpenSceneGraph Users <[email protected]>
Date:
22/07/2012 07:14
Objet :
[osg-users] Example using osgUtil::Tessellator to only get back 
GL_TRIANGLE primitives?
Envoyé par :
[email protected]



Is there anyway to use osgUtil::Tessellator to only get back
GL_TRIANGLE primitives? With the available examples, the tessellator
adds/changes the primitive sets of the osg::Geometry passed to it into
multiple triangle fans, triangle strips, and triangles. I want my
geometry to just consist of GL_TRIANGLE draw calls.

Also, there's another method of using the tessellator where it looks
like you manually define contours / add vertices, etc, but I can't
figure out how to use it. Could anyone provide a small example, or
maybe point out what I'm doing wrong:

    osgUtil::Tessellator myTess;
    myTess.setTessellationNormal(offsetVec);
    myTess.beginTessellation();
    myTess.beginContour();
    for(int i=0; i < areaVx->size(); i++)   {
        osg::Vec3 * someVertexPtr = &someVertex;
        myTess.addVertex(someVertexPtr);
    }
    myTess.endContour();
    myTess.endTessellation();

    std::cout << "Num Contours " << myTess.getContours().size();    //
gives me a zero
_______________________________________________
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

Reply via email to