[Algorithms] Trouble with translating ragdoll joint rotation to animation joint rotation
Brought to you by:
vexxed72
|
From: Megan F. <sha...@gm...> - 2005-02-18 20:47:20
|
I'm having trouble with my ragdoll code, but it isn't the physics side - ODE has that handled famously - the trouble I'm having is with translating the rotation of the physical joint to the rotation of the animation joint. Specifically, getting the coordinate space of the physical side of things to match the coordinate space used by the joint in question. In the physical world, I have my "root" body for a creature, which is roughly equivalent to the root node in the animation system. To create, say, the waist joint, I make the "root" physical representation resemble the hips, create another physical body to resemble the chest, and joint the two. To get the rotation between the two, I would do chestMat * (hipMat ^ -1), and take the quaternion of the result matrix. This works fine for exactly one test matrix - an arm - because it just so happens that the single joint of the arm has axis which align with the object-space axis. The trouble arrives when you look at the coordinate systems for the hips and chest. The torso ends up having axis which go xvec = -objecty, yvec = -objectx, and zvec = -objectz - this is because in the animation skeleton, there's a good 3 bones between the root and hips (all of which liking to tweak the coordinate space - it ends up that positive X always points "up" the bone towards the parent joint), while in the physical skeleton it's just a straight connection. I've tried canning it, by working through the pose (default joint position) quaternions, quat1 * quat2 * ... etc up to the hips, hard-setting that as an assumed hips rotation, setting the initial orientation of the chest body to match the pose joint rotation of that bone, then doing the rest of the joint rotation calc normally from there... but even that didn't give me the results I was expecting - it aligned the torso's axis with object-space axis, though the joint movement past that was seemingly correct. So, I assume my understanding of all of this is flawed on a basic level, probably relating to my fairly weak understanding (self-taught as I've needed it) of the application of matrices. I could very much use some help in figuring out where I've gone wrong. Thanks, -Megan |