Added --speed <ratio> command line parameter to osgviewer to enable control of the speed that animation paths are played back at.

This commit is contained in:
Robert Osfield 2010-12-17 11:19:29 +00:00
parent 634dd421fc
commit 348870d7ba

View File

@ -90,12 +90,16 @@ int main(int argc, char** argv)
keyswitchManipulator->addMatrixManipulator( '7', "Spherical", new osgGA::SphericalManipulator() ); keyswitchManipulator->addMatrixManipulator( '7', "Spherical", new osgGA::SphericalManipulator() );
std::string pathfile; std::string pathfile;
double animationSpeed = 1.0;
while(arguments.read("--speed",animationSpeed) ) {}
char keyForAnimationPath = '8'; char keyForAnimationPath = '8';
while (arguments.read("-p",pathfile)) while (arguments.read("-p",pathfile))
{ {
osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile);
if (apm || !apm->valid()) if (apm || !apm->valid())
{ {
apm->setTimeScale(animationSpeed);
unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); unsigned int num = keyswitchManipulator->getNumMatrixManipulators();
keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm );
keyswitchManipulator->selectMatrixManipulator(num); keyswitchManipulator->selectMatrixManipulator(num);