Sign in to follow this  

OBB Algorithms

This topic is 3150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If you aren't planning to do this at runtime, it may be easiest to rotate your model around the y axis, such that every point gets a turn to be in the x direction. Then you could keep the configuration that has the least area for an axis-aligned square. Then clamp the top and bottom to your maximum and minimum.

Optimizing beyond that is not likely to yield any benefit, but will cost significantly more.

Share this post


Link to post
Share on other sites
Granted, an AABB is faster to calculate and use, but I'm not looking to wrap my object in an AABB. I'm trying to figure out how to orient an OBB around my object so it is most optimal.

Share this post


Link to post
Share on other sites
there is, it is used by the RAPID collision detection library. It's using the covariance matrix to find the vertex distribution. It's usually best to use the convex hull of the object you try to bound, instead of the object itself (so only the vertex at the periphery of the object will affect the bounding box).

http://www.itu.dk/courses/MEP/E2006/Lectures/lectures/collision2.pdf

If you don't fancy all the maths, and want a simple solution that is very very slow, you can take the convex hull of the object you are interested in, the cente of the bounding box will be the centre of the convex hull, and each axis of the bounding box will align with either a face, an edge, or a vertex.

by aligned, I mean :

1) use face normal as an axis for the bounding box.
2) take the closest point on edge from the centre, and use direction as axis.
3) take vector(vertex - centre), and use direction as axis.

Did I say slow?

[Edited by - oliii on April 29, 2009 11:09:37 AM]

Share this post


Link to post
Share on other sites
I don't mind it being very slow, because I will calculate this only once - during loading. Rotations and Scaling can be applied to the OBB after the fact without having to recalculate the OBB.

Share this post


Link to post
Share on other sites
Quote:
Original post by RealMarkP
Granted, an AABB is faster to calculate and use, but I'm not looking to wrap my object in an AABB. I'm trying to figure out how to orient an OBB around my object so it is most optimal.


If your object is optimized for the least area when you have rotated it by R, then you can rotate the AABB by R-1. The AABB, having been rotated, is no longer axis-aligned, but has been oriented to the model.

Share this post


Link to post
Share on other sites

This topic is 3150 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this