I want to convert an existing bone matrix into a direction vector and a roll angle, because when I import a glTF file from Blender then I have the bones matrices including the directions, but I don’t have the “roll” for each bone, I have no idea how to calculate the roll, any help please?
void boneMatrix_to_headTailRoll(
const glm::mat4 &matrix,
float length,
glm::vec3 &out_head,
glm::vec3 &out_tail,
float &out_roll)
{
?
}
Another simple question, referencing from Blender’s bone, how to calculate the bone matrix from 2 points ‘head’, ‘tail’ and an angle ‘roll’ such as the origin of the matrix is the ‘head’, use GLM C++? In general, asking this question will solve 2 problems: “Add a bone in C++” and “Half answer the first question by doing reverse engineering”, but the problem is I indicate a weird situation in the image (double solutions).
glm::mat4 boneHeadTailRoll_to_matrix(
const glm::vec3 &head,
const glm::vec3 &tail,
float roll)
{
?
}
Note, I tried to use glm::yawPitchRoll()
but it’s very different than the Blender bone matrix rotation.
.blend file:
doc-bone-roll.blend (137.9 KB)