[osg-users] Toggling between wireframe modes
Charlie Tan
chen.qunhan at gmail.com
Wed Nov 7 01:41:44 PST 2018
Hi,
I just began using OSG for one of my projects. Basically one of the tasks is to enable/disable wireframe mode. I have tried to follow the osgkeyboardmouse example and tried to implement a different version(where you don't have to click on the model, but push a keyboard key) to toggle between the modes.
To do this, I use 2 functions, enterWireFrame() and exitWireFrame() to toggle between the wireframe modes:
void enterWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer* viewer)
{
osg::Node* scene = viewer->getSceneData();
osg::Group* parent = scene->getParent(0);
osg::Node* node = parent->getChild(0);
auto scribe = new osgFX::Scribe();
scribe->addChild(node);
parent->replaceChild(node, scribe);
}
void exitWireFrame(const osgGA::GUIEventAdapter& ea, osgViewer::Viewer* viewer)
{
osg::Node* scene = viewer->getSceneData();
osg::Group* parent = scene->getParent(0);
osg::Node* node = (dynamic_cast<osg::Group*>(scene))->getChild(0);
parent->replaceChild(parent, node);
}
I then ran enterWireFrame() followed by exitWireFrame(). I am able to render the wireframe after the 1st function, but the 2nd function does not do anything at all.
I am totally new to OSG and would very much appreciate if someone could point me in the right direction where my mistake lies (probably in the 2nd function, but I can't figure it out).
Thank you!
Cheers,
Charlie
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75172#75172
More information about the osg-users
mailing list