PDA

View Full Version : Col detect.



RedZen
07-12-2001, 03:03 AM
Can someone please shed some light on collision detection. I get my collision detected but the way I do it is with physicall coordinates, and obviously thats crap. Basically to start off with how do you determine that the camera has colided with a polygon?

Itskata
07-12-2001, 03:54 AM
Hi!
This is not answer. I want to ask you about the moving. I don't want to move the whole scene. I want to move only one object among the others. When I use glTranslatef the whole scene is moving.

RedZen
07-12-2001, 04:10 AM
Hehehe, OK thats easy.
glPushMatrix();
glTranslatef(whatever);
glBegin(WHAT_EVER);
//
...
...
...
//
glEnd();
glPopMatrix();
By doing this you are only translating the current matrix. If glTranslatef() is within the push/pop matrix, it doesn't effect the rest of the scene. http://www.opengl.org/discussion_boards/ubb/smile.gif Hope it helps.

Itskata
07-12-2001, 04:23 AM
Oh,Thank you!
Now I understand, at last. It is good that there are such good people like you in this forum. They help to the beginners like me.

RedZen
07-12-2001, 04:28 AM
Hehe, thanks but I'm pretty much a begginer myself.

Coconut
07-12-2001, 04:52 AM
You meant camera as a point, or the view volume defined by the camera's clipping planes?

RedZen
07-12-2001, 05:02 AM
Well lets take a first person perspective.
How do you know when you walk into a wall. I know about the sphere thing, but don't understand it all that well yet. So I mean camera as in explained here. http://www.opengl.org/discussion_boards/ubb/smile.gif

Fastian
07-12-2001, 05:08 AM
From what I understand... he's talking about the camera as a point...

You can try using something like portals and BSP trees to minimize the checks needed for collision detection. They greatly reduce the amount of unnecessary checks for collision. Then maybe you could try to check for collision with only those walls that are in front of you (through BSP trees).

If you dont want to do that much work then a simple hack is ...

when drawing a vertical wall ( in the main draw loop ) check your existing point and the points of the wall. If your point is within boundaries of the wall then check your points normal of the direction that your moving in. compare it with the normal of the wall ( which should be pre calculated ) and if they are opposite then stop movement.

... this may not be a very efficient approach but you can make it more efficient by using BSP trees. Also you can add other checks if the wall in front is of a certain height then you can climb over it etc.

Hope this helps....


Fastian

"It is better to know OpenGL then to keep thinking which 3D API to start with http://www.opengl.org/discussion_boards/ubb/wink.gif"

RedZen
07-12-2001, 05:12 AM
Aaaah cool. http://www.opengl.org/discussion_boards/ubb/smile.gif
Thats actaully a good idea!
I started looking at BSP, but sheeesh, it's gonna take me a while to know it. And this is only for a small demonstration, so that other method should work cool http://www.opengl.org/discussion_boards/ubb/smile.gif

DFrey
07-12-2001, 05:14 AM
Easy, most first person perspective games implement some form of collision map. The collision map (either explicitly or procedurally) which is derived from the architectural map. The collsion map is nothing more than a set of plane segments that define the boundaries of solid (or rather blocking) objects. You simply check your new position against the collision map to see if it is allowed. And if its not, you clip the movement by the plane that is blocking the motion. The tricky part is determining which planes to test as you don't want to test all planes. You need to test only those planes that would have a chance of blocking you.

RedZen
07-12-2001, 05:17 AM
hmmmm thats a good idea too.
Yeah I suppose you can work on a radius around you, and only check for objects that fall within the radius. Heh, thanks guys. I'm gonna play tonight when I get home, make that just now, almost time http://www.opengl.org/discussion_boards/ubb/smile.gif

Fastian
07-12-2001, 05:21 AM
Thats why I told you about the hack... Read it again... forget bsp trees for now. use the vertiacl wall check in the main draw loop. i'm asking for it in the main draw loop is because you will be drawing the walls any way so you'll get the coordinates and thus you can can apply the check there and then. Also this reduces a great amount of processing since you wont need another loop just for checking the collision against the walls which will in the end be extracting the same coordinates and checking against them.

Fastian

almok
07-13-2001, 07:31 AM
Originally posted by Fastian:
Thats why I told you about the hack... Read it again... forget bsp trees for now. use the vertiacl wall check in the main draw loop. i'm asking for it in the main draw loop is because you will be drawing the walls any way so you'll get the coordinates and thus you can can apply the check there and then. Also this reduces a great amount of processing since you wont need another loop just for checking the collision against the walls which will in the end be extracting the same coordinates and checking against them.

Fastian

almok
07-13-2001, 07:49 AM
[QUOTE]Originally posted by Fastian:
[B]Thats why I told you about the hack... Read it again... forget bsp trees for now. use the vertiacl wall check in the main draw loop. i'm asking for it in the main draw loop is because you will be drawing the walls any way so you'll get the coordinates and thus you can can apply the check there and then. Also this reduces a great amount of processing since you wont need another loop just for checking the collision against the walls which will in the end be extracting the same coordinates and checking against them.

how I can know in my scene what wall hit
the light.
I can see this as a collision?