Search Unity

Bounding boxes (for compound objects)

Discussion in 'Scripting' started by Dougxing, Mar 28, 2008.

  1. Dougxing

    Dougxing

    Joined:
    Mar 13, 2008
    Posts:
    90
    Is there any one-step way to get a bounding box for a hierarchy of objects?
    The best method we could come up with is going through the bb's of each object in the hierarchy and keeping track of the outermost surfaces, then creating a bb from those, but that's kind of tedious. It's also not immediately clear to me how one would align the centers of the bb and the objects.
     
  2. AngryAnt

    AngryAnt

    Keyboard Operator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    If you're going to cycle through the hierarchy then you could calculate the max and min corner as you go along.

    That'd give you the two most extreme corners in all child bounding boxes and based on these co-ordinates you can calculate the box.
     
  3. David-Helgason

    David-Helgason

    Moderator

    Joined:
    Mar 29, 2005
    Posts:
    1,104