| Inverse Kinematics |
DigitalRune Animation supports various Inverse Kinematics (IK) methods
that can be used to procedurally transform a skeleton.
This topic contains the following sections:
Inverse kinematics (IK)
Inverse kinematics (IK) is used to procedurally transforms the bones of
a skeleton in order to achieve a desired pose. For instance, a
LookAtIKSolver
rotates a bone (e.g. a head) to look into a desired direction. A
TwoJointIKSolver
can be used to bend/stretch a leg so that it touches the ground, or to make
an arm reach a certain target.
Typical IK tasks are:
-
Let the character head turn to look at a target position.
-
Let an arm reach for a target.
-
Manipulate a leg, so that the foot touches the ground exactly.
-
Manipulate a leg so that its ground position does not change to remove "foot sliding" in animations.
DigitalRune Animations supports various IK methods:
- LookAtIKSolver:
Can be used to make a bone look at or point at a target position.
- TwoJointIKSolver:
Manipulates two bones connected by a hinge joint (including hinge limits). This can be used for arm and leg IK.
- ClosedFormIKSolver:
Manipulates a bone chain with an arbitrary number of bones. Limits are not supported.
- CcdIKSolver:
Manipulates a bone chain with an arbitrary number of bones. This method is iterative and supports limits.
- JacobianTransposeIKSolver:
Manipulates a bone chain with an arbitrary number of bones. This method is iterative and supports limits.
See base class IKSolver
and the derived class for more information.
Class diagram Sample
The character animation samples (see Samples)
contains several IK samples.
General inverse kinematic tips Here are some general thoughts on solving IK problems:
-
If possible, solve the problem manually using math, geometry and trigonometry.
Simple 2-bone chains can be solved using the
Law of Cosines.
-
If you can solve at least part of the problem manually, do this. This will help the
IK solver to find a better/more stable/faster solution. For example: Rotate the root
bone to manually align a bone chain and then use an IK solver to compute the remaining angles.
-
Use a specialized IK solver, e.g.
LookAtIKSolver
or
TwoJointIKSolver,
if applicable.
-
Otherwise use general IK solvers.
-
Use physics simulation for very complex chains or constraints – or use physics if you
are more familiar with our physics API compared to our animation API.
The DigitalRune samples contain an "IKPhysicsSample", which shows how to use physics
simulation to solve a complex IK problem.
Subtopics