Show
Ignore:
Timestamp:
12/16/08 21:29:00 (5 years ago)
Author:
robert
Message:

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).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osganimationtimeline/osganimationtimeline.cpp

    r9151 r9370  
    3030#include <osgAnimation/Timeline> 
    3131#include <osgAnimation/AnimationManagerBase> 
     32#include <osgAnimation/TimelineAnimationManager> 
    3233 
    3334 
     
    5556    osg::ref_ptr<osgAnimation::StripAnimation> _scratchHead; 
    5657    osg::ref_ptr<osgAnimation::StripAnimation> _scratchNose; 
    57     osg::ref_ptr<osgAnimation::AnimationManagerTimeline> _manager; 
     58    osg::ref_ptr<osgAnimation::TimelineAnimationManager> _manager; 
    5859 
    5960    bool _releaseKey; 
    6061 
    61     ExampleTimelineUsage(osgAnimation::AnimationManagerTimeline* manager) 
     62    ExampleTimelineUsage(osgAnimation::TimelineAnimationManager* manager) 
    6263    { 
    6364        _releaseKey = false; 
    6465        _manager = manager; 
    6566 
    66         osgAnimation::AnimationMap map = _manager->getAnimationMap(); 
     67        const osgAnimation::AnimationList& list = _manager->getAnimationList(); 
     68        osgAnimation::AnimationMap map; 
     69        for (osgAnimation::AnimationList::const_iterator it = list.begin(); it != list.end(); it++) 
     70            map[(*it)->getName()] = *it; 
     71 
    6772        _mainLoop = new osgAnimation::StripAnimation(map["Idle_Main"].get(),0.0,0.0); 
    6873        _mainLoop->setLoop(0); // means forever 
     
    158163 
    159164    osgViewer::Viewer viewer(psr); 
    160     osg::ref_ptr<osg::Group> group = new osg::Group(); 
    161165 
    162166    std::string file = "osgAnimation/nathan.osg"; 
     
    165169 
    166170    // replace the manager 
    167     osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(osgDB::readNodeFile(file)); 
     171    osg::Group* root = dynamic_cast<osg::Group*>(osgDB::readNodeFile(file)); 
     172    osgAnimation::AnimationManagerBase* animationManager = dynamic_cast<osgAnimation::AnimationManagerBase*>(root->getUpdateCallback()); 
    168173    if(!animationManager)  
    169174    { 
    170         std::cerr << "Couldn't convert the file's toplevel object into an AnimationManager." << std::endl; 
     175        std::cerr << "Did not found AnimationManagerBase updateCallback needed to animate elements" << std::endl; 
    171176        return 1; 
    172177    } 
    173178 
    174     osg::ref_ptr<osgAnimation::AnimationManagerTimeline> tl = new osgAnimation::AnimationManagerTimeline(*animationManager); 
    175  
    176     animationManager->removeChildren(0, animationManager->getNumChildren()); 
     179    osg::ref_ptr<osgAnimation::TimelineAnimationManager> tl = new osgAnimation::TimelineAnimationManager(*animationManager); 
     180    root->setUpdateCallback(tl); 
    177181    ExampleTimelineUsage* callback = new ExampleTimelineUsage(tl.get()); 
    178     group->addChild(tl.get()); 
    179     group->setEventCallback(callback); 
    180     group->setUpdateCallback(callback); 
     182    root->setEventCallback(callback); 
     183    root->getUpdateCallback()->addNestedCallback(callback); 
     184         
    181185 
    182186 
     
    202206    viewer.addEventHandler(new osgViewer::ScreenCaptureHandler); 
    203207 
    204     viewer.setSceneData(group.get()); 
     208    viewer.setSceneData(root); 
    205209 
    206210    return viewer.run();