|
发表于 2010-7-10 22:45:57
|
显示全部楼层
如此切换即可:
- // 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() );
- keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() );
- std::string pathfile;
- char keyForAnimationPath = '5';
- 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() );
- }
复制代码 |
|