RE: [Algorithms] Trouble with translating ragdoll joint rotation to animation joint rotation
Brought to you by:
vexxed72
|
From: Jon W. <hp...@mi...> - 2005-02-18 22:14:37
|
I'm assuming ODE gives you all the bodies in world space, assuming you get both the rotation matrix and the position (offset) and stuff them into a 4x4 matrix. Does your animation system want bone-local matrices, or world-space matrices for bones? It's significantly easier if it wants bones; in that case, just feed the ODE matrices into the animation system (possibly with an offset for global->model space transform). If you want parent relative matrices, then you have to do a little more work, but not a whole lot. Form the ODE 4x4, then multiply that with the inverse of the 4x4 for the parent, and set that as your bone matrix. Note that the position part matters! If your skeleton doesn't allow bones to move (in addition to artuculate) then you have to separately take into account the actual points that the bones end up in, and try to run an IK-style solver to make them match the ragdoll -- it might be easier to just change the animation system at that point :-) In general, you can't talk about the "axis" of a joint in an animation system, although you CAN talk about an "axis" for constraints, and for expressing constraints of that joint. Sometimes, you'll optimize to the point that you know a joint is always only rotational around axis A, and you only store the rotation angle, but if you want to match a dynamics system with the animation system, you probably need more expressive systems than that for good results. Obviously, you also need to match your ODE skeleton as closely as feasible to the animation skeleton; you can remove bones by setting them to identity in the animation when rag-dolling, but the best results if the skeletons are not the same is to do the IK-like thing. (That's in fact what we do when tumbling our avatars) Cheers, / h+ -----Original Message----- From: gda...@li... [mailto:gda...@li...]On Behalf Of Megan Fox Sent: Friday, February 18, 2005 12:47 PM To: gda...@li... Subject: [Algorithms] Trouble with translating ragdoll joint rotation to animation joint rotation 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 ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ GDAlgorithms-list mailing list GDA...@li... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 |