From edaed5996ac00b8f2727716f01a8d7f57e721694 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 12 Mar 2003 13:54:59 +0000 Subject: [PATCH] Added 'w' toggle to StateSetManipulator to toggle between filled, line and point polygon drawing modes. --- src/osgGA/StateSetManipulator.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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)