diff --git a/examples/osganalysis/osganalysis.cpp b/examples/osganalysis/osganalysis.cpp index cd5548b03..0d2f9898e 100644 --- a/examples/osganalysis/osganalysis.cpp +++ b/examples/osganalysis/osganalysis.cpp @@ -25,6 +25,12 @@ #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -531,6 +537,22 @@ public: osg::ref_ptr _incrementalCompileOperation; }; +class TexturePoolHandler : public osgGA::GUIEventHandler +{ +public: + virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) + { + if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP) + { + if (ea.getKey()=='r') + { + osg::Texture::getTextureObjectManager(0)->reportStats(); + } + } + return false; + } +}; + int main(int argc, char** argv) { @@ -539,10 +561,39 @@ int main(int argc, char** argv) // construct the viewer. osgViewer::Viewer viewer(arguments); - viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); - viewer.addEventHandler( new osgViewer::StatsHandler()); - viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); - viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); + // set up camera manipulators + { + osg::ref_ptr 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() ); + keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); + + std::string pathfile; + char keyForAnimationPath = '8'; + while (arguments.read("-p",pathfile)) + { + osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); + if (apm || !apm->valid()) + { + unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); + keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); + keyswitchManipulator->selectMatrixManipulator(num); + ++keyForAnimationPath; + } + } + + viewer.setCameraManipulator( keyswitchManipulator.get() ); + } + + // set up event handlers + { + viewer.addEventHandler( new osgViewer::StatsHandler()); + viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); + viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); + viewer.addEventHandler( new TexturePoolHandler() ); + } ///////////////////////////////////////////////////////////////////////////////// //