Sign in to follow this  
ov3r_dr1v3

starting collision detection...

Recommended Posts

ov3r_dr1v3    122
Hey... I have a 3d world which i have loaded into my opengl program. All the objects in my scene are imported from .OBJ files. At this stage now im starting to think about collision detection. If I could start to get some basic collision detection up and running i'd be very happy. I think i understand the basics of how collision detection works, or this for of it anyway. Every object in my world must have a bounding box, and tests must be carried out every frame to see of any of these boxes have intersected...right? No i'm just having some trouble thinking of how to implement this. When I read in an object from an .OBJ file, should i create an invisible box around it then? If i do this i can see one problem in my situation. The folowing image shows my scene...this is loading in in one single OBJ file...so any box which bounded the whole thing would be useless?? description of your image would it be better to load in seperate models for the wall, road, sidewalk e.t.c? Any help anyone could provide would be great! I look forward ot reading some replies thanks

Share this post


Link to post
Share on other sites
h3ro    161
Hallo,

Just so you know, I don't have much experience when it comes to collision detection, so if someone tells you I'm wrong, ignore anything I said.

I dont think you need to have a bounding box, but it makes things a lot faster. As the case is in the program I'm writing I first check if there is a collision between the bounding box of the object. If there is, I do more checks to see which of the triangles of the object it hits. This is just to speed things up, as it is easier to do one check against the bounding box, than to do one check for each of the triangles for each timestep. In fact, most games only do bounding box checking I think (or have multiple bounding boxes covering their objects)

Also, you want to do the collision detection more the ones a frame, to ensure that you get a good result.

I think there is a openGL tutorial covering this (NeSh or something), but from what I remember the code is a bit messy.

Best of luck

Share this post


Link to post
Share on other sites
deviantDarren    156
hey,

You should check out the great tutorial written by Paul Nettle (http://www.gamedev.net/reference/articles/article1026.asp) on collision detection. It should provide you with all thats required to perform simple collision detection against you scene...

Hope this is helpful

Share this post


Link to post
Share on other sites
oliii    2196
Yeah, what you want is triangle-based collisions. Simplest is sphere-triangle interference.

1) for each triangles...
2) Find closest point (not just vertices) on triangle from sphere centre.
3) if that point is inside the sphere, push the sphere away from that so that the distance from the point ot the sphere centre is equal to the sphere radius.

The closest point calculation can be a bit tricky, but I've used Dave Eberly's implementation, which is both fast and pretty straight forward.

here's the example

http://members.gamedev.net/oliii/very_basic_collision.rar

The demo has extra stuff, main.cpp has the very basic algo.

Paul Nettle's stuff is good, but I'm not 100% sure it's actually right. Anyway, it's a tad more advanced, you can jump right in, it's well documented.

Share this post


Link to post
Share on other sites
Kwizatz    1392
Quote:
Original post by oliii
Paul Nettle's stuff is good, but I'm not 100% sure it's actually right.


If I remember correctly there were some issues for edge collisions, can't quite remember if it was because he didn't covered them, the algorithm just pushed the sphere back all the way out of the triangle plane or both.

Also, avoid ellipsoids and you will avoid a headache. [smile]

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