/**
* Update the global and palette transforms of our posed joints based on the current local joint transforms.
*/
public void updateTransforms() {
final Transform temp = Transform.fetchTempInstance();
// we go in update array order, which ensures parent global transforms are updated before child.
// final int[] orders = _skeleton.getJointOrders();
final int nrJoints = _skeleton.getJoints().length;
// for (int i = 0; i < orders.length; i++) {
for (int i = 0; i < nrJoints; i++) {
// the joint index
final int index = i;
// find our parent
final short parentIndex = _skeleton.getJoints()[index].getParentIndex();
if (parentIndex != Joint.NO_PARENT) {
// we have a parent, so take us from local->parent->model space by multiplying by parent's local->model
// space transform.
_globalTransforms[parentIndex].multiply(_localTransforms[index], _globalTransforms[index]);
} else {
// no parent so just set global to the local transform
_globalTransforms[index].set(_localTransforms[index]);
}
// at this point we have a local->model space transform for this joint, for skinning we multiply this by the
// joint's inverse bind pose (joint->model space, inverted). This gives us a transform that can take a
// vertex from bind pose (model space) to current pose (model space).
_globalTransforms[index].multiply(_skeleton.getJoints()[index].getInverseBindPose(), temp);
temp.getHomogeneousMatrix(_matrixPalette[index]);
}
Transform.releaseTempInstance(temp);
firePoseUpdated();
}