Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - nikola

#1
Bones / Manually rotate joints using quaternion input
October 20, 2013, 10:15:35 PM
Hello! I am participating in a small project aiming to create Motion capturing system. I must create some kind of visual representation of the collected data.

For input I have quaternions representing the rotation of different body parts. I took a look at ProceduralAnimationSample and modified ( deleted what I didn't understand :) ) targetJoint function. It now looks like this:


private void targetJoint(SkeletonPose pose, int jointIndex, float x, float y,
    float z, float w) {
   
        final int parentIndex = pose.getSkeleton().getJoint(jointIndex).getParentIndex();

        // neckBindGlobalTransform is the neck bone -> model space transform. essentially, it is the world transform of
        // the neck bone in bind pose.
        final Matrix jointInverseBindPose = pose.getSkeleton().getJoint(jointIndex).getInverseBindPose();
        final Matrix jointBindPose = jointInverseBindPose.invert();

        Quaternion quat = new Quaternion(x,y,z,w);

        final Matrix subGlobal = quat.getRotationMatrix();
       
        // now remove the global/world transform of the neck's parent bone, leaving us with just the local transform of
        // neck + rotation.
        subGlobal.matMul(jointBindPose);
        subGlobal.matMul(pose.getSkeleton().getJoint(parentIndex).getInverseBindPose();

        // set that as the neck's transform !!
        pose.getLocal(jointIndex).setTo(subGlobal);
    }


I set left and right foreams of Seymor model with sample quaternion and expected them to point at same direction. But the angles were mirrored which I think has something to do with the joints unrotated orientation. I really don't get how these things work and I am missing the bigger picture. So please help me to make the joints point the same direction when I rotate them with one and the same quaternion. I really spent more than 10 hours and couldn't figure it out. As you can see English is not my native language and not a skilled Java person or mathematician ( just hardware guy ). Thank you :)