Hi guys, I have little problem.
There is a function, that rotates bone
// type script function
public static rotateBone(bone: BABYLON.Bone, quat: BABYLON.Quaternion): void {
var result = bone.getLocalMatrix();
var xx = quat.x * quat.x;
var yy = quat.y * quat.y;
var zz = quat.z * quat.z;
var xy = quat.x * quat.y;
var zw = quat.z * quat.w;
var zx = quat.z * quat.x;
var yw = quat.y * quat.w;
var yz = quat.y * quat.z;
var xw = quat.x * quat.w;
result.m[0] = 1.0 - (2.0 * (yy + zz));
result.m[1] = 2.0 * (xy + zw);
result.m[2] = 2.0 * (zx - yw);
result.m[3] = 0;
result.m[4] = 2.0 * (xy - zw);
result.m[5] = 1.0 - (2.0 * (zz + xx));
result.m[6] = 2.0 * (yz + xw);
result.m[7] = 0;
result.m[8] = 2.0 * (zx + yw);
result.m[9] = 2.0 * (yz - xw);
result.m[10] = 1.0 - (2.0 * (yy + xx));
result.m[11] = 0;
result.m[15] = 1.0;
}
But this function rotates bone in local space, and I need rotetes bone in world space. What I should change in function?