anyone know how to activate an animation. fbx?
...
Thank you!
Cheers,
Josue
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=37845#37845
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
osg::ref_ptr<osg::Node> root = osgDB::readNodeFile( fbxFile )

struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptr<osgAnimation::BasicAnimationManager> _am;
AnimationManagerFinder() {setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); }
void apply(osg::Node& node) {
if (_am.valid())
return;
if (node.getUpdateCallback()) {
_am = dynamic_cast<osgAnimation::BasicAnimationManager*>(node.getUpdateCallback());
return;
}
traverse(node);
}
};
AnimationManagerFinder finder;
root->accept(finder);
const osgAnimation::AnimationList& animations = finder._am->getAnimationList();
finder._am->playAnimation( animations[an].get() );
...
std::cout << "name animation: " << animations[an]->getName() << std::endl;
finder._am->playAnimation( animations[an].get() );
and where i can see how can i do this:
Finally, you can do what ever you want: play the animation on the osgViewer, get the Duration, the StartTime, the Name of the animation... specify the PlayMode..
PD the fbx load ok
PD2: sorry if my english is not good
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=37887#37887
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=37888#37888
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38077#38077
another custion: the argument of AnimationSplitter is my .fbx or is something else?
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38166#38166
I beleive osgDB/XmlPaser is part of osg 2.9.x and higher, the argument passed to the spliter class is an xml file, but for some reason this forum blocks them. Here is the content of the splitConfig.xml file I use.
<?xml version="1.0" encoding="ISO-8859-15"?>
<OsgAnimationTools sourceFile='./Data/BookModel/bookPage.FBX' destinationFile='./Data/BookModel/bookPage.osgb' fps='30'>
<AnimationSplit sourceAnimation='Take 001'>
<NewAnimation name='IdleClosed' startFrame='0' endFrame='1'/>
<NewAnimation name='AnimateOpen' startFrame='2' endFrame='30'/>
<NewAnimation name='IdleRightOpen' startFrame='31' endFrame='34'/>
<NewAnimation name='RightPageTurn' startFrame='36' endFrame='49'/>
<NewAnimation name='IdleLeftOpen' startFrame='50' endFrame='53'/>
<NewAnimation name='LeftPageTurn' startFrame='55' endFrame='70'/>
<NewAnimation name='AnimateClosed' startFrame='71' endFrame='104'/>
</AnimationSplit>
</OsgAnimationTools>
Hope that helps
Tom
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38173#38173
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38204#38204
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38209#38209
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38260#38260
Attachments:
http://forum.openscenegraph.org//files/animacionfbx_575.cpp
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38264#38264
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38272#38272
#include <osg/Node>
#include <osg/MatrixTransform>
#include <osg/Group>
#include <osg/Timer>
#include <osgGA/TrackBallManipulator>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgViewer/Viewer>
#include <iostream>
#include <osgViewer/ViewerEventHandlers>
#include <osgAnimation/BasicAnimationManager>
using namespace std;
static osg::Timer_t old_tick,new_tick;
int bandera=0;
static double delta;
class tankControll: public osgGA::GUIEventHandler{
public:
tankControll(){
acc=0;
};
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa){
if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='q' || ea.getKey()=='Q')){
bandera=0;
bandera=1;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='w' || ea.getKey()=='W')){
bandera=0;
bandera=2;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='e' || ea.getKey()=='E')){
bandera=0;
bandera=3;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='a' || ea.getKey()=='A')){
bandera=0;
bandera=4;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='s' || ea.getKey()=='S')){
bandera=0;
bandera=5;
return true;
}else if(ea.getEventType()==osgGA::GUIEventAdapter::KEYDOWN && (ea.getKey()=='d' || ea.getKey()=='D')){
bandera=0;
bandera=6;
return true;
}else{
return false;
}
}
private:
int acc;
};
struct AnimationManagerFinder : public osg::NodeVisitor
{
osg::ref_ptr<osgAnimation::BasicAnimationManager> _am;
AnimationManagerFinder() {setTraversalMode(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN); }
void apply(osg::Node& node) {
if (_am.valid())
return;
if (node.getUpdateCallback()) {
_am = dynamic_cast<osgAnimation::BasicAnimationManager*>(node.getUpdateCallback());
return;
}
traverse(node);
}
};
int main()
{
osg::ref_ptr<osg::Node> escena = osgDB::readNodeFile("Lerpz.osgb");
if (!escena){
cout<<"I´m not reading"<<endl;
//exit(0);
}
AnimationManagerFinder finder;
escena->accept(finder);
const osgAnimation::AnimationList& animations = finder._am->getAnimationList();
tankControll *eh=new tankControll();
osgViewer::Viewer visor;
visor.setSceneData(escena);
visor.addEventHandler(eh);
/*if(bandera==1)
finder._am->playAnimation( animations[1].get() );
else if(bandera==2)
finder._am->playAnimation( animations[2].get() );
else if(bandera==3)
finder._am->playAnimation( animations[3].get() );*/
visor.setCameraManipulator(new osgGA::TrackballManipulator);
visor.realize();
while ( !visor.done()){
//while (bandera!=6){
if (bandera==1)
finder._am->playAnimation( animations[1].get() );
else
if (bandera==2)
finder._am->playAnimation( animations[2].get() );
else
if (bandera==3)
finder._am->playAnimation( animations[3].get() );
else
printf("%i",bandera);
visor.frame();
}
return visor.run();
}
the problem is the follow: when i press the w after the q, or e, it seems that animations are one over the other, why it happens?
...
Thank you!
Cheers,
Josue
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38406#38406
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=38444#38444