I believe this is strictly a math problem, and my math skills are lacking.
I want to switch a perspective camera pointing at a scene (with its specific frustum and zoom settings) to a parallel camera. Easy enough: just call “setParallelProjection(true)”. Except that now my scene is completely out of whack: it’s zoomed way out to the point of invisibility.
Through trial and error, I realized that the new parallel frustum settings need to be updated, as the old “trapezoidal” ones for the perspective camera no longer apply to the “box” frustum of the parallel camera. Also, the zoom value doesn’t influence the scene, which makes sense given that “zoom” doesn’t mean anything with a parallel camera. However, judicious updates to the parallel frustum settings seems to mimic a perspective zoom - smaller frustum, closer “zoom”, larger frustum, farther away “zoom”.
What I’m looking for here is how to programmatically convert [perspective frustum + zoom] values into [parallel frustum] values so that the rendered image occupies the same general space in the ViewPort.
Sorry if this has been answered elsewhere or if what I’m requesting makes no sense. Thanks!
To transition between perspective and parallel without changing the apparent size of objects, you have to pick objects at a particular distance from the camera. If you have objects both 10 world units from the camera and 1000 world units from the camera, “something has to give”.
OK, let’s say I’ve identified an object at a particular distance. Given this, is there a straightforward algorithm/formula for how to make that object appear the same size after switching the camera from perspective to parallel mode?