I used a bunch of primitive convex shapes - mostly capsules, but theres at least two box shapes in there too - I was able to get a “close enough fit” without actually defining any custom geometry.
For each major bone in my skeleton, there is a corresponding bodypart.
For things like the spine, I simplified the number of bodyparts / active bones, thus, there is not a strictly one to one relationship between bones and bodyparts.
So, in Urho3D, when we load our animated model and instantiate it in our scene, there are a bunch of nodes with names matching our skeleton bones. Before playing any animations, we are in the “bind pose” … We attach rigidbody components to those bone nodes, and set the rigidbodies to “kinematic mode”. Now the rigidbodies will automatically be animated when we play animations on that character - but we won’t get any collision responses on our armature because its in kinematic mode. If we want the armature to respond to collisions, we need to do a bit more work.
I used the Ragdoll Sample as a guide to help me construct my armature, but I did not leave the rigidbodies in “dynamic mode” (aka ragdoll mode). Making them kinematic means they get their world transform from their parent node, which in our case means a bone node, which in turn, is likely to be animated.
I separated the hardcoded data from the sourcecode, and moved it into an xml file per character:
When this xml file is read back in at runtime, the data completely informs the code how to construct the armature for that character - this is my understanding of a “data-driven approach”. Note that our code requires no knowledge of the bone topology - this will “just work” for any skeleton, from an octopus to a dinosaur. We just need to craft the right data!
Since the names of bones might differ between character models, we are specifying the bone names explicitly in the per character data, so that is never a problem. Oh yeah - the position and rotation values are relative to the space of the parent node , ie, “in bonespace”. We use them as “offsets” to position and orient the bodyparts, relative to their parent bones, IN THE BIND POSE.
I have data for joint constraints, but I don’t need any joints until I want to switch from animated to ragdoll mode… and when that happens, I may choose to set only part of the armature to ragdoll mode, and leave the rest animated…