PDA

View Full Version : Collision Detection! Help me please



I_NeedHelp
01-21-2003, 06:35 AM
I'm only a begginner first off and i posted this question in the begginner section aswell but i said to myself, "who better to ask about an advanced subject than advanced people http://www.opengl.org/discussion_boards/ubb/smile.gif" Anyway, i've made a bit of a hill but i can walk through it. The area around d hill is flat and i was able to avoid going through the ground by just keeping an eye on the height i was at:
if (height < 3)
height = 3;

But now i have a hill which complicates tings. I was lookin at a heap of collision detection tutorials on a bunch of sites and i find myself losing my sanity looking at them, which is why i turned to u experts (i'm hoping flattery will get me something useful instead of being rebuked 4 being in an advanced forum http://www.opengl.org/discussion_boards/ubb/biggrin.gif) The tutorials tell me to divide up the "world" into sections and test for collisions with these sections. So my question to you fine people (does he ever stop with the flattery) is how do i divide up my world. the world is flat as a pancake besides this hill. the hill is the only ting i need to check for collisions. so i presume there's no point dividing the whole world up????? I also don't need to no much about the collision except that it has happened cos i want to just crash (and i don't need any info about d collision to do this).
One reply i got was about a bounding box which includes the whole mountain. It seems a bad idea to me cos if i go within 100 feet of the hill, i'll crash in mid air! I want to avoid this method (unless i'm wrong about mid-air collisions??) so i need to find out how to split up the area around my hill and then check it for collisions.

Some code would be great if it's not too much to ask http://www.opengl.org/discussion_boards/ubb/wink.gif

[This message has been edited by I_NeedHelp (edited 01-21-2003).]

[This message has been edited by I_NeedHelp (edited 01-21-2003).]

Coriolis
01-21-2003, 08:06 AM
Code is too much to ask, and flattery usually puts people off (or me at least).

The guy who suggested the bounding box didn't mean for that to be your whole test, just your quick first test. Collision detection is all about doing fast cheap inaccurate tests before doing slow expensive accurate tests. If you are outside the bounding box, you know you didn't hit the hill; if you are inside the bbox, you need to do more checks.

This really is an inappropriate place to ask such a question, since it is not an advanced opengl topic. You'd probably have better luck at the discussion forums at flipcode www.flipcode.com (http://www.flipcode.com) .

rgpc
01-21-2003, 03:02 PM
There is also the very well known Quake 2 source which is freely downloadable from id software's web site...

jwatte
01-21-2003, 04:48 PM
OPCODE is a collision engine which supports a number of useful queries, and is freely available.

Other words to search for are MAGIC or RAPID.

Last: this is an OpenGL board, not a collision detection board. OpenGL has nothing to do with collision detection.

rgpc
01-21-2003, 04:51 PM
Originally posted by jwatte:
Last: this is an OpenGL board, not a collision detection board. OpenGL has nothing to do with collision detection.

Gee, you've said that before... http://www.opengl.org/discussion_boards/ubb/smile.gif

I'm beginning to think that this list should have a "Sticky" message (ie. one that stays at the top of the list like on some other boards I've seen) that describes what is and isn't appropriate, like on the GDAlgorithms mailing list... (And someone with the ability to delete OT msgs...)

I_NeedHelp
01-22-2003, 12:55 AM
Ouch! That message thing is a good idea. I assumed that a question about collision detection would be acceptable. I thought i was taking my life in2 my hands by posting in a advanced forum, i didn't realise there would be a problem with the topic. Anyway, thanks for your comments (they are fair i think)
To whom it concerns, some indication about whats off topic would be a nice addition. Now mayb there is one, i can't c it dough so mayb put it somewhere it will be noticed.

[This message has been edited by I_NeedHelp (edited 01-22-2003).]

HamsterofDeath
01-22-2003, 03:43 AM
be clever.
you need about 10 calculations for this problem - no whiles, no fors, not a single loop.

put your map's height into an array[x][y], insert your position there, and u know your height.
if you are between 4 heightpoints, interpolate.

i can post a pseudo-code later, if you want

[This message has been edited by HamsterofDeath (edited 01-22-2003).]

I_NeedHelp
01-22-2003, 05:49 AM
Please post the pseudocode because i don't quite understand what you are saying. Thanks in advance.