Let's say I have the following hierarchy:
Bone A
Bone B
Bone C
Here's how most tutorial is telling me how to calculate the finalMatrix to be sent to shader.
bonePoseToWorldPose(Joint * joint, glm::mat4 & parentTransform, glm::mat4 & globalInverseTransform) {
joint->finalTransform = parentTransform * joint->localTransform; // local transform is the result of interpolating 2 keyframes
for (int i = 0; i < joint->children.size(); i++) {
bonePoseToWorldPose(joint->children[i], joint->finalTransform, globalInverseTransform);
}
joint->finalTransform = joint->finalTransform * joint->inverseBindTransform;
}
Doing it this way, the final transform in bone C for example, would be localTransformA * localTransformB * localTransformC * jointInverseBindTransform.
Which does not make sense to me, and none of the tutorial satisfactorily explains that. Let's go back to the example again. the inverse bind transform would bring a vertex V from mesh space to bone space of Bone C. At bone space C, it would be multiplied with the localTransformC (or interpolated transform C), which I guess would set the model to our desired pose. But what are A and B doing there?