From a88fa6f7b7c6a108d670ecbbf97346ac401e4c65 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 16 Mar 2015 10:07:13 +0000 Subject: [PATCH] Added --play-mode [ONCE, STAY, LOOP, PPONG] to help with testing. git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14788 16af8721-9629-0410-8352-f15c8da7e697 --- examples/osganimationviewer/AnimtkViewer.cpp | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/examples/osganimationviewer/AnimtkViewer.cpp b/examples/osganimationviewer/AnimtkViewer.cpp index 969eac693..a9a22a121 100644 --- a/examples/osganimationviewer/AnimtkViewer.cpp +++ b/examples/osganimationviewer/AnimtkViewer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -136,10 +137,30 @@ int main(int argc, char** argv) // Set our Singleton's model. AnimationManagerFinder finder; node->accept(finder); - if (finder._am.valid()) { + if (finder._am.valid()) + { + + std::string playModeOpt; + if (arguments.read("--play-mode", playModeOpt)) + { + osgAnimation::Animation::PlayMode playMode = osgAnimation::Animation::LOOP; + if (osgDB::equalCaseInsensitive(playModeOpt, "ONCE")) playMode = osgAnimation::Animation::ONCE; + else if (osgDB::equalCaseInsensitive(playModeOpt, "STAY")) playMode = osgAnimation::Animation::STAY; + else if (osgDB::equalCaseInsensitive(playModeOpt, "LOOP")) playMode = osgAnimation::Animation::LOOP; + else if (osgDB::equalCaseInsensitive(playModeOpt, "PPONG")) playMode = osgAnimation::Animation::PPONG; + + for (osgAnimation::AnimationList::const_iterator animIter = finder._am->getAnimationList().begin(); + animIter != finder._am->getAnimationList().end(); ++animIter) + { + (*animIter)->setPlayMode(playMode); + } + } + node->setUpdateCallback(finder._am.get()); AnimtkViewerModelController::setModel(finder._am.get()); - } else { + } + else + { osg::notify(osg::WARN) << "no osgAnimation::AnimationManagerBase found in the subgraph, no animations available" << std::endl; }