# Col detect.

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?

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.

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. Hope it helps.

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.

Hehe, thanks but I’m pretty much a begginer myself.

You meant camera as a point, or the view volume defined by the camera’s clipping planes?

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.

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 "

Aaaah cool.
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

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.

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

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

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.

Fastian[/b]

[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?