Sign in to follow this  

Collision detection how to start ?

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

hello,
I have a problem because I have to implement a small demo with collision detection. I know A LOT about how it works, I think I would use AABB (axis aligned bounding box) BUT how should it look like in code ?

For example so that you will understand me(I use c++ + OpenGL):
I have and object and I want to check if it's colliding with anything I can check if something is in my defined box volume but how ? I have my object's coords and all the others objects' coords but how to check which of them are colliding?
Can you show me some practical example ?

Share this post


Link to post
Share on other sites
could you explain in detail what you DO know? I have implemented it myself, but what exactly DONT you know?

edit (sorry, a few edits here, not quite in my best shape):
I guess I can add some info instead of just asking...
//for horizontal check
if(a.left>b.right || a.right<b.left)return;//no collision

Share this post


Link to post
Share on other sites
I just know a lot about it in theory but I don't know how to implement it in practice. btw I have found very interesting site about collision detection (theory)
http://www.metanetsoftware.com/technique/tutorialA.html

I don't even know how to start.

Share this post


Link to post
Share on other sites
that's what I mean, you haven't really asked a question. it's just a random request for information. what is it you do not know. are you looking for performance improvements? it did not sound like it. have you implemented anything yet? it did not sound like it. give us more information, or you will end up with random information to that random question.

what is high level design?

Share this post


Link to post
Share on other sites
Ok, sooo... I haven't yet implemented anything regarding collision detection. What I am asking is how to structurise objects, how to organize them so that they will detect collisions.

For example I have came to idea like this :
I will have abstract class sprite from which all objects will derive from, then on constructor all of the objects will be pushed on the let's say vector, deque or STL list and then the collision detection funciton will first check which of the other object is in the particular checked object's range (aabb) and do the test.

Is it the right approach ? Or how does the industry standard look like ?

Share this post


Link to post
Share on other sites
The metanet N tutorials are excellent. That's how I got started with vector math and collision detection. The little ragdoll physics in N is really cool :)

It's still not clear what you are asking about though. You seem to have a good grasp already.

Yes, you would need an array or some other form of list for your sprites so that you could iterate them all. It depends on your own implementation. It could be a basic, linear array or it could be some form of hierarchical list, like a binary, quad or octree. It could be a linked list. Or some combination of.

Share this post


Link to post
Share on other sites

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