Re: [osg-users] [forum] osgAnimation with bvh and model
Hi, I got a little further with the bvh problem. I know have a valid bvh file from daz3d... it appears that daz3d needs to bake the keys into it's timeline before exporting. I can now successfully load the bvh file with the option "solids" and see the animation working. So, now I'm stuck on the part that should animate the model. No animation going on here. This is my basic procedure: 1. I load the bvh, let's call that nodeBvh 2. I load the model, let's cal lthat nodeModel 3. I location the osgAnimation::Animation in the nodeBvh, let's call that nodeAnim 4. I create a new BasicAnimationManager (let's call that bamCallback) and register nodeAnim and call buildTargetReferrence 5. I create a group and this group gets a setUpdateCallback with bamCallback 6. I add the model to the group note the model contains skeleton and riggeometry. so am I missing a point? Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55917#55917 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Am 19.08.2013 13:28, schrieb Peter Wraae Marino: Peter, long story short: It will not simply work without some renaming. Most exporters and the osg-importers simply don't agree on the same scheme here. That is exactly why one should traverse the models and match the names. (I had to match them based on the groups and geometries for .fbx). I guess they are simply not playing, because the matcher traverses the wrong skeleton. Hi Sebastian, The bvh file should be able to play without having to rename anything. there is no name matching in there. if you supply the option "solids" when loading they you will see a stick figure of the bones. so why the bvh files doesn't animate is what I'm looking into now... Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55867#55867 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi Sebastian, The bvh file should be able to play without having to rename anything. there is no name matching in there. if you supply the option "solids" when loading they you will see a stick figure of the bones. so why the bvh files doesn't animate is what I'm looking into now... Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55867#55867 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Peter, Hi Sebastian Messerschmidt, Thanks for your info. it is correct that the model containing the geometry does not have the animation,.. this is as designed. the bvh file contains the animation but no geometry also as designed. I don't want geometry and animation in the same files, because I will have 100's of bvh files that all use one character geometry. What I want is the ability to play what I want and blend what I want. This is exactly my approach, as I want to keep them separate. back to the subject at hand... I found out that the bvh file I have does not work well with openscenegraph, this file was exported from Daz3D. I exported a bvh file from 3dsmax and I got the animation to work (somewhat). Okay, check as I advised. All animations ran fine, but the linkage to the model were incorrect. That's why I had to write some technique to couple them again. apparently there are many variations of the bvh files and openscenegraph only supports a subset of these. How I'm going to fix this is a good question... but at least now I know where the problem is. Maybe the community can help if you provide such "incompatible" bhv. cheers Sebastian Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55865#55865 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi Sebastian Messerschmidt, Thanks for your info. it is correct that the model containing the geometry does not have the animation,.. this is as designed. the bvh file contains the animation but no geometry also as designed. I don't want geometry and animation in the same files, because I will have 100's of bvh files that all use one character geometry. What I want is the ability to play what I want and blend what I want. back to the subject at hand... I found out that the bvh file I have does not work well with openscenegraph, this file was exported from Daz3D. I exported a bvh file from 3dsmax and I got the animation to work (somewhat). apparently there are many variations of the bvh files and openscenegraph only supports a subset of these. How I'm going to fix this is a good question... but at least now I know where the problem is. Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55865#55865 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi Peter, Since your questions were a bit confusion: I had problems loading skeleton models with geometry and playing some different animation on them as well. In order to get this working (as skeletons and animations were not matching) I had to build a set of visitors which would match the animation to the skeleton an vice versa. My first advice is to display the skeleton bones (and potentiall the bones of the "animation") Here's some snippet that might be helpful (It's from the osganimationviewer). Apply it to your loaded models and play found animations. In my case I saw that the skeleton is animated, but not the one containing the geometry. I can send you a complete example of what I've done, but I'm not sure if it solves your problem. Send me a personal message (email) so we maybe could test your data sets with my algorithm. osg::Geode* createAxis(float scale) { osg::Geode* geode= new osg::Geode(); osg::Geometry* geometry = new osg::Geometry(); osg::Vec3Array* vertices = new osg::Vec3Array(); osg::Vec4Array* colors = new osg::Vec4Array(); vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f)); vertices->push_back(osg::Vec3(scale, 0.0f, 0.0f)); vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f)); vertices->push_back(osg::Vec3(0.0f, scale, 0.0f)); vertices->push_back(osg::Vec3(0.0f, 0.0f, 0.0f)); vertices->push_back(osg::Vec3(0.0f, 0.0f, scale)); colors->push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); colors->push_back(osg::Vec4(1.0f, 0.0f, 0.0f, 1.0f)); colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)); colors->push_back(osg::Vec4(0.0f, 1.0f, 0.0f, 1.0f)); colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); colors->push_back(osg::Vec4(0.0f, 0.0f, 1.0f, 1.0f)); geometry->setVertexArray(vertices); geometry->setColorArray(colors); geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX); geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, 6)); geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, false); geode->addDrawable(geometry); return geode; } struct AddHelperBone : public osg::NodeVisitor { AddHelperBone() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply(osg::Transform& node) { osgAnimation::Bone* bone = dynamic_cast(&node); if (bone) bone->addChild(createAxis(5)); traverse(node); } }; Hi, I'm trying to animate a character with data from a bvh I have tried a lot of different setups.. but none work. The osgAnimation seems to have what it needs to get this working, but there isn't enough documentation to make sense of it. This is where I am at now: Code: osg::Node* createScene() { // convenience variables osg::Node* bvh = osgDB::readNodeFile( osgDB::findDataFile( "test.bvh" ) ); osg::Node* model = osgDB::readNodeFile( osgDB::findDataFile( "test.dae" ) ); osgAnimation::BasicAnimationManager* manager = new osgAnimation::BasicAnimationManager; // get animation from bvh osgAnimation::AnimationManagerBase* animationManager = dynamic_cast(bvh->getUpdateCallback()); osgAnimation::Animation* anim = animationManager->getAnimationList()[0]; anim->setPlayMode( osgAnimation::Animation::LOOP ); osg::Group* group = new osg::Group; group->setUpdateCallback( manager ); group->addChild( model ); manager->registerAnimation(anim); manager->buildTargetReference(); manager->playAnimation( anim ); return group; } The BVH contains Skeleton and Bones The Model contains Skeleton, Bones, RigGeometry so,.. what I basically do is create my own BasicAnimationManager extract the animation from bvh and register it. I can see the character clearly being render, but with no animation. Am I missing something? Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55853#55853 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi, I'm not giving up on this (but I'm sure am tired of failing). I can see that that the bvh reader actually plays the animation and I can add the option "solids" to the loader... this basically should show the bvh file animating which it doesn't: Code: osg::Node* createScene() { osgDB::ReaderWriter::Options* o = new osgDB::ReaderWriter::Options; o->setOptionString( "solids" ); osg::Node* bvh = osgDB::readNodeFile( osgDB::findDataFile( "test.bvh" ), o ); return bvh; } Something is just not right here... the poor documentation makes this even harder to figure out? I'm starting to think that the bvh reader is the problem. Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55860#55860 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi, still need help: I have tried to look only at the bvh file now, you can see the data here: http://osghelp.com/wp-content/uploads/2013/08/testbvh.osg here is the code that adds a little sphere to each bone, but again when I run this no animation. anybody!?!? Code: class CAddDummyObject : public osg::NodeVisitor { public: CAddDummyObject() : osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} void apply( osg::Node& node ) { osgAnimation::Bone* bone = dynamic_cast(&node); if ( bone ) { osg::Sphere* shape = new osg::Sphere( osg::Vec3(0, 0, 0), 1.0f ); osg::ShapeDrawable* d = new osg::ShapeDrawable( shape ); osg::Geode* geodeSphere = new osg::Geode; geodeSphere->addDrawable(d); bone->addChild( geodeSphere ); } traverse(node); } }; osg::Node* createScene() { osg::Node* bvh = osgDB::readNodeFile( osgDB::findDataFile( "test.bvh" ) ); bvh->accept( *new CAddDummyObject ); osg::ref_ptr manager = dynamic_cast(bvh->getUpdateCallback()); osgAnimation::Animation* anim = manager->getAnimationList()[0]; anim->setPlayMode( osgAnimation::Animation::LOOP ); manager->playAnimation( anim ); return bvh; } Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55856#55856 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] osgAnimation with bvh and model
Hi, I'm still having problems with this.. I have saved the group node to a file here: http://osghelp.com/wp-content/uploads/2013/08/mymodel.osg perhaps somebody can see why it doesn't animate. I'm a little lost here. Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55854#55854 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [forum] osgAnimation with bvh and model
Hi, I'm trying to animate a character with data from a bvh I have tried a lot of different setups.. but none work. The osgAnimation seems to have what it needs to get this working, but there isn't enough documentation to make sense of it. This is where I am at now: Code: osg::Node* createScene() { // convenience variables osg::Node* bvh = osgDB::readNodeFile( osgDB::findDataFile( "test.bvh" ) ); osg::Node* model = osgDB::readNodeFile( osgDB::findDataFile( "test.dae" ) ); osgAnimation::BasicAnimationManager* manager = new osgAnimation::BasicAnimationManager; // get animation from bvh osgAnimation::AnimationManagerBase* animationManager = dynamic_cast(bvh->getUpdateCallback()); osgAnimation::Animation* anim = animationManager->getAnimationList()[0]; anim->setPlayMode( osgAnimation::Animation::LOOP ); osg::Group* group = new osg::Group; group->setUpdateCallback( manager ); group->addChild( model ); manager->registerAnimation(anim); manager->buildTargetReference(); manager->playAnimation( anim ); return group; } The BVH contains Skeleton and Bones The Model contains Skeleton, Bones, RigGeometry so,.. what I basically do is create my own BasicAnimationManager extract the animation from bvh and register it. I can see the character clearly being render, but with no animation. Am I missing something? Thank you! Cheers, Peter -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55853#55853 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org