🔒 Locked
Collision Detection..
Advertisement
Original Post
Ah, I was planning on writing some collision detection for the 3d world in Tut 10, based on some old code a friend had done a while back. Basically the code just checked to see if a point was going to be inside of a polygon. It guessed your next place you may move, and then checked if the point would be inside the polygon, and wouldn''t let you move if it was. But I realized these "walls" etc in the 3d world are just a flat surface, in fact, two flat triangles(but thats not important), and the collision detection would only work if the next place of "movement" were to be exactly on the point in space where the wall is drawn across, otherwise you could just walk right through it. it may work if the walls were solid, but if you wanted to have an empty area behind you, you would be SoL yes?
Well anyway, I was just curious if anyone had any ideas as to how to handle collision detection with the flat surfaces in the 3d world.
the easiest way to do it would be to use 3d math. I can''t get the hang of it myself though. You could use a library like ColDet (http://photoneffect.com/coldet) or you could do what I did:
have a line sticking directly in front of the user. check to see if the line''s end and start are on different sides of a wall. The only drawback is that if someone comes in at a corner he can walk through it. I''m waiting for the OpenGL game programming book to be delivered. It has a section on collision detection so I would get that if you have the money (
)
baldurkarlsson
have a line sticking directly in front of the user. check to see if the line''s end and start are on different sides of a wall. The only drawback is that if someone comes in at a corner he can walk through it. I''m waiting for the OpenGL game programming book to be delivered. It has a section on collision detection so I would get that if you have the money (
baldurkarlsson
I think you have got the way that the collision detection is handled all wrong..
Think about it like this:
Imagine that the whole plan of the the level is the polygon .. and the egdes of the polygon are the walls. Well whenever the player moves the collision detection routine checks to see if the payers position is in the polygon (i.e. inside the walls) or oustide the polygon (i.e. outside the walls). if youre inside no need to do anything, if youre outside then move the player back inside (..somehow)..
I think thats how it works.. i read this in an article on gamasutra and it said that doom used this method of keeping the player within the confines of the level (i think..umm been a while since i read it).
anyway .. thats my 2 cents..
Collision detection is not that hard, honestly. Im sure that if you put it down clearly on paper and stare at it a bit, you''ll be able to apply some very basic math to get it to do what you want. This is why you should have a basic plan of the engine you''re designing, because without a plan, implementing collision detection can be a massive mess.
Think about what you want your engine to do, what objects you want it to draw and where and how you want to store the object''s data such as verticies, texture-coordinates and normals. Thus every object can be retrieved for testing against collisions whenever you want.
Im sure you can find plenty of sources describing ways in which you may plan ahead the making of a computer program on the internet. Its part of every program lifecycle - it always begins with the design.
Im sure you can find plenty of sources describing ways in which you may plan ahead the making of a computer program on the internet. Its part of every program lifecycle - it always begins with the design.
Hi,
I think collision detection as a whole is a complicated topic. However, you don''t need moving triangle - moving triangle intersection, but rather simple bounding boxes and the like. At least you can start with that.
You method can be easily extended in the following manner: Take the players'' current position, and his predicted next position, construct a line between those 2 points. Now, if the line intersects any of the planes in your world, check whether it also hits the associated polygon. If so, he collided. That is the technique described in the flipcode tutorial Bump Lens mentioned.
I have once implemented that, it works, but it was somewhat buggy, probably my fault. Its easy, however.
The anti-planes method (a plane for each edge) is rather solid and easy, but takes a lot of memory (4 Planes for each polygon). There are numerous techniques to do this, however. Some are more computationally expensive, others in terms of memory. Some also can cause headache
Perhaps you could try to write a simple BSP-Compiler. That is hard task for beginners, but its a great exercise I think.
I think collision detection as a whole is a complicated topic. However, you don''t need moving triangle - moving triangle intersection, but rather simple bounding boxes and the like. At least you can start with that.
You method can be easily extended in the following manner: Take the players'' current position, and his predicted next position, construct a line between those 2 points. Now, if the line intersects any of the planes in your world, check whether it also hits the associated polygon. If so, he collided. That is the technique described in the flipcode tutorial Bump Lens mentioned.
I have once implemented that, it works, but it was somewhat buggy, probably my fault. Its easy, however.
The anti-planes method (a plane for each edge) is rather solid and easy, but takes a lot of memory (4 Planes for each polygon). There are numerous techniques to do this, however. Some are more computationally expensive, others in terms of memory. Some also can cause headache
Perhaps you could try to write a simple BSP-Compiler. That is hard task for beginners, but its a great exercise I think.
http://www.codercorner.com/Opcode.htm
========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
========================
Leyder Dylan
http://ibelgique.ifrance.com/Slug-Production/
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement