Thanks for the replies!

I found a bug in my code ...

Code:

void AnimatedModel::update()
{
        for(int i = 0; i<m_bones.size();i++)
        {               
                if(!_firstUpdate){
                        pBoneUpdate.at(i)->getStackedTransforms().pop_back();
                }

                if(!m_bones.at(i)->getName().compare("Waist")){
                        pBoneUpdate.at(i)->getStackedTransforms().push_back(new 
osgAnimation::StackedTranslateElement(
                                "trans",modelTranslate));
                }
                pBoneUpdate.at(i)->getStackedTransforms().push_back(new 
osgAnimation::StackedQuaternionElement(
                        "rotate",boneMatrices[i]->getMatrix().getRotate()));
debugAxesMatrices.at(i)->setMatrix(m_bones.at(i)->getMatrixInSkeletonSpace());
        }
        _firstUpdate = false;
}



Not all pBoneUpdate.at (i) -> getStackedTransforms have the same size ... must 
delete the former because otherwise the transformations add up.

On the other hand I still missing something, movements of both arms are 
reversed each other... What about this part of the code?

Code:

//c# code
Vector3 s;
Quaternion r;
Vector3 t;
if (!worldTransform.Decompose(out s, out r, out t))
return;

var currentPos = positionResolver(currentJointID);
var nextPos = positionResolver(nextJointID);

var shoulderToElbowDir = Vector3.Normalize(nextPos - currentPos);
var angle = (float)Math.Acos(Vector3.Dot(Vector3.Right, shoulderToElbowDir));
var axis = Vector3.Normalize(Vector3.Cross(Vector3.Right, shoulderToElbowDir));

worldTransform = Matrix.CreateScale(s) * Matrix.CreateFromAxisAngle(axis, 
angle) * Matrix.CreateTranslation(t);

worldBindPoseCopy[bone] = worldTransform;
outputSkin[bone] = inverseBindPose[bone] * worldBindPoseCopy[bone];



I tried to multiply inverseBindPose by my matrix, but I deform the whole model.

I have another question ... if I have a model with bones Orieta differently, 
this does not serve me, right? (the same code for diferent oriented bones 
models).

Thank you!

Cheers,
Aitor

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to