| 542 | | viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); |
| 543 | | viewer.addEventHandler( new osgViewer::StatsHandler()); |
| 544 | | viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); |
| 545 | | viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); |
| | 564 | // set up camera manipulators |
| | 565 | { |
| | 566 | osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; |
| | 567 | |
| | 568 | keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); |
| | 569 | keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); |
| | 570 | keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); |
| | 571 | keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); |
| | 572 | |
| | 573 | std::string pathfile; |
| | 574 | char keyForAnimationPath = '8'; |
| | 575 | while (arguments.read("-p",pathfile)) |
| | 576 | { |
| | 577 | osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); |
| | 578 | if (apm || !apm->valid()) |
| | 579 | { |
| | 580 | unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); |
| | 581 | keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); |
| | 582 | keyswitchManipulator->selectMatrixManipulator(num); |
| | 583 | ++keyForAnimationPath; |
| | 584 | } |
| | 585 | } |
| | 586 | |
| | 587 | viewer.setCameraManipulator( keyswitchManipulator.get() ); |
| | 588 | } |
| | 589 | |
| | 590 | // set up event handlers |
| | 591 | { |
| | 592 | viewer.addEventHandler( new osgViewer::StatsHandler()); |
| | 593 | viewer.addEventHandler( new osgViewer::WindowSizeHandler() ); |
| | 594 | viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); |
| | 595 | viewer.addEventHandler( new TexturePoolHandler() ); |
| | 596 | } |