Rotate a skeleton bone to look into specific point

I’ve stumbled on possible easy to solve problem with quaternions.

Situation:

  • I’ve got skeleton with a specific bone (e.g. “bone”)
  • The bone has it’s modelSpace position, rotation, scale
  • I’ve got other point in space (specifically tail point of an other bone e.g. “trackedBone” in the same skeleton)

Problem:

  • I would like to rotate a “bone” to point to this specific point in model space (simple trackTo constraint)

I was trying to get vector which define desired direction in world space:

[java]
Vector3f vec = trackedBone.getModelSpacePosition().subtract(bone.getModelSpacePosition());
[/java]

then i have to create Quaternion q in order to apply it on setUserTransforms:

[java]
bone.setUserControl(true);
bone.setUserTransforms(Vector3f.ZERO, q, Vector3f.UNIT_XYZ);
[/java]

And with this I have problem. Using Quaternion.lookAt() gives rotation regarding base position in Cartesian system but not for bone, which is located specifically in modelSpace e.g.

[java]
q.lookAt(vec, Vector3f.UNIT_Y);
[/java]

I’m not so good with quaternions yet. Anyone has got some advices ?