Simple Polygon Swept collsion Detection

BlitzMax Forums/BlitzMax Programming/Simple Polygon Swept collsion Detection

Rico(Posted 2008) [#1]
Hi, I am now intending to use a polygonal collision system for my game. I really want the following

1) a rock solid collsion system so that no object can EVER pass though another object or the background, no matter how fast it moves
2) I want to use any polygonal shape for my objects and background. I'd also like curves if possible.
3) I also want objects to bounce off each other, and to move down slopes.
4) Objects don't need to rotate or tip in my game

I have never done anything like this before, but I really want to understand it and do at least this much myself before I look at using a physics engine for future games. I have been reading a bit on Seperating axis theorems for collision detection and response, and I am starting to understand it. I have read the theory on swept collsion - which I really need - but I am not sure how to actually do it in practice.
Also there is a swept system where you solve 2 equations (representing each object to find the exact place they intersect). I read the theory on this but I don't know how to solve the 2 equations in my program! - the actual code I need to write. Please help.
Can anyone give my actual source code (in Blitz language of course) that does what I require. Even something that I have to pay for would be good. But I need source code because I want to learn it myself too :) I would be happy with just a fairly simple polygonal collision system that is 100% rock solid.

Thank you very much - Rico


tonyg(Posted 2008) [#2]
I would start here


z80jim(Posted 2008) [#3]
tony I think you messed up somewhere with that code lol.

for simple rock solid collision in general just have your loop set up in the following order.

movement input
move
check for collision
move just outside of object
draw

Your objects WILL collide, but the user will not see that because the program will correct it before drawing.


tonyg(Posted 2008) [#4]
tony I think you messed up somewhere with that code lol.


Yeah, missed a '/' off the front : My how we laughed!


Rico(Posted 2008) [#5]
Thanks TonyG. Those functions look great for collison checking and the like between polygons. Only thing is I don't really want to do a collision check for every pixel an object moves I wanted to represent the movement of each object as an equation and then solve both equations to find at what time the objects will collide. And then get the x and y coords of the objects at this point. This would be good because the objects will never actually overlap then,so I don't have to worry about moving them apart. I suppose then I need to some jiggery-pokery (technical term) to calculate surface normals, and create the appropriate bounce and friction ( I reckon I could do this if I read up on it a bit more).
As I said I've never done this before and Im not great at Math so all the help I can get the better!
Oddball's functions include one to see if two lines intersect but it only returns TRUE or FALSE.

Appreciate the help. Thanks again - Rico

BTW what physics engines do people use with Blitz. I checked out the Chipmunk Physics module but on the webpage it said that it didn't do swept collisions (which is what I want). Do you get source code with them? My games may not use *proper* physics so it would be good to fiddle with them.