Sign in to follow this  
Scottehy

Looking for some info on OBB Collision.

Recommended Posts

Alright so I've spent the past 2 days trying to figure out OBB collision. It's doing my head in as I can't really find any posts/info on the subject. Most of the stuff I've found is broken or incomplete. If anyone has any half decent links / info on the topic please share :) I'll still post up how I wanted mine done anyway incase anyone can give me a hand. Alright so I'm making a small game framework using SDL/openGL with C++. I already have all the graphics stuff and what not done. I've created a simple Matrix class that I use for holding my images rotation and on screen position. I've also wrote a Vector2 class that pretty much is the same as C#/XNA Vector2 class. Everything works great no issues at all so far except for I'm stumped how to do OBB collision. So if I was to make a new class called Player and made him nice and simple. So lets say his images is a square and it rotates. Now lets say I made two of these and wanted to check if they collide while they are both on an angle of X how would I be able to use OBB to check to see if they collide. I'm not to fusses how it's written as I'll fix it up I just want to know how I can somehow create a check for it. Example:
//Yes this would be in a class but for an example of a function so I can understand how this works.

struct OBB
{
    //Not sure what sort of values I'd need to store but I gather a position and
    //Maybe a matrix?
};

bool CheckOBBCollision(OBB& box1, OBB& box2)
{
    Check:
    {
        // return false if no collision
    }
    //return true if collision
}
Sorry if this is a bit of a length question I'm just getting frustrated with myself and making it harder. Thanks, Scott.

Share this post


Link to post
Share on other sites
Seach the internet and/or forum archives for 'obb sat' or 'obb separating axis theorem'; I would be very surprised if you weren't able to find some good references.

Note that the 2-d version of the SAT for OBBs is quite a bit simpler than the 3-d version (since there are only two axes per box and no cross-product axes, there's a total of only 4 axes that need to be checked rather than 15).

Share this post


Link to post
Share on other sites
Thanks for the reply. I searched for what you've said and come across a couple of things. Looking at something like An Oriented Bounding Box (OBB) Intersection Test (Sorry don't know how to make a hyper link on here) This just seems a really over complicated way of doing this?

In one of your posts on another thread you were talking about "oliii's tutorials" but I can't find much info on this in google. Is this something on gamedev someone has made?

Sorry for being a pain in the butt.

Thanks for your help,
Scott.

[grhodes_at_work edit - I turned the quoted URL into a hyperlink]

[Edited by - grhodes_at_work on September 11, 2009 9:43:48 AM]

Share this post


Link to post
Share on other sites
Quote:
This just seems a really over complicated way of doing this?
Nope, that's how it's done. (The alternative algorithms that I can think of right now are all even more complicated than that.)

Like I said though, the 2-d version is quite a bit less complicated. Also, the example code in the article you linked to is optimized, which makes the algorithm look more complicated than it really is.
Quote:
In one of your posts on another thread you were talking about "oliii's tutorials" but I can't find much info on this in google. Is this something on gamedev someone has made?
oliii is a forum member who has made available some code and tutorials on the SAT. Try using the forum search rather than using Google directly, and you should be able to find some links.

Share this post


Link to post
Share on other sites

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