Added 'w' toggle to StateSetManipulator to toggle between filled, line and

point polygon drawing modes.
This commit is contained in:
Robert Osfield
2003-03-12 13:54:59 +00:00
parent 6021ffecac
commit edaed5996a

View File

@@ -1,5 +1,7 @@
#include <osgGA/StateSetManipulator>
#include <osg/PolygonMode>
using namespace osg;
using namespace osgGA;
@@ -62,6 +64,24 @@ bool StateSetManipulator::handle(const GUIEventAdapter& ea,GUIActionAdapter& aa)
return true;
break;
case 'w' :
{
osg::PolygonMode* polyModeObj = dynamic_cast<osg::PolygonMode*>(_drawState->getAttribute(osg::StateAttribute::POLYGONMODE));
if (!polyModeObj)
{
polyModeObj = new osg::PolygonMode;
_drawState->setAttribute(polyModeObj);
}
// cycle through the available modes.
switch(polyModeObj->getMode(osg::PolygonMode::FRONT_AND_BACK))
{
case osg::PolygonMode::FILL : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); break;
case osg::PolygonMode::LINE : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT); break;
case osg::PolygonMode::POINT : polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::FILL); break;
}
}
break;
}
}
return false;
@@ -72,6 +92,7 @@ void StateSetManipulator::getUsage(osg::ApplicationUsage& usage) const
usage.addKeyboardMouseBinding("b","Toggle backface culling");
usage.addKeyboardMouseBinding("l","Toggle lighting");
usage.addKeyboardMouseBinding("t","Toggle texturing");
usage.addKeyboardMouseBinding("w","Toggle polygon fill mode between fill, line (wire frame) and points");
}
void StateSetManipulator::accept(GUIEventHandlerVisitor& gehv)