I tried inputting a bone’s absolute matrix’s rotation quaternion into its bone.setRotationQuaternion() method with the parameter BABYLON.Space.WORLD, however the skeleton and mesh become messed up
I thought that a bone’s (1) absolute matrix’s rotation quaternion and (2) world rotation quaternion are the same, so I expected that setting one to the other would have no effect, though it looks like I’m wrong.
Please see the Youtube video below where I uncomment lines in the PG linked below:
Does anyone know the relationship between the (1) world rotation quaternion and (2) absolute matrix rotation? I’m trying to find the correct input quaternion for bone.setRotationQuaternion() with BABYLON.Space.WORLD.
You are missing a multiplication of the first row by a scaling value, which is +1 or -1 depending on the bind matrix determinant. From _updateAbsoluteBindMatrices:
@Evgeni_Popov thank you for your tip on the scaling determinant. I’ve tried looking online to understand this term more, though haven’t found anything yet. Would you have any pointers on where I could read more on the scaling determinant’s purpose in the bone’s world rotation?
Unfortunately, I don’t really understand this part of our bone code, so I can’t really help…
From what I understand, it takes into account the fact that the matrix could be “left”/“right” handed (as we do for meshes coming from gltf files), and negate the X axis of the matrix (the first row) - we also negate scaling.x for the root bone in gltf case.
Thank you so much again, @Evgeni_Popov, for your expertise and help here
I exported a .glb of the same model. Previously, I exported to the .babylon format. I’m trying to do the same thing in the PG for the .glb version
The boolean USE_GLTF can be changed to use either the .glb or .babylon model. The PG below works great when using .babylon, though I’m having trouble getting the same result with .glb. Would you be able to help with finding where I’m going wrong?
bone._linkedTransformNode.rotationQuaternion = rotation is wrong, because rotation is in world space whereas bone._linkedTransformNode.rotationQuaternion expects a quaternion in local space.
I gave it a try, simplifying the calculation, as it seems to boil down to R.W-1, where R is the rotation matrix you want to define for the bone (in world space) and W-1 is the inverse rotation matrix of the bone’s parent:
Would you be able to help me figure out how to get these few bones in the right orientation when trying to set the rotation of their _linkedTransformNodes? Thank you so much for your help, Evgeni I’ll be studying this too to try to also try to learn how to do this
I’m afraid I can’t help more, I’m a bit stucked… The problem is because of left-handedness. It works if you switch the scene to right handed mode (that’s a workaround at least):
In fact, we can see that in left handed mode there are more problems than just the thumb position:
Thank you so much, @Evgeni_Popov! You’ve helped me greatly in the right direction I’ll be studying this today and will try to solve this for left handed mode