Hi All,

I have now added support for the multiple (trackball, flight and
drive) camera manipulators and the StateSet manipulator to the
osgViewer path of osgviewer.  The achieve the later I had to fill out
a bit more functionality in osgViewer, which should make for an all
round library.

The drive and flight manipulators don't like the way that timing of
events are coming in though, so are behaving quite sporadically.
Unfortunately I have found a way of finding out what absolute time the
X11 event timestamps relate to so there is only an approximate method
used to tie the time of events relative to the osg::Timer generated
time used for frame stamps.  It is likely a simple tweak to the drive
and flight manipulators should allow them to work better.

Follows are the code additions required to add the extra functionality
to the base osgViewer::Viewer:

int main_osgViewer(osg::ArgumentParser& arguments)
{
   osgViewer::Viewer viewer;

   // set up the camera manipulators.
   {
       osg::ref_ptr<osgGA::KeySwitchMatrixManipulator>
keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;

       keyswitchManipulator->addMatrixManipulator( '1', "Trackball",
new osgGA::TrackballManipulator() );
       keyswitchManipulator->addMatrixManipulator( '2', "Flight", new
osgGA::FlightManipulator() );
       keyswitchManipulator->addMatrixManipulator( '3', "Drive", new
osgGA::DriveManipulator() );

       viewer.setCameraManipulator( keyswitchManipulator.get() );
   }

   // add the state manipulator
   {
       osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator =
new osgGA::StateSetManipulator;
       
statesetManipulator->setStateSet(viewer.getCamera()->getOrCreateStateSet());

       viewer.addEventHandler( statesetManipulator.get() );
   }

   viewer.setSceneData( osgDB::readNodeFiles(arguments) );

   return viewer.run();
}


Next elements of functionality such as stats, screen snapshots, file
saving will require custom EventHandlers so will be more work, and
require more code... especially stats as this will require
modifications to the core OSG for better stats reporting, this is a
big topic though something for a different thread.

Robert.
_______________________________________________
osg-users mailing list
osg-users@openscenegraph.net
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to