For example, in blender, I have a rigged mesh where each bone has a local orientation.
However when I rotate the bone imported to an OpenGL application for Skinning/Animations, if I do glm::rotate(angle, axis); the rotation is along it’s “local” axis from within Blender, and not according to the “global” Z axis of my View.
Using glm, how would I rotate it so it appears to be rotating about an orthogonal point in my screen instead of about it’s local axis?
Does this make sense?
In red, is a rotation I “want”, it just happens that the original roll of the Head bone is oriented so it “appears” correct, but if I were to rotate the Mesh then obviously the bone will not rotate in the correct way as it is still rotating along it’s local z.
The arm bone in yellowish green, rotates along it’s local z as well.
Basically I would want the arm rotation, to be like the head rotation. Facing the camera.
glm::mat4 CurrentNodeTransform; CopyaiMat(&this->getScene()->mRootNode->FindNode(boneName.c_str())->mTransformation, CurrentNodeTransform); //glm::mat4 newRotation = glm::rotate(angle, glm::vec3(axis.x, axis.y, axis.z)); glm::mat4 newRotation = glm::rotate(angle, glm::vec3(0.0, 0.0, 1.0)); // NEED GLOBAL ROTATION //CurrentNodeTransform = newRotation * CurrentNodeTransform; CurrentNodeTransform = (CurrentNodeTransform * newRotation); CopyGlMatToAiMat(CurrentNodeTransform, this->getScene()->mRootNode->FindNode(boneName.c_str())->mTransformation);
Basically I fetch the local rotation of the joint, rotate it, and apply it back to the heirarchy of the rig.
How would I get it so it matches the axis of the “View”?