From Cedric Pinson and Jeremey Moles, Changes to OpenSceneGraph-osgWidget-dev branch.
Notes from Robert Osfield, Merged changes to OpenSceneGraph-osgWidget-dev r9367 (prior to my botched attempt at merged svn/trunk into the branch).
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <osgAnimation/Skinning>
|
||||
#include <osgAnimation/Timeline>
|
||||
#include <osgAnimation/AnimationManagerBase>
|
||||
#include <osgAnimation/TimelineAnimationManager>
|
||||
|
||||
|
||||
struct NoseBegin : public osgAnimation::Action::Callback
|
||||
@@ -54,16 +55,20 @@ struct ExampleTimelineUsage : public osgGA::GUIEventHandler
|
||||
osg::ref_ptr<osgAnimation::StripAnimation> _mainLoop;
|
||||
osg::ref_ptr<osgAnimation::StripAnimation> _scratchHead;
|
||||
osg::ref_ptr<osgAnimation::StripAnimation> _scratchNose;
|
||||
osg::ref_ptr<osgAnimation::AnimationManagerTimeline> _manager;
|
||||
osg::ref_ptr<osgAnimation::TimelineAnimationManager> _manager;
|
||||
|
||||
bool _releaseKey;
|
||||
|
||||
ExampleTimelineUsage(osgAnimation::AnimationManagerTimeline* manager)
|
||||
ExampleTimelineUsage(osgAnimation::TimelineAnimationManager* manager)
|
||||
{
|
||||
_releaseKey = false;
|
||||
_manager = manager;
|
||||
|
||||
osgAnimation::AnimationMap map = _manager->getAnimationMap();
|
||||
const osgAnimation::AnimationList& list = _manager->getAnimationList();
|
||||
osgAnimation::AnimationMap map;
|
||||
for (osgAnimation::AnimationList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
map[(*it)->getName()] = *it;
|
||||
|
||||
_mainLoop = new osgAnimation::StripAnimation(map["Idle_Main"].get(),0.0,0.0);
|
||||
_mainLoop->setLoop(0); // means forever
|
||||
|
||||
@@ -157,27 +162,26 @@ int main (int argc, char* argv[])
|
||||
osg::ArgumentParser psr(&argc, argv);
|
||||
|
||||
osgViewer::Viewer viewer(psr);
|
||||
osg::ref_ptr<osg::Group> group = new osg::Group();
|
||||
|
||||
std::string file = "osgAnimation/nathan.osg";
|
||||
if(argc >= 2)
|
||||
file = psr[1];
|
||||
|
||||
// replace the manager
|
||||
osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(osgDB::readNodeFile(file));
|
||||
osg::Group* root = dynamic_cast<osg::Group*>(osgDB::readNodeFile(file));
|
||||
osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(root->getUpdateCallback());
|
||||
if(!animationManager)
|
||||
{
|
||||
std::cerr << "Couldn't convert the file's toplevel object into an AnimationManager." << std::endl;
|
||||
std::cerr << "Did not found AnimationManagerBase updateCallback needed to animate elements" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osgAnimation::AnimationManagerTimeline> tl = new osgAnimation::AnimationManagerTimeline(*animationManager);
|
||||
|
||||
animationManager->removeChildren(0, animationManager->getNumChildren());
|
||||
osg::ref_ptr<osgAnimation::TimelineAnimationManager> tl = new osgAnimation::TimelineAnimationManager(*animationManager);
|
||||
root->setUpdateCallback(tl);
|
||||
ExampleTimelineUsage* callback = new ExampleTimelineUsage(tl.get());
|
||||
group->addChild(tl.get());
|
||||
group->setEventCallback(callback);
|
||||
group->setUpdateCallback(callback);
|
||||
root->setEventCallback(callback);
|
||||
root->getUpdateCallback()->addNestedCallback(callback);
|
||||
|
||||
|
||||
|
||||
// add the state manipulator
|
||||
@@ -201,7 +205,7 @@ int main (int argc, char* argv[])
|
||||
// add the screen capture handler
|
||||
viewer.addEventHandler(new osgViewer::ScreenCaptureHandler);
|
||||
|
||||
viewer.setSceneData(group.get());
|
||||
viewer.setSceneData(root);
|
||||
|
||||
return viewer.run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user