Game Development Reference
In-Depth Information
The final vertex's transformed position is the weighted average of the initial vertex
position transformed by each of the attached joints. However, before deriving the
formula for the vertex position, let's first understand the concept of the binding
matrix. The Bi i matrix for the i joint is a matrix of the transformation of the coordinate
joint local space to skin local space. To transform a point from skin local space to
joint local space, we use B-1i, -1 i , the inverse of the binding matrix.
The binding matrix
Although, the binding matrix is a simple concept, sometimes it baffles the most
intelligent of the minds. When we draw a mesh, each vertex is provided with a
position relative to the model's center. It is like the model is centered at the origin
of our world. During modeling, we create the skeleton along with the skin, each
bone/joint at this point has a zero DOF value, we call this pose a zero pose. However,
during the skinning process, we change the position of each joint to match the mesh.
This pose is called the binding pose. Note that we change the DOF (position and
angles) of each joint to match the vertices. The initial DOF values of the binding pose
for each joint form the binding matrix or we can say, the initial joint matrix. This
matrix is used to transform any position from joint local space to skin local space.
Remember that each vertex is defined in skin local space. Hence, to transform a
coordinate from skin local space to joint local space, we use inverse joint matrix B-1i. -1 i .
During animation, we change DOF values (position and rotations) of a joint, but
these values are in joint local space. Hence, the final vertex is transformed using
M i =B -1 i W i where W i is the joint matrix in the world space. Hence first, we transform
a vertex from skin local space to joint local space and then, we transform it using the
joint's world space matrix. For a pose or animation frame, we calculate the Mi i for all
joints and then pass this final transformation matrix as a uniform to the shader so
that we do not have to recalculate it for other vertices in the same joint, as shown in
the following code snippet:
// compute the offset between the current and the original transform.
mat4.mul(offsetMatrix,this.bones[ b ].skinMatrix,
this.boneInverses[ b ]);
The final vertex transformation
The final vertex transformation is the weighted average of the initial vertex position
transformed by each of the attached joints, v'=∑w i *v*M i , where Mi=B -1 i Wi and wi are
the weight value of a joint for vertex.
 
Search WWH ::




Custom Search