I have a person model that is animated and a suitcase model that is not. The person can pick up the suitcase and it should move to the location of the hand bone of the person model. Unfortunately the suitcase doesn't follow the animation correctly. it moves with the hand's animation but its position is under the ground and way too far to the right. I haven't scaled any of the models myself. Thank you. The source code (forgive the rough prototype code):

        Matrix[] tran = new Matrix[man.model.Bones.Count];// The absolute transforms from the animation player

        Vector3 suitcasePos, suitcaseScale, tempSuitcasePos = new Vector3();// Place holders for the Matrix Decompose
        Quaternion suitcaseRot = new Quaternion();

        // The transformation of the right hand bone is decomposed
        tran[man.model.Bones["HPF_RightHand"].Index].Decompose(out suitcaseScale, out suitcaseRot, out tempSuitcasePos);

        suitcasePos = new Vector3();
        suitcasePos.X = tempSuitcasePos.Z;// The axes are inverted for some reason
        suitcasePos.Y = -tempSuitcasePos.Y;
        suitcasePos.Z = -tempSuitcasePos.X;

        suitcase.Position = man.Position + suitcasePos;// The actual Suitcase properties
        suitcase.Rotation = man.Rotation + new Vector3(suitcaseRot.X, suitcaseRot.Y, suitcaseRot.Z);

I am also copying the bone transforms from the animation player in the Person class like so:

        // The transformations from the AnimationPlayer
        Matrix[] skinTrans = new Matrix[model.Bones.Count];
        skinTrans = player.GetBoneTransforms();

        // copy each transformation to its corresponding bone
        for (int i = 0; i < skinTrans.Length; i++)
            model.Bones[i].Transform = skinTrans[i];


Unfortunately I can't add screenshots, as this specific project has been lost to time. I still want to know why it didn't work, though.

  • \$\begingroup\$ I still haven't been able to make this work... D: :'( \$\endgroup\$ Dec 23 '11 at 0:34
  • \$\begingroup\$ I've added a 100-rep bounty for your question. Please dispense it wisely. And please add a screenshot. \$\endgroup\$
    – ashes999
    Feb 29 '12 at 3:03

My initial guess was that CopyAbsoluteBoneTransforms gave you the bone's position in world coordinates instead of model coordinates, but that would only be true if you moved the model by modifying the transform of the root bone. (Not entirely sure how animation is done in XNA)

Something else to note is that you're taking the XYZ components of a quaternion and using them in a vector3 (that I'm assuming is a euler angle), which doesn't work as you would expect.

  • \$\begingroup\$ My guess is also the Quaternion usage, X Y Z W are not normal coordinates, try this for converting a Quaternion to a Matrix4x4 and then to a Vector3 (Unity code but idea should be similar) answers.unity3d.com/questions/11363/… \$\endgroup\$
    – Roy T.
    Feb 29 '12 at 11:10
  • \$\begingroup\$ So this solved the problem? @annonymously \$\endgroup\$
    – ashes999
    Mar 4 '12 at 4:16
  • \$\begingroup\$ @ashes999 I stored the rotation in a Quaternion wherever I used a Vector3 and it worked. \$\endgroup\$ Mar 4 '12 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .