Hi Cedric,
I'm using OSG 2.9.6 (61) but with the latest osgAnimation from svn (2.9.8).
I added these lines to osgviewer (just before setting scene data):

AnimationManagerFinder finder;
loadedModel->accept(finder);
if(finder._am.valid())
{
    osg::notify(osg::WARN) << "osgAnimation::AnimationManagerBase found in
the subgraph..." << std::endl;
    loadedModel->setUpdateCallback(finder._am.get());
}
else
{
    osg::notify(osg::WARN) << "no osgAnimation::AnimationManagerBase found
in the subgraph, no animations available" << std::endl;
}

and I defined the visitor like this:

struct AnimationManagerFinder : public osg::NodeVisitor
{
    osg::ref_ptr<osgAnimation::BasicAnimationManager> _am;
    AnimationManagerFinder() :
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}

    void apply(osg::Node& node)
    {
        if (_am.valid())
            return;

        if (node.getUpdateCallback())
        {
            osgAnimation::AnimationManagerBase* b =
dynamic_cast<osgAnimation::AnimationManagerBase*>(node.getUpdateCallback());
            if (b)
            {
                osg::notify(osg::FATAL)<<"found
AnimationManagerBase..."<<std::endl;
                _am = new osgAnimation::BasicAnimationManager(*b);

                int i=0;
                osgAnimation::AnimationList animations =
b->getAnimationList();
                for (osgAnimation::AnimationList::iterator it =
animations.begin(); it != animations.end(); ++it)
                {
                    osg::notify(osg::FATAL)<<"playing animation:
"<<i<<std::endl;
                    (*it)->setPlayMode(osgAnimation::Animation::LOOP);
                    _am->playAnimation(*it);
                    osg::notify(osg::FATAL)<<"animation name:
"<<(*it)->getName()<<std::endl;
                    osg::notify(osg::FATAL)<<"animation duration:
"<<(*it)->getDuration()<<std::endl;

                    i++;
                }

                return;
            }
        }
        traverse(node);
    }
};

And tried with a simple FBX model, but animation do not play.

Thanks.
Alessandro


On Wed, Jun 2, 2010 at 12:06 AM, Cedric Pinson
<[email protected]>wrote:

> Hi Alessandro,
>
> Which version of osg are you using ?
> do you have a small sample code that reproduce the problem ?
>
> Cheers
> Cedric
>
> On Tue, 2010-06-01 at 23:22 +0200, alessandro terenzi wrote:
> > I'm trying to manage animations in my application and I'm looking at
> > the osganimationviewer example to try to understand how to do it. So
> > far I have done something like this:
> >
> > 1) I use a node visitor that looks for an AnimationManagerBase
> > 2) if the visitor manage to find an AnimationManagerBase then I get
> > its AnimationList
> > 4) then I create a new BasicAnimationManager from the
> > AnimationManagerBase
> > 3) and for each animation in AnimationList I call
> > setPlayMode(osgAnimation::Animation::LOOP) and the playAnimation()
> > method for the BasicAnimationManager
> >
> > but animations do not start. Am I missing something?
> >
> > Thanks.
> > Alessandro
> >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> >
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
> --
> Provide OpenGL, WebGL and OpenSceneGraph services
> +33 659 598 614 Cedric Pinson mailto:[email protected]
> http://www.plopbyte.net
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to