Ok. You have to do the trig calculation a little differently to allow for perspective.
Find the normals of the top and bottom culling planes. Find the size of the box along those normal directions, using the formula I gave previously. If the sizes are s1 and s2, then the distance is
D = (s1 + s2) / (2 sin(half FOV))
Do the same for left and right. Also, you don't want to be looking at the box centre or part of the box will be off screen. You'll need to pan the camera to make it fit. The distance to pan is
P = (s1 - s2) / (2 sin(half FOV))
I'll leave the derivation as an exercise for the reader ;)
Show differencesHistory of post edits
#1EWClay
Posted 20 February 2013 - 04:33 PM
Ok. You have to do the trig calculation a little differently to allow for perspective.
Find the normals of the top and bottom culling planes. Find the size of the box along those normal directions, using the formula I gave previously. If the sizes are s1 and s2, then the distance is
D = (s1 + s2) / 2 sin(half FOV)
Do the same for left and right. Also, you don't want to be looking at the box centre or part of the box will be off screen. You'll need to pan the camera to make it fit. The distance to pan is
P = (s1 - s2) / 2 sin(half FOV)
I'll leave the derivation as an exercise for the reader ;)
Find the normals of the top and bottom culling planes. Find the size of the box along those normal directions, using the formula I gave previously. If the sizes are s1 and s2, then the distance is
D = (s1 + s2) / 2 sin(half FOV)
Do the same for left and right. Also, you don't want to be looking at the box centre or part of the box will be off screen. You'll need to pan the camera to make it fit. The distance to pan is
P = (s1 - s2) / 2 sin(half FOV)
I'll leave the derivation as an exercise for the reader ;)