I am trying to draw a rubber band wioth the mouse around a selection
I get the mouse position, convert into world coords (assumign a plan view) then
add the new point to the geometry.
I then call osg::Util Tessellator to build the selection into a polygon.
This works, but only for the first 4 points! After that I can continue to draw
a line but not a filled polygon?
Code:
createPolygon() {
_geode = new osg::Geode;
_geometry=new osg::Geometry;
_geometry->setVertexArray(_vertices);
// set colour ...
// set normal ...
_vertices->push_back(point);
_geometry->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,1));
_geometry->addPrimitiveSet(new
osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,1));
_geode->addDrawable(_geometry);
_root->addChild(_geode);
}
updatePolygon(){
// update point counts
((osg::DrawArrays*)_geometry->getPrimitiveSet(0))->setCount(_vertices->size());
((osg::DrawArrays*)_geometry->getPrimitiveSet(1))->setCount(_vertices->size());
// update polygon - assuming >2 points!
osgUtil::Tessellator* tessellator = new osgUtil::Tessellator;
tessellator->setBoundaryOnly(true);
tessellator->setTessellationType(osgUtil::Tessellator::TESS_TYPE_POLYGONS);
tessellator->setWindingType( osgUtil::Tessellator::TESS_WINDING_POSITIVE);
// don't know
tessellator->setTessellationNormal(osg::Z_AXIS);
tessellator->retessellatePolygons(*_geometry);
}
Martin
--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=22020#22020
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org