Skip to main content
GameDev.net gamedev.net
🔒 Locked

fitting a random mesh to the screen

Started by BlackLiquid Oct 25, 2005 at 2:16 PM 0 replies 600+ views
Original Post
BlackLiquid
BlackLiquid
I hope this doesn't fall under the category "Kindergarten Math" but here goes :) I'm trying to scale a random triangle mesh which I've read from a file so that it fills the scene I draw it too. I'm using perspective projection and set the frustum like so: glFrustum(-1.0f, 1.0f, -1.0f, 1.0f, 2.4f, 30.0f); I've gone through all the vertices to figure out the max width, height and depth of a given mesh and been playing with those numbers, but to be honset I'm not entirely sure what I'm doing ;) Just so you know this is school related but since this is not the main focus of the excercise and its more math than graphics oriented I thought I'd cheat a bit (that's right professor!) ;) Feel free to be vague in your answers though if you think I'd benefit more from it :D
grhodes_at_work
grhodes_at_work
What you have to do is find some kind of bounding volume, then determine a frustum that can entirely contain that volume. You've picked a box,but a sphere can be easier to use because it is not view angle dependent. Once you have the bounding volume, and know what the dimensions of the frustum must be to contain it, just move the camera and orient it to be at the apex of the frustum. You certainly can constrain the frustum to have a specific view angle (say 45 degrees), and to have a closed problem you will have to constrain it. You also have to take into account the fact that your near clip plane is somewhere in front of the camera (znear > 0) and the far clip plane isn't at infinity (zfar is finite).

Hope this gives some clues!
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.