Another way to do this could be using the bones initial matrix.
The method that I use to charge different animations to the same model is;
first read a model fbx (with the model and skeleton) and then for each
animation read their fbx (with the animated skeleton, without model). So we
will have different fbx for the same animated model: model.fbx, modelAnim1.fbx,
modelAnim2.fbx....
We can take the bone matrix as follows:
Code:
struct OSGBoneFinder : public osg::NodeVisitor
{
std::vector<osg::ref_ptr<osgAnimation::Bone>> _bones;
OSGBoneFinder() :
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {}
void apply(osg::Transform& node) {
osg::ref_ptr<osgAnimation::Bone> bone =
dynamic_cast<osgAnimation::Bone*>(&node);
if (bone.valid()){
_bones.push_back(bone);
}
traverse(node);
}
};
...
std::vector<osg::ref_ptr<osgAnimation::Bone>> bones;
OSGBoneFinder boneFinder;
modelAnimation->accept(boneFinder);
if (boneFinder._bones.size()>0) {
bones.swap(boneFinder._bones);
bones[0]->getMatrixInSkeletonSpace();
}
The problem here is that if I read a fbx file that it has only skeleton
information with the animation them the matrix obteined will always 0. This is
not occur if we read a fbx with skeleton binded model. I do not know if I
explained well... Why is this so?
Thank you!
Cheers,
Aitor
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=46193#46193
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org