Hi Community,
i have create a polygon by a lot of points by using DelaunayTriangulator, and 
now i want to add a limit to make the polygon's outer boundary is a concave 
boundary.
    here is the test code .but it make no scene. how should i add the limit to 
make a concave polygon by using DelaunayTriangulator?

Code:

osg::ref_ptr<osg::Node> createDelu()
{
    osg::ref_ptr<osg::Geode> geode = new osg::Geode;
    osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
    osg::ref_ptr<osg::Vec3Array> vec = new osg::Vec3Array;
    vec->push_back(osg::Vec3(10, 0, 0));
    vec->push_back(osg::Vec3(10, 10, 0));
    vec->push_back(osg::Vec3(-10, 10, 0));
    vec->push_back(osg::Vec3(-10, -10, 0));
    vec->push_back(osg::Vec3(0, -3, 0));
    vec->push_back(osg::Vec3(-10, 8, 0));
    vec->push_back(osg::Vec3(-10, -5, 0));
    vec->push_back(osg::Vec3(5, 5, 0));
    vec->push_back(osg::Vec3(10, -10, 0));
    osg::ref_ptr<osgUtil::DelaunayTriangulator> dt = new 
osgUtil::DelaunayTriangulator;
    
    osg::ref_ptr<osgUtil::DelaunayConstraint> dc=new 
osgUtil::DelaunayConstraint;
    osg::ref_ptr<osg::Vec3Array> vec1 = new osg::Vec3Array;
    vec1->push_back(osg::Vec3(10, 0, 0));
    vec1->push_back(osg::Vec3(10, 10, 0));
    vec1->push_back(osg::Vec3(-10, 10, 0));
    vec1->push_back(osg::Vec3(-10, -10, 0));
    vec1->push_back(osg::Vec3(0, -3, 0));
    vec1->push_back(osg::Vec3(10, -10, 0));
    dc->setVertexArray(vec1);
    dc->addPrimitiveSet(new 
osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP,0,vec1->size()) );
//     osg::ref_ptr<osgUtil::Tessellator> tes = new osgUtil::Tessellator();
//     tes->setBoundaryOnly(false);
//     tes->setWindingType(osgUtil::Tessellator::TESS_WINDING_NONZERO);
//     tes->setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY);
//     tes->retessellatePolygons(*dc);

    dt->addInputConstraint(dc.get());
    dt->setInputPointArray(vec);
    dt->triangulate();
    geom->setVertexArray(vec);
    geom->addPrimitiveSet(dt->getTriangles());
    geode->addDrawable(geom);

    return geode;
}




Thank you!

Cheers,
cai

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to