Jengu
08-14-2005, 11:35 PM
I'm trying to figure out how to size glOrtho so that it gets the tightest possible fit around a 3D box. Normally this would be simple -- just make glOrtho's dimensions the same as the box. But I rotate the box, so if I pass the box's dimensions to glOrtho, vertices get rotated outside the view frustrum.
The first thing I tried was making all of the dimensions passed to glOrtho equal to the distance of the two farthest apart points of the box. This makes any rotation visible, but it's not the best fit for any given rotation.
My trig skills are a little rusty. How can I figure out for a given rotation what the best fitting glOrtho parameters would be? I'm always drawing a rectangular box (i.e. not always all of the boxes dimensions are the same, could be 3x3x3 or 52x7x4).
The first thing I tried was making all of the dimensions passed to glOrtho equal to the distance of the two farthest apart points of the box. This makes any rotation visible, but it's not the best fit for any given rotation.
My trig skills are a little rusty. How can I figure out for a given rotation what the best fitting glOrtho parameters would be? I'm always drawing a rectangular box (i.e. not always all of the boxes dimensions are the same, could be 3x3x3 or 52x7x4).