The specialization project at The Game Assembly is a coarse that lets the student learn more about one specific area of programming. The student sets up a plan and goals, then reviews the result and learnings. The project is constructed over 4 weeks (half-time).
For my specialization I wanted to dive deeper into physics (PhysX) and animation. Because of this, I chose to create a ragdoll effect for my specialization. The steps needed for this was to find transforms for physics actors through the animation system, connect these with joints, then send back new orientations to the animation system.
I started off familiarizing myself with the animation system, to see how I could get the transforms of the animation bones. I came to realize, the assimp animation nodes were structured as a branching linked list. Knowing this, I could loop through the nodes with a recursive function, adding their relative transforms to a global transformation matrix. This global transformation matrix was in bone-space, which meant I had to multiply it by the inverse of the bone offset matrix.
Positions and rotations of the animation bones.
Creating PhysX Actors
With the transformation data and parent connections in place, the next step was to create the PhysX actors and connect them by joints.
The bone positions generated from the animation system were points where the joints would be placed, which meant the actors should be placed between them.
Adding collision layering and D6 joints with constraints, this produced the result I was hoping for.
Writing Data to Animation System
When writing to the animation system, I had to convert the world-space transformations of the PhysX actors back to bone-space. This also meant I had to find the orientation of the joints by only using the actors. This is my solution. The current animation in progress is stopped, then the matrices are sent back to the animation system.
The result was a bit rocky, but still proves the fundamental idea. It seems the rotation of the joints relative to the parent is at fault. If I had more time I would investigate that futher.