Jump to content
• Advertisement

# Generating lines of an OBB

This topic is 4242 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

I have an OBB and stored the 3 directions and extents. what's a fast way to generate all the edges? (for collision detection) Thanks.

#### Share this post

##### Share on other sites
Advertisement
Quote:
 Original post by daniel_i_lI have an OBB and stored the 3 directions and extents. what's a fast way to generate all the edges? (for collision detection)Thanks.
One of the key points that was made in your previous thread on OBB collision detection was that, in general, you do not need nor want to handle OBB collision detection in terms of individual features (vertices, edges, faces).

So I will ask, why do you think you need the edges for collision detection? What are you going to do with them exactly? I suspect that you're still misunderstanding some aspect of the SAT, and your answers to these questions may help point out the nature of the misunderstanding.

In summary, you should really only need the actual box edges for debug rendering. If you're constructing them for the purpose of collision detection, then you're probably doing something wrong.

#### Share this post

##### Share on other sites
Thanks, the reason that i thought that i needed to generate the edges (and faces) of the rigid bodies was to find the exact collision points. for example, lets say that i detected a collision with the SAT and have the collision normal and depth. then i used the collision normal to find the collision type (face-face, face-edge, corner-face...) and found that i have a face-edge collision. don't i have to get the corners of the face and the endpoints of the edge so that i can clip the edge to the face and get the two collisio points? this has been confusing me as i got up to that part of the implementation - as you sudgested in another post, the only information that i store for the geometry of an OBB are the extents (the directions are stored in the orientation matrix), together with the directions and extents i could implement all the steps of the SAT collision detection except for this last step. how can i get the collision points of, for example, a face-edge collision if i only have the extents and directions?
Thanks for your help!

#### Share this post

##### Share on other sites
Quote:
 Original post by daniel_i_lThanks, the reason that i thought that i needed to generate the edges (and faces) of the rigid bodies was to find the exact collision points. for example, lets say that i detected a collision with the SAT and have the collision normal and depth. then i used the collision normal to find the collision type (face-face, face-edge, corner-face...) and found that i have a face-edge collision. don't i have to get the corners of the face and the endpoints of the edge so that i can clip the edge to the face and get the two collisio points? this has been confusing me as i got up to that part of the implementation, as you sudgested in another post, the only information that i store for the geometry of an OBB are the extents (the directions are stored in the orientation matrix), together with the directions and extents i could implement all the steps of the SAT collision detection except for this last step. how can i get the collision points of, for example, a face-edge collision if i only have the extents and directions?Thanks for your help!
Ah, I see :) In reading your post I jumped to the conclusion that you intended to perform the collision detection itself using the box features. My mistake - sorry about that.

So, now I'll try to be more helpful. The eight corners of the OBB can be computed as:
corner = C +/- e[0]*A[0] +/- e[1]*A[1] +/- e[2]*A[2]
Where C is the box center, e[] are the extents, and A[] are the axes. The eight different corners correspond to the eight permutations of +'s and -'s.

Once you have the corners, you can compute the edges and faces. There are some other ways these features can be represented and computed, but the above method is probably a good place to start.

#### Share this post

##### Share on other sites
Thanks, i had an idea of what to do that's similar to what you wrote but i'm not sure if it's correct, here it is:

To get the corners of a face using the normal of the face:
in this case i called the normal of the face Normal:) and the other two directions of the OBB Right and Up, then i multiplied all these vectors (now they're nomalized because i take them from the orientation matrix which is reorthogonalized each frame) by their respective extents. then the 4 corners of the box are: (Pos is the position of the box)
Pos + Normal +/- Right +/- Up

To get the endpoints of an edge using a vector normal to the edge (Normal):
in this case there are the three directions multiplied by the respective extents, i call the one in the direction of the edge EdgeDirection and the other two Right and Up. now i find the dot product of Right with the Normal vector (the Normal vector is assumed to not be perpendiculer to any of the other directions - otherwise it would be a face collision, it is also going in the direction from the edge to the center of the OBB, not away from it)- if it's bigger than zero then i multipy Right by -1 (reverse it), then i do the same with Up.
This leaves me with two vector, Up and Right that when added to the position of the OBB come to the middle of the edge that i'm looking for.
Then the two endpoints are:
Pos + Right + Up +/- EdgeDirection.

are these two methods correct and reasonably fast? if something isn't clear please let me know.
Thanks!

#### Share this post

##### Share on other sites

• Advertisement

### Announcements

• Advertisement

• ### Popular Now

• 10
• 17
• 9
• 13
• 41
• Advertisement
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!