[osg-users] Implementing own manipulator
Vinicius Nonnenmacher
vnonnenmacher at gmail.com
Wed Oct 3 18:55:09 PDT 2018
Hi,
The trackball manipulator is almost what I need for my application. I would like to handle some keyboard inputs to move the camera.
I am trying to derive TrackballManipulator and override the handle() method. Looking at the structure of 'camera manipulators', it seems to me that this is the right way to just handle keyboard inputs.
But somehow the handle method of my manipulator is not being called. just never.
Am I in the right direction?
Code:
class CityManipulator : public osgGA::TrackballManipulator
{
public:
CityManipulator(int flags = DEFAULT_SETTINGS)
:osgGA::TrackballManipulator(){}
CityManipulator( const CityManipulator& tm,
const osg::CopyOp& copyOp = osg::CopyOp::SHALLOW_COPY )
:osgGA::TrackballManipulator( tm, copyOp ){}
META_Object( osgGA, CityManipulator )
protected:
bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
{
std::cout << "handling" << std::endl;
bool handled(false);
switch(ea.getEventType())
{
case(osgGA::GUIEventAdapter::KEYDOWN):
{
switch(ea.getKey())
{
case 'w':
std::cout << "pressing w" << std::endl;
return false;
break;
default:
return false;
}
}
default:
return false;
}
return TrackballManipulator::handle(ea, us);
}
};
//////
CityManipulator * tm = new CityManipulator();
tm->setNode(m_rootNode);
tm_viewer->setCameraManipulator(tm);
...
Thank you!
Cheers,
Vinicius
Code:
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75032#75032
More information about the osg-users
mailing list