diff --git a/src/osgGA/StateSetManipulator.cpp b/src/osgGA/StateSetManipulator.cpp index 50b3f0edf..34afd6b14 100644 --- a/src/osgGA/StateSetManipulator.cpp +++ b/src/osgGA/StateSetManipulator.cpp @@ -1,5 +1,7 @@ #include +#include + 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(_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)