Ok... I found the error... I'm not reseting the position and rotation parameters when change the bone into the for. so this is the final code:
Code: osgAnimation::ChannelList channelList = anim->getChannels(); float rotateX, rotateY, rotateZ; rotateX = rotateY = rotateZ = 0.0; osg::Vec3 pos(0.0,0.0,0.0), scale(1.0,1.0,1.0); std::map<std::string, Transforms> localMatrixMap; for(unsigned channelIndex=0;channelIndex<channelList.size();channelIndex++) { osgAnimation::Channel* channel = channelList[channelIndex]->clone(); //channel->getTargetName() channel->update(time,1.0,1.0); //if new bone init values if(localMatrixMap.find(channel->getTargetName()) == localMatrixMap.end()) { localMatrixMap[channel->getTargetName()].pos.set(0.0,0.0,0.0); localMatrixMap[channel->getTargetName()].rotateX = localMatrixMap[channel->getTargetName()].rotateY = localMatrixMap[channel->getTargetName()].rotateZ = 0.0; localMatrixMap[channel->getTargetName()].scale.set(1.0,1.0,1.0); } if(!channel->getName().compare("translate")){ osg::ref_ptr<osgAnimation::Vec3Target> posTarget = dynamic_cast<osgAnimation::Vec3Target*>(channel->getTarget()); localMatrixMap[channel->getTargetName()].pos = posTarget->getValue(); } else if(!channel->getName().compare("rotateX")){ osg::ref_ptr<osgAnimation::FloatTarget> xTarget = dynamic_cast<osgAnimation::FloatTarget*>(channel->getTarget()); localMatrixMap[channel->getTargetName()].rotateX = xTarget->getValue(); } else if(!channel->getName().compare("rotateY")){ osg::ref_ptr<osgAnimation::FloatTarget> yTarget = dynamic_cast<osgAnimation::FloatTarget*>(channel->getTarget()); localMatrixMap[channel->getTargetName()].rotateY = yTarget->getValue(); } else if(!channel->getName().compare("rotateZ")){ osg::ref_ptr<osgAnimation::FloatTarget> zTarget = dynamic_cast<osgAnimation::FloatTarget*>(channel->getTarget()); localMatrixMap[channel->getTargetName()].rotateZ = zTarget->getValue(); } else if(!channel->getName().compare("scale")){ osg::ref_ptr<osgAnimation::Vec3Target> scaleTarget = dynamic_cast<osgAnimation::Vec3Target*>(channel->getTarget()); localMatrixMap[channel->getTargetName()].scale = scaleTarget->getValue(); } } for(std::map<std::string, Transforms>::iterator it = localMatrixMap.begin(); it != localMatrixMap.end(); it++) { osg::Quat rot(it->second.rotateX,osg::Vec3(1,0,0), it->second.rotateY,osg::Vec3(0,1,0), it->second.rotateZ,osg::Vec3(0,0,1)); Bone* bone = _skeleton->getBone(it->first); osg::Matrix local = bone->getMatrixInBoneSpace(); osg::Matrix parentInvBindMat = bone->getBoneParent()->getInvBindMatrixInSkeletonSpace(); osg::Matrix glovalBindMat = osg::Matrix::inverse(bone->getInvBindMatrixInSkeletonSpace()); osg::Matrix localBindMat = glovalBindMat * parentInvBindMat; osg::Matrix finalLocalMat = localBindMat; if(it->second.pos!=osg::Vec3(0.0,0.0,0.0)) finalLocalMat.setTrans(it->second.pos); if(!rot.zeroRotation()) finalLocalMat.setRotate(rot); if(it->second.scale!=osg::Vec3(1.0,1.0,1.0)) finalLocalMat.scale(it->second.scale); osg::Matrix finalGlobalMat = finalLocalMat * bone->getBoneParent()->getMatrixInSkeletonSpace(); _skeleton->updateBone(it->first, finalGlobalMat ); } Thank you! Cheers, Aitor ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55245#55245 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org