| | 249 | { |
| | 250 | osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; |
| | 251 | |
| | 252 | keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); |
| | 253 | keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); |
| | 254 | keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); |
| | 255 | |
| | 256 | unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); |
| | 257 | keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); |
| | 258 | |
| | 259 | std::string pathfile; |
| | 260 | char keyForAnimationPath = '5'; |
| | 261 | while (arguments.read("-p",pathfile)) |
| | 262 | { |
| | 263 | osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); |
| | 264 | if (apm || !apm->valid()) |
| | 265 | { |
| | 266 | num = keyswitchManipulator->getNumMatrixManipulators(); |
| | 267 | keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); |
| | 268 | ++keyForAnimationPath; |
| | 269 | } |
| | 270 | } |
| | 271 | |
| | 272 | keyswitchManipulator->selectMatrixManipulator(num); |
| | 273 | |
| | 274 | viewer.setCameraManipulator( keyswitchManipulator.get() ); |
| | 275 | } |
| | 276 | |