|
I need to quickly find the on-screen bounding box of a given object or mesh. Do I have to iterate convert all the points to world space and compute my own?
(comments are locked)
|
|
If anyone is interested in Matt's solution, here is my implementation. Many thanks, Have pinched the fragment entire just to save me rebuilding this particular wheel
Nov 02 '12 at 02:05 PM
Duke Euphoria
...annnnd as an extension method :
Apr 07 at 02:41 AM
duke
(comments are locked)
|
|
You could get the bounding volume using Renderer.bounds, then convert those coordinates to screen coordinates. The min and max of the screen X & Y coordinates will be a bounding box. However, this is only an approximation. Because it is axis-aligned, AND because the camera angle will distort the shape further. You might end up with a box that's bigger than necessary depending on the shape. It will work better for compact, convex objects. Right, I thought of that, and passed on it for those reasons. What I'm going for is the old 'trombone' shot used by Steven Spielberg and the like, where the 'target object' stays the same size on screen, but the camera moves way back while zooming in at the same time (or vice versa). That approximation would mess a bit with the actual extent of the rendered object. I guess I should try it, but I think for my purposes it will be too distorted.
Mar 02 '11 at 12:09 AM
DaveA
Actually, this effect was invented by Alfred Hitchcock in Vertigo.
Apr 05 '12 at 02:47 PM
PatHightree
(comments are locked)
|
