steelflame at September 2nd, 2003 13:11 — #1
I am currently writing the code for some sort of game, which so far loads up a .3ds model/scene and allows free movement around it with mouse and arrow keys. I would like to know how to add collision detection, to prevent walking through objects etc, I have no ideas on how to do this.
Thanks for any help.
baldurk at September 2nd, 2003 13:21 — #2
Try looking into different techniques on google. The technique you should investigate depends on how accurate you want it. You COULD check down to tri-tri, but that's almost always not necessary. The most innacurate (probably) is bounding sphere. That's normally not good enough, but it might be for you. Then you should try bounding boxes. If one bounding box isn't enough, try using several boxes, one for each section of the model.
anubis at September 2nd, 2003 14:38 — #3
the topic is very broad... there are several techniques that you could apply depending on the way you are going to partition your scene, etc. i also suggest trying google.
as baldurk mentioned the basics involve some sort of bounding volume test depending on the game you want to make. also this is not opengl related so you might want to post this sort of question in the general programming forum
steelflame at September 2nd, 2003 14:52 — #4
OK thanks. I think bounding box collision detection would be good. So does this mean I have to find a way to place bounding boxes around all the solid objects in my scene? I am using opengl for the game by the way.
dk2 at September 2nd, 2003 14:59 — #5
You'll just have to store a bounding box for each object you have in the scene. Also, there are two kinds of bounding boxes:
- Axis-Aligned Bounding Boxes (somtimes abbreviated as AABB)
- Oriented Bounding Boxes (more accurate)
Axis aligned bounding boxes, as the name suggests, are always aligned to an axis (e.g. x-axis). Oriented bounding boxes can rotate, usually the same orientation of the object associated with the box.
anubis at September 2nd, 2003 17:43 — #6
i'm sorry. i didn't want to be rude. anyway, this forum normally only deals with topics directly related to opengl
baldurk at September 3rd, 2003 13:13 — #7
I wasn't really bothered about it, but I think for the sake of clarity and for people searching in the future, I'd better move it.
steelflame at September 3rd, 2003 14:05 — #8
OK thanks very much. I am much clearer now