I am trying to allow my camera to have different "focus points" around the scene so that when the user rotates the camera, the camera rotates around that focus point. In "focus mode", when the user clicks on an item in the scene that item is set to the camera's rotation point.
To do this I simply made a transform from the position of the clicked item and a quaternion holding the cameras rotation about that item. Basically the clicked item acts as the camera's parent.
The transforms are multiplied like this -
camQuaternion.getRotationTransposeMatrix() * camPosition.getInverseTranslationMatrix() * mParentTransform.getInverse()
Where the parent inverse is just
parentQuaternion.getRotationTransposeMatrix() * parentPosition.getInverseTranslationMatrix()
When the mode is in "focus mode" I then apply all rotations to the parent rather than the camera..
This all works great - but im stuck on one thing..
How do I set the camera's local position and rotation when the focus point changes so that the camera does not move at all..
or in other words, how do I transform the camera's rotation/translation from the coordinate space of one clicked object to the coordinate space of another clicked object so that the camera does appear to move at all to the user when the focus point has changed?
right now when you click on another object the camera jumps so that it is in the same position/rotation with respect to the new focus object as it was with the old focus object