OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgAnimation with bvh and model


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Thu Aug 15, 2013 11:35 am    Post subject:
osgAnimation with bvh and model
Reply with quote

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<osgAnimation::AnimationManagerBase*>(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
Back to top
View user's profile Send private message
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Fri Aug 16, 2013 7:48 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Fri Aug 16, 2013 12:49 pm    Post subject:
Reply with quote

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<osgAnimation::Bone*>(&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<osgAnimation::BasicAnimationManager> manager = dynamic_cast<osgAnimation::BasicAnimationManager*>(bvh->getUpdateCallback());

   osgAnimation::Animation* anim = manager->getAnimationList()[0];
   anim->setPlayMode( osgAnimation::Animation::LOOP );
   manager->playAnimation( anim );

   return bvh;
}



Thank you!

Cheers,
Peter
Back to top
View user's profile Send private message
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Mon Aug 19, 2013 8:18 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Sebastian Messerschmidt
Guest





PostPosted: Mon Aug 19, 2013 8:50 am    Post subject:
osgAnimation with bvh and model
Reply with quote

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.

<snip>
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<osgAnimation::Bone*>(&node);
if (bone)
bone->addChild(createAxis(5));
traverse(node);
}
};

</snip>

Quote:
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<osgAnimation::AnimationManagerBase*>(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









------------------
Post generated by Mail2Forum
Back to top
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Mon Aug 19, 2013 8:58 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Sebastian Messerschmidt
Guest





PostPosted: Mon Aug 19, 2013 11:09 am    Post subject:
osgAnimation with bvh and model
Reply with quote

Peter,


Quote:
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.
Quote:

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.
Quote:

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
Quote:


Thank you!

Cheers,
Peter

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=55865#55865









------------------
Post generated by Mail2Forum
Back to top
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Mon Aug 19, 2013 11:27 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Sebastian Messerschmidt
Guest





PostPosted: Mon Aug 19, 2013 11:36 am    Post subject:
osgAnimation with bvh and model
Reply with quote

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.

Quote:
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









------------------
Post generated by Mail2Forum
Back to top
Crisium (Peter Wraae Marino)
User


Joined: 30 Dec 2008
Posts: 49

PostPosted: Wed Aug 21, 2013 7:04 am    Post subject:
Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts BVH and model axis centering: a model... Paradox Plugins [osgPlugins] 0 Mon Oct 16, 2017 4:27 pm View latest post
No new posts Best Model For Augmented Reality? Bobykhani General [forum] 3 Sun Oct 15, 2017 6:49 am View latest post
No new posts Osg model assembly jaisingla General 0 Mon Sep 18, 2017 3:36 pm View latest post
No new posts Osg model assembly jaisingla General 0 Mon Sep 18, 2017 3:35 pm View latest post
No new posts Assembly of a model jaisingla General 0 Mon Sep 18, 2017 8:37 am View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP