Hope someone can help me here.
I seem to have a hard time trying to simulate the rag doll with my DX model. Here's a screen shot.
Before I update all the frame matrices, that is, combining the parent to child relationship to a combined matrix for rendering, I do this:
Code: Select all
// declare a few variables
D3DXQUATERNION quat;
float yaw, pitch, roll;
// extract transformation from rigid bodies
btTransform pelvis = m_bodies[BODYPART_PELVIS]->getWorldTransform();
btTransform leftUpperLeg = m_bodies[BODYPART_LEFT_UPPER_LEG]->getWorldTransform();
// apply transformation to the frame's transformation matrix
D3DXMatrixTransformation( &((Frame*)m_pMesh->GetFrame( "RootFrame" ))->TransformationMatrix, NULL, NULL, NULL, NULL, &quat, &ConvertVector(pelvis.getOrigin()) );
// the whole transformation is only applied to the root frame, the rest i only apply orientations
leftUpperLeg.getBasis().getEulerZYX( yaw, pitch, roll );
D3DXMatrixRotationYawPitchRoll( &((Frame*)m_pMesh->GetFrame( "ThighLeftBone" ))->TransformationMatrix, yaw,pitch, roll );
One thing I tried is to copy the whole rigid body transformation to the left leg - and you can see the result, the leg apparently drifted apart.
I think my questions are, can I just copy the btQuaternion or extract yaw, pitch, roll just what I did above and copy it over to DX data structures and use it for transformation and expect it to work?
Do I need to apply any offsets?
I am expecting at least the leg should be aligned with the right body but is not. The rootFrame/Pelvis seems to be aligned correctly.
Please let me know if you need additional information.