2
\$\begingroup\$

How can I generate AABB, OOBB and Sphere from a polygon soup, where the bounding volumes are defined as follows:

  • AABB should be specified by min(x,y,z) max(x,y,z)
  • OOBB should be specified by min(x,y,z) max(x,y,z) and a quaternion for rotation
  • Sphere is specified as position(x,y,z) and radius
\$\endgroup\$
5
  • \$\begingroup\$ OBB cannot be specified by min and max. \$\endgroup\$
    – concept3d
    Commented Nov 16, 2013 at 13:40
  • \$\begingroup\$ @concept3d How can they be specified then? \$\endgroup\$
    – Soapy
    Commented Nov 16, 2013 at 14:00
  • \$\begingroup\$ OBB are bounding boxes that are oriented with the object. That means you'll need to define an orientation for your soup. It could be the same as the AABB to start with. Or it could be defined by some other rules, like the direction from the average center to the vertex density center. Totally up to you. \$\endgroup\$
    – House
    Commented Nov 16, 2013 at 18:22
  • \$\begingroup\$ @Byte56 So the orientation could be represented by a quaternion? \$\endgroup\$
    – Soapy
    Commented Nov 16, 2013 at 19:06
  • \$\begingroup\$ Yes. OOBB is similar to a AABB except it rotates with the object. So when the object is at the "default" position, or its local axis is aligned to that of the global axis, the OOBB and AABB are the same bounds. You need to have the rotation defined if you want to get the OOBB. You can do that with a quaternion. \$\endgroup\$
    – House
    Commented Nov 16, 2013 at 19:13

1 Answer 1

3
\$\begingroup\$

Iterate through your soup and collect the following information:

  • Per vertex:
    • Maximum and Minimum x, y and z values

Something like:

for each polygon in soup
    for each vertex in polygon
        if vertex.x > maxX
           maxX = vertex.x
        if vertex.x < minX
           minX = vertex.x

        // and so on for y and z

sphereCenter = minX + (maxX-minX)/2, minY + (maxY-minY)/2, minZ + (maxZ-minZ)/2 
sphereRadius = max((maxX-minX)/2,(maxY-minY)/2,(maxZ-minZ)/2)
boundMin = minX, minY, minZ
boundMax = maxX, maxY, maxZ

That gives you both the bounding sphere and the AABB bounding box.

In order to get an OOBB you'll need some kind of orientation information for the soup. Then you'll have to find the center of the soup, negate the orientation information by rotating all the vertices in the soup around the common center. Now you have an axis aligned soup. You can perform the same steps as above, then rotate everything (including the eight corners of the axis aligned bounding box) back around the common center.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ That will definitely get you a bounding sphere, though not necessarily the smallest one. If you want to get fancy, have a look at en.wikipedia.org/wiki/Smallest-circle_problem \$\endgroup\$ Commented Nov 20, 2013 at 23:30
  • \$\begingroup\$ That's true. It'll probably get close enough for this problem, but thanks for the link that's an interesting topic. \$\endgroup\$
    – House
    Commented Nov 20, 2013 at 23:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .