masterbooda |
Posted - May 15 2004 : 01:09:03 AM Ok......... real simple.........can anybody help me with this... I have two 4 sided polygons, all I need to know is of a method or the math needed to detect if they are overlapping...
I was using gdi32 calls for this, and even after fixing the memory leak issues........it was still to slow........I have looked high and low for articles on this and everyone is using the gdi calls and the math tutorials where well above this uneducated man's head........
Could somebody point me to something........or explain the math in layman(i'm a blithering idiot) language....... The closest article I found was on line intersection......and it doesn't work in all instances.....
Any help would be appreciated..... and I will remain calm and civil....
DaBooda out..... |
Sion |
Posted - Jul 03 2004 : 06:33:36 AM There is a very informative tutorial on how to calculate polygon collisions. The code is in C++ but ideas should be relatively clear, however it may be a bit too advanced for what you're asking for, but try and take a look. It's found here http://www.gamedev.net/community/forums/topic.asp?topic_id=251638 |
game_maker |
Posted - Jul 02 2004 : 4:43:08 PM Hi
hmmmmm ,, divide on polygon into 2 traingles
then find if any point of the other polygon is lies on any of the 2 traingles
this means you have to test point in traingle 16 times
and here is a code of point in traingle
Download Attachment: triangle.zip 3.89 KB
regards
|
Chris |
Posted - Jul 01 2004 : 03:17:59 AM Hi, DaBooda. I'm not too sure what you intend to do, but if you're looking for Pixel Perfect Collision Detect in DirectDraw, VB, then here's a tutorial i'd like to refer you to: http://rookscape.com/vbgaming/tutAS.php. This only works for 8-Bit, but in the message board there is a way of fixing it for 16-bit. For any more help, email me on: drewboy_notyou@hotmail.com. Good luck! Chris |
masterbooda |
Posted - May 16 2004 : 06:59:04 AM Thanks, those really helped....... I figured out how to cut the math in half, by not squaring the result...... thanks again..
DaBooda out... |
Brykovian |
Posted - May 16 2004 : 12:18:54 AM Are you aware of these: http://voodoovb.talosstudios.com/tutorialscollision.html
The Circles method actually allows for multiple circles per object ... and the "irregularly shaped" method is using line intersection (which you're already trying) ... but maybe these will give you other ideas to try.
-Bryk |
Sr. Guapo |
Posted - May 15 2004 : 11:11:29 PM There are all sorts of different shortcut collision detection methods. Circles are the easy, but don't usually fit well. Same with rectangles. There ae even ways to use ellipses (rather than circles), if those fit better, though I don't know how. It probably involves some complex math, however. |
masterbooda |
Posted - May 15 2004 : 11:03:13 PM Yeah that works for rectangles, but I have irregular polygons....... I was needing an actual algorithm to detect the intersection of these two.... I have been using line intersection, but it is slow and even if all I detect is just whether or not the lines intersect..... still slow......
I then switched over to using very simple circle collision... which is just one line of code..... still pretty slow..... but of course my processer is slower than my grandmother on a rainy day...
And circular collision isn't very accurate...... I was hoping to find a better algorithm... I could take this and write it in c++ and use it that way... but I'm pulling my hair out finding something...
I need something that covers all bases, that way there is no error...... Its for my dabooda2dturbo engine.....
DaBooda out... |
Sr. Guapo |
Posted - May 15 2004 : 2:55:32 PM The math isn't difficult at all, it's just a compound If statement -
If rect1.top >= rect2.bottom And rect1.bottom <= rect2.top And _ rect1.left <= rect2.right And rect1.right >= rect2.left Then End If
I think that works... And it is pretty fast as well (faster than gdi calls, anyway) |
VBBR |
Posted - May 15 2004 : 06:01:25 AM Try this article from DirectX4VB, it's for collisions in 3D but I think it can be adapter to 2D easily. |