I have reached my wits end in trying to get my model to align with its ragdoll, and I was hoping you could help me a with a couple questions. I am using BEPU physics for my simulation, where my Player primarily moves around via a CharacterController object until he dies, and then the ragdoll is activated.
I am currently trying to simply get the player model to stay locked with the the "body" entity as an initial working case before attaching each limb. The problem I have is pictured below:
As the ragdoll moves, the model does not stay locked with the body entity, and the more it rotates, the more the model separates. I presume this has to do with one (or both) of these 2 things:
1. The world transform of the model represents the center of the CharacterController capsule (the pink thing pictured). I use an offset during drawing that adjusts the draw position, but this may be causing wierdness when rotations are added from the body entity. Should I essentially just pre-offset my CharController's position, and then pass that Transform to the ragdoll class and draw functions?
2. I am attempting to calculate the offset of the model to the ragdoll, which I then factor in when passing back the bone transforms, so that apples are compared to apples when the body does start to rotate/translate. I may be doing this wrong? This is my psuedocode for calculating that offset:
Matrix offset = Matrix.Invert(bindPose[bindPoseIndex]) * Entities["body"].WorldTransform
and my code for reapplying it when the bone transforms are being calculated:
Matrix.Invert(offset) * body.WorldTransform * actor.WorldTransform (actor is the char controller)
I am pretty sure that once I can figure this out, the rest of the ragdoll will be gravy, but I have been racking my brain for about 30 total hours on this issue to no avail, and I need some help thinking outside the box.
Edited by trock, 05 November 2012 - 01:27 PM.