Inverse Kinematics and Jacobians
I recently wrote a paper on my research into procedural animation. We are only a few days from final project and my big game proposal is largely animation based. I thought it would be a good idea to put together a simple demonstration of Inverse Kinematics before Wednsday.
Although I was fairly successful at implementing the basic hierarchy, I am miles away from true IK. At the moment I’m attempting to comprehend Jacobians, but I feel my understanding for Calculus is really holding me back, as I’m having a hard time understanding fundemental concepts such as partial derivatives and how to represent derivites in code. Of course these are only set backs that I will resolve in the coming days.
For one I am glad I decided to keep this Unit Test very light and keep the process very itterative. This is usually quite the opposite to how I approach problems, but in this case it was largely to my benefit, as it allows for the implementation of small features before tackling the monster that is IK.
The steps I took are as follows:
- Render a joint on screen using D3DXCreateTeapot (later changed to D3DXCreateSphere)
- Add simple camera controls
- Build a simplified skeleton architectures. This involves joints, and bones.
- A joint is packed with a 4×4 local and global matrix representing both orientation and translation.
- A local matrix is relative to its parent or @ origin (identity matrix) if no parent is present.
- A global matrix is set or computed by taking the inverse of the local matrix. (this step will refined later)
- A joint contains a list of children (bones). This allows us to climb down the hierarchy.
- A joint contains an index into it’s parent (joint). This allows us to climb up the hierarchy.
- A bone contains an index into it’s fromJoint, and an index into it’s toJoint.
- If a a bone contains no toJoint it is assumed as the endeffector.
- Build a DummySkeleton function that initializes a simple arm hierarchy as seen above. This is fast and easy, and would be later replaced with a filestream and a tool.
- Render the skeleton.
- Rendering joints as sphere will allow for simple collision tests when regarding picking
- Bones are rendered through D3DPT_LINELIST.
- Utilization of recursive breadth first traversal and ID3DXMatrixStack for push, and pop functionality.
- Add picking (simply changing the appearance color of the joints for visual confirmation)
- This will probably involve having to add additional information to an already rather large joint class.
- Add highlighed, and selected states to the joints.
- Again I opted to keep these inside the joints
- When selected, translate the joint based on cursor position (should already be taken care of inside the picking algorithm). There is again some heavy use of inverses in this function, and this is where we can draw relationships between the data, to hopefully create better data structures during the next iteration.
- Although imo, a minor step before attempting true IK. Implementing bounds based on bone length and DOF values for the axis, we will be officially at the milestone of Dynamic Control.
