Fit object in camera view

Started by
0 comments, last by MrCodeSushi 10 years, 10 months ago
I'm thinking of a simple camera behavior where the camera would smoothly zoom in to an object but just enough that the entire 3d model would perfectly fit in the camera's view. More specifically, i'm creating a 3D textured quad with GUI elements rendered in the texture then the camera would zoom in to that quad until it would look like as if it was rendering quads in an orthographic projection; but it would still be in perspective projection. Kind of like similar to what Windows Aero View does when it transitions back.

Windows_7_Aero.jpg

I'm drawing blank on where to start on the math for this behavior. Can anyone be so kind to explain the mathematics for this? Pseudo-code would even be much helpful. smile.png
Advertisement

Found this topic that i think should solve my problem. http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene

My main concern was figuring out the right distance for the camera to zoom in on an object but just enough that the entire object still fits in the camera view. Haven't implemented this on my own yet but i think the math seems sound.

This topic is closed to new replies.

Advertisement