4/4

4. Character skinning

Consider the code in 03_skinning/skinning.

This scene load an animated skeleton, and a mesh which is expected to be deformed by skinning. A rough animation of the skeleton is already coded (no smooth interpolation between key poses). The geometrical deformation of the associated mesh by skinning is not coded yet.

Two models are proposed

  • A cylindrical model (basic bending cylinder) fully procedurally generated within the code (load_cylinder_data)

  • A more complex running character (load_character_data) stored as external files (loaders are provided)

    • Note that the file format doesn’t follow any standard, but is rather a simple ASCII format easy to read and parse

    • Standard file format handling skinning are often complex to parse. Collada is an open XML based format that can handle skinning animation. Other formats are mostely software specific (.3ds, .blend, .fbx, etc.).

Skeleton encoding

The skeleton is stored in a simplistic format assuming tree like organization from the root node.

  • A vector stores for each node/joint its geometry encoded as 3D position and rotation (quaternion).

    • The geometry is expressed in a local coordinate frame with respect to the parent joint.

    • This vector is build such that child joints are always encoded after their respective parent

  • Another vector indicates the parent index of the k-th entry within the vector, therefore storing the connectivity of the tree structure.

  • Given the tree connectivity and the local geometry, the function local_to_global() compute the global 3D coordinates of each joint.

  • The associated skeleton can then be displayed by the function display_skeleton()

Skeleton motion

The function interpolate_skeleton_at_time is expected to compute the interpolation of the skeleton at a given time \(t\). So far, no smooth interpolation is performed (nearest(/smaller integer) neighbor is picked) which leads to discontinuous motion.

  • Complete the function interpolate_skeleton_at_time to get a smooth skeleton motion

    • Position can be interpolated linearly

    • Rotations can be interpolated using the provided SLERP function using quaternions

Linear Blend Skinning

The function compute_skinning is expected to compute the deformation for each vertex with respect to the linear blend skinning formulation.

The function receives in parameter the current skeleton geometry and the associated rest pose (already in global coordinate system). The skinning structure contains the skinning weights (stored in variable influence), the positions of the mesh in the rest pose, and the deformed mesh position to be filled.

  • Code the linear blend skinning formulation to obtain the temporal animation of the cylinder and the running character.

    • Tips: The static function mat4::from_mat3_vec3(mat3,vec3) can generate a \(4\times 4\) matrix given a \(3\times 3\) matrix (typically a rotation matrix in our case) and a translation.

    • Tips: The function quaternion_to_mat3(quaternion) converts a unit quaternion to its corresponding rotation matrix

    • Tips: You can explicitely express the inverse of a transformation involving a rotation and a translation.

  • (if you have time) Make your character follow a specific trajectory described by key-frames (translating the character is obtained by applying a transformation on the root joint).