From e15006b194207ca7b4c91180aaac5e2b05ad98ac Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 20 Nov 2009 10:54:39 +0000 Subject: [PATCH] From Cedric Pinson, "here an update of osgmovie example with the following features: - play and pause now stop and play all streams given in the command line (not only the first) - add key + - to increase decrease the speed of all streams - add key o to display all stream frame rate " --- examples/osgmovie/osgmovie.cpp | 57 ++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/examples/osgmovie/osgmovie.cpp b/examples/osgmovie/osgmovie.cpp index b5d7dc7f8..dae6bb384 100644 --- a/examples/osgmovie/osgmovie.cpp +++ b/examples/osgmovie/osgmovie.cpp @@ -43,7 +43,7 @@ class MovieEventHandler : public osgGA::GUIEventHandler { public: - MovieEventHandler():_playToggle(true),_trackMouse(false) {} + MovieEventHandler():_trackMouse(false) {} void setMouseTracking(bool track) { _trackMouse = track; } bool getMouseTracking() const { return _trackMouse; } @@ -116,7 +116,6 @@ protected: }; - bool _playToggle; bool _trackMouse; ImageStreamList _imageStreamList; @@ -211,17 +210,16 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction itr!=_imageStreamList.end(); ++itr) { - _playToggle = !_playToggle; - if ( _playToggle ) + osg::ImageStream::StreamStatus playToggle = (*itr)->getStatus(); + if (playToggle != osg::ImageStream::PLAYING) { - // playing, so pause - std::cout<<"Play"<play(); } else { // playing, so pause - std::cout<<"Pause"<pause(); } } @@ -233,7 +231,7 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction itr!=_imageStreamList.end(); ++itr) { - std::cout<<"Restart"<rewind(); (*itr)->play(); } @@ -247,17 +245,53 @@ bool MovieEventHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIAction { if ( (*itr)->getLoopingMode() == osg::ImageStream::LOOPING) { - std::cout<<"Toggle Looping Off"<setLoopingMode( osg::ImageStream::NO_LOOPING ); } else { - std::cout<<"Toggle Looping On"<setLoopingMode( osg::ImageStream::LOOPING ); } } return true; } + else if (ea.getKey()=='+') + { + for(ImageStreamList::iterator itr=_imageStreamList.begin(); + itr!=_imageStreamList.end(); + ++itr) + { + double tm = (*itr)->getTimeMultiplier(); + tm += 0.1; + (*itr)->setTimeMultiplier(tm); + std::cout << (*itr).get() << " Increase speed rate "<< (*itr)->getTimeMultiplier() << std::endl; + } + return true; + } + else if (ea.getKey()=='-') + { + for(ImageStreamList::iterator itr=_imageStreamList.begin(); + itr!=_imageStreamList.end(); + ++itr) + { + double tm = (*itr)->getTimeMultiplier(); + tm -= 0.1; + (*itr)->setTimeMultiplier(tm); + std::cout << (*itr).get() << " Decrease speed rate "<< (*itr)->getTimeMultiplier() << std::endl; + } + return true; + } + else if (ea.getKey()=='o') + { + for(ImageStreamList::iterator itr=_imageStreamList.begin(); + itr!=_imageStreamList.end(); + ++itr) + { + std::cout<< (*itr).get() << " Frame rate "<< (*itr)->getFrameRate() <