[SOLVED] Zooming in 3D

I am working on a game in 3D, and have a question about zooming.

I basically want to be able to enlarge / zoom a single model in the game world to view it better, whilst keeping everything else at the regular size / normal scale.

Currently I am doing that by changing the single model scale to be larger. I have also found another way that also works well… I set everything at a Z depth of 40, and I can also zoom a single model by changing its Z to be closed to the camera e.g 10.

I have since discovered that there’s a 3rd way to zoom I.e change the camera FOV, but this won’t work unless I maintain a separate camera for each model, or recalculate the camera view for each model (on every draw) based on its zoom.

My question is… Which would be the most efficient method to zoom on a per model basis… Scale it, change Z, or change FOV per model?

One other question I have is regarding the Z. When setting up the camera near and far planes, you can use values like 500 etc.

For the vector3, I thought the range was - 1 to 1 for X, Y and Z… But it seems I can set Z to 40, 50 etc?

How does the near and far plane values map to the vector3 Z value?


The way I have doing is moving the camera closer to the modal. U will have the look vector for the camera so add that to the camera position multiplyed by the amount you want to move

Campos += look at * amount;

You can either move the camera position as mentioned above, or if you want a telephoto zoom like using the telephoto lens on a camera, lower the field of view when creating the camera matrix. This also has the effect of compressing the apparent depth of objects in the scene, just like a telephoto zoom would.

I have been playing around with using the camera to zoom and have run into an issue.

If the model I am zooming in is in the center of the screen… then all is good.

The problem is, if the model is in the far left or right of the screen and I then zoom by changing the FOV, the zoomed model is then displayed in the center of the screen.

How can I use the camera / FOV to zoom and still keep the zoomed model on the side of the screen it’s supposed to be on, but just be larger?

Am I forced to use scale or just change the model Z instead?


In your earlier edit, you mentioned that you set the camera target to the model. That is how the model ends up being in the centre of the screen after the zoom. Just change the FoV for the camera matrix. Don’t move the camera position or change the camera target.

Note that if the model is already on the edge of the screen, a zoom will end up with that model disappearing of the side of the screen simply because the field of view is being narrowed.


Yeah, you are right… the model disappears off the screen when zooming via the camera. I am thinking the way to solve this would be to offset the camera position by an amount relative to the zoom so the camera is closer to the model in the X and Y axis, but just enough to still keep the model in view (and still relative to the models original position on the screen).

The math for this seems like it might be tricky though…


Solved this by moving the camera closer to the target model… seems to work as expected now.