I have a very large sphere that I would like the view camera to be able to fly on (the surface) as if it were a flat plane. Yet rotating the camera on the surface of the sphere has proven troublesome…Here is a quick video meant to demonstrate the issue:
The first seven seconds are spent showing the rotation error when the axes of the camera have not been modified. At seven seconds, the following line of code is activated:
Vector3f up = cam.getLocation().normalize();
cam.setAxes(up.cross(cam.getDirection()).normalize(), up, cam.getDirection());
and repeatedly executed in the update-loop. Since the camera is on a sphere I figured one can just set the up-vector to be the vector from the center of the sphere to the camera (just the camera position normalized.) But as shown by the video, this does not work.
I do have a more free range of rotation when using the aforementioned line of code, but as seen, the camera does not rotate all the way around (noticed when the camera begins to “jitter”.) I also cannot look up or down when using that code: when I attempt to “look” up and down, the camera simply rotates.
Is there anyway to fix this problem?