I have a 3d model of a human skeleton.
Currently I do the following:
Bone3D* node; //The bone I want to set the orientation of. Mat4 mat = node->getLocalMat(); //I modified Skeleton3d to let me access the local matrix Vec3 pos, scale; // store original translation & scale mat.getTranslation(&pos); mat.getScale(&scale); // reset matrix mat.setIdentity(); // create float array for translation float trans; trans = pos.x; trans = pos.y; trans = pos.z; // create float array for scale float s; s = scale.x; s = scale.y; s = scale.z; // create quaternion float array for rotation Quaternion q = ToQuaternion(yaw,pitch,roll); float rot; rot = q.x; rot = q.y; rot = q.z; rot = q.w; // send transform values to bone node->setAnimationValue(trans, rot, s);
By doing this, I am able to set the angle of the bone relative to its parent bone (similar to how localspace works with 2d sprites), but I am not able to set the orientation of the bone in 3d space. How can I do that ? I still want the location of the bone to be where it should be (it should be attached to its parent at the correct place), but I want to be able to set its yaw, pitch and roll, relative to the world.