| 169 | | std::string pathfile; |
| 170 | | while (arguments.read("-p",pathfile)) |
| 171 | | { |
| 172 | | osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile); |
| 173 | | if (apm->valid()) viewer.setCameraManipulator(apm.get()); |
| 174 | | } |
| 175 | | |
| 176 | | if (!viewer.getCameraManipulator()) viewer.setCameraManipulator( new osgGA::TrackballManipulator() ); |
| | 176 | // set up the camera manipulators. |
| | 177 | { |
| | 178 | osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; |
| | 179 | |
| | 180 | keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); |
| | 181 | keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); |
| | 182 | keyswitchManipulator->addMatrixManipulator( '3', "Drive", new osgGA::DriveManipulator() ); |
| | 183 | keyswitchManipulator->addMatrixManipulator( '4', "Terrain", new osgGA::TerrainManipulator() ); |
| | 184 | |
| | 185 | std::string pathfile; |
| | 186 | char keyForAnimationPath = '5'; |
| | 187 | while (arguments.read("-p",pathfile)) |
| | 188 | { |
| | 189 | osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); |
| | 190 | if (apm || !apm->valid()) |
| | 191 | { |
| | 192 | unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); |
| | 193 | keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); |
| | 194 | keyswitchManipulator->selectMatrixManipulator(num); |
| | 195 | ++keyForAnimationPath; |
| | 196 | } |
| | 197 | } |
| | 198 | |
| | 199 | viewer.setCameraManipulator( keyswitchManipulator.get() ); |
| | 200 | } |
| | 201 | |
| | 202 | // add stats |
| | 203 | viewer.addEventHandler( new osgViewer::StatsHandler() ); |