Advertisement

Rotate a bone, mathematical issues :(

Started by September 11, 2014 10:42 PM
10 comments, last by Buckeye 10 years, 5 months ago

mulMatrixByInverse(getJoint(joint.getParentIndex()), bind);

results in:

matrix = parent-inverse-bind * bind.

bind = parent-inverse-bind * parent-bind * bone-local * translate-to-origin * rotation. Note the emphasis.

bind = Identity-matrix * bone-local * translate-to-origin * rotation.

The problem is that "mulMatrixByInverse" function does this :


	private void mulMatrixByInverse(Joint ref, Matrix mat) {
		if (ref != null) {
			mat.matMul(ref.getInverseBindPose());
		}
	}

Thus the result is matrix = bind * parent-inverse-bind and not matrix = parent-inverse-bind * bind .

We have tried to invert the matrices inside the function above and the result is wrong, the model's leg moves in the wrong way.

It appears that the various matrix multiplication functions implement multiplication in right-to-left order, rather than left-to-right as I had assumed. The mathematical principle remains the same.

So..

bind = rotation * translate-to-origin * bone-local * parent-bind

Following mulMatrixByInverse

bind = rotation * translate-to-origin * bone-local * parent-bind * parent-inverse-bind

With regard to generating the Identity matrix, the order par-bind * par-inv-bind or par-inv-bind * par-bind is immaterial. The end result is the modified local transform for the bone.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement