Not sure if it is possible, but lets say the camera is looking to object X, and then it goes to look object Y, but object Y seems too small at the camera current Y axis(the “zoom” axis); how could one make the object occupy almost all the camera viewport(leaving just some spacing)? The obvious way would be:
1 - Could change the camera Y axis value, increasing the camera “zoom”, until it intersects the camera borders, when that happens, I would detect that and revert the zoom increase a bit, but that would not look good at that slighty “zoom” revert step of the process.
2 - Could just hard code the exact “zoom” amount for the “type” to which the object being zoomed in belongs to.
3 - Could do some kind of calculation between the object current scale and Y distance to the camera to obtain the final “zoom” value.
Is there more efficient ways of doing the above?If not, what option above would you consider best? Thanks for your support.
There are probably lots of great ways to do this. Here’s the first thought that came to my mind:
I like idea 1 in your list. Since you don’t want the “zoom back” effect (which might actually look pretty cool… you should try it first), put a second (inactive) camera slightly in front of the active camera. Use the inactive camera to do the intersection calculations. That way the object will be slightly outside of the inactive camera’s frustum, but it will still be entirely within the frustum of your active camera.
Edit: Actually, that’s unnecessary. Just use camera.shpereInsideFrustum() and set the radius of the sphere to be slightly larger than the actual object. Zoom until it returns “INTERSECT” and then stop. Your border around the object will be determined by how much larger than the object you make the sphere.