Skeletal
animation is a
modelling technique in which, in general, a
polygonal or other solid
mesh is connected and
deformed by a collection of
joints and
bones.
A bone may be connected to other
bones, via joints. A bone may have one 'parent' joint, and several children. Each bone's
angle and
position will be computed in relation to its parent, and the parent of that,
etc, until there is no parent.
Bones consist of a length, an angle (or
quaternion), and children bones. The drawer will start at the
root bone,
rotate
the
vertices/part of mesh affected by the bone. It will then draw the bone's children, in relation to the parent bone, in
the same manner. The result of this is a new mesh, that is deformed to fit the bone structure.
The advantages of this, over simply altering the position of vertices in pre-set fashions (such as in
Quake) are smoother
animation playback, easier animation creation, and the ability for
dynamic movement of limbs.
Dynamic animation, such as
ragdoll physics, where a man caught in an
explosion could fly away from the impact, and react
to the
environment as if his muscles were completely relaxed, is possible. As is
blending of different animations, to create a seamless
rendition from walking to running, or talking and walking.
Here is some
pseudo code, to describe the basic idea of writing a skeletal animation renderer:
function bone($bone, $matrix)
{
rotate $matrix by the angles of $bone
add vertices in $bone to new array, rotating each by $matrix
translate $matrix by the length of $bone
for each child of $bone, recurse this function with the matrix we now have and add vertices to the array
return the array of vertices
}