Monday, August 06, 2007

jME Camera Cropping

I've been having an issue with culling when using a fixed camera. When I try to position the camera so that it has a good perspective on the course, moving the marble to various parts of the course cause either (a) the marble to disappear or (b) part of the course to disappear. This doesn't happen when I use the chase camera.

A little experimenting suggests that I may have been positioning the camera in an invalid manner. I was using cam.getLocation().set() and cam.setDirection(). The problem seems to go away when I instead modify cam.getLocation().y and call cam.lookAt().

Update 2007-08-08: I immediately ran into problems with Camera.lookAt() in that the method seems to point the camera at the specified location by first tilting the vertical axis along the z-axis and then swiveling the camera left or right as required. This poses no problem when looking at an object ahead of the camera, but if the camera actualy has to look to the left or right, the image appears tipped over. For a while I went back to fiddling with adjusting the camera axes and direction manually but ultimately gave up; if I want to figure out how to point the camera without culling side-effects I'm probably going to have to study the lookAt method source code. I ultimately was able to get lookAt to work by specifying a top (argument 2 of the lookAt method) that points the camera in the direction of the target, so no left or right swivel is required.

No comments: