Choose of Algorithm:
After searching on internet, I think Cyclic Coordinate Descent, as a numerical method, is a more practicable algorithm compared with analytical methods. It can be implemented both easily and efficiently.
Implementations:
The implementation of CCD are mostly done in one single function(function SetModleSpaceIkPosition at line 691 in file AnimatedMesh.cpp), in which bones from a given IK chain are traversed and updated for 10 times according to a given end effector position to get a result, The end effector positions are assumed to be under model space and will be draw as a red ball. To build an IK chain, I wrote a function AddIK (at line 291 in file AnimatedMesh.cpp), which takes names of start bone and end bone, traverse the skeleton hierarchy using function TraverseGetBones( at line 383 in file AnimatedMesh.cpp) to find the whole chain from start to end, and save bone indices into a map container.
Pose Blending:
To Show the process that bones move from animation pose to IK effector pose, I add a float blending value in SetModleSpaceIkPosition function, which blend position between end bone position and end effector position to get “true” position for IK calculation.
Character’s arm blending from animation pose to IK pose
Explanation About Videos:
The first video shows IK effect of a skeletal mesh’s arm and leg, the IK chain for leg starts at upper leg and ends at first bone of foot and the IK chain for arm starts at shoulder and ends at hand.
The second video shows the blend effect between animation poses and IK poses.