PDA

View Full Version : Viewport Fitting



glfreak
07-16-2009, 10:04 AM
How can I transform an arbitrary 3D object such that it fits into the viewport centered. for example, inside the view volume with specific margins from the edges of the viewport?

Thanks.

awhig
07-16-2009, 11:16 AM
Need to check the coordinates of the object and the camera origin.

Otherwise, keep the object fixed and then accordingly set the camera parameters so that the object gets housed in the view frustum of your camera.

Brolingstanz
07-16-2009, 03:30 PM
Sounds to me like your problem is under-constrained, but in the interest of argument how about say maximizing the projection of a salient convex hull?

glfreak
07-17-2009, 07:01 AM
Solved. I just need to calculate a bounding volume of the object and makes it fit in the frustum based on a z-distance from the center.

Thanks.