Sign in to follow this  

simulating ragdoll with Bullet

This topic is 3311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello Would anyone please try and help me here. Please see attached screen shot: I use DirectX Skinned mesh SDK to load and render my skinned mesh. Specifically I render my mesh with the code under DrawMeshContainer with the method D3DNONINDEXED. So there's 4 matrix here. 2 Goes with the derive D3DXFRAME. Another 2 for the pointer and the bone offset that goes to the derived D3DXMESHCONTAINER. Prior to the rendering, I do 2 things. 1. - is I set orientation from the rag doll rigid bodies to D3DXFrame::TransformationMatrix 2. I update all the frame matrices and put them into a combined matrix variable - just the same code how everyone else does it. Then render the entire mesh hierarchy. I would remove step #1 if i were just animating the mesh, and it would show right. This is how I do step #1.
// 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 );

// I do the same with the HeadBone

I only try to deform the upper leg, the head and the pelvis, and it won't transform right. The pelvis/root frame seems to be correct, otherwise both the leg and the head are not. I'm expecting they should at least align with the rigid bodies. The 2 side by side screen shot above is when i only apply orientation. The lower screen shot is when i apply the whole rigid body transformation to the upper left leg - you can see its drifting apart! This is the frame hierarchy if it helps:
/*
DEBUG - SCENE_ROOT
DEBUG -  RootFrame
DEBUG -   HipLeftBone
DEBUG -    HipBone
DEBUG -     HipRightBone
DEBUG -      ThighRightBone
DEBUG -       ShinRightBone
DEBUG -        FootRightBone
DEBUG -     ChestBone
DEBUG -      ShoulderLeftBone
DEBUG -       NeckBone
DEBUG -        ShoulderRightBone
DEBUG -         UpperArmRightBone
DEBUG -          ForearmRightBone
DEBUG -           HandRightBone
DEBUG -        HeadBone
DEBUG -       UpperArmLeftBone
DEBUG -        ForearmLeftBone
DEBUG -         HandLeftBone
DEBUG -    ThighLeftBone
DEBUG -     ShinLeftBone
DEBUG -      FootLeftBone
*/

Please let me know if you guys need additional information. Many thanks in advance!

Share this post


Link to post
Share on other sites

This topic is 3311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this