A quick way to detect polygon collision... | |

masterbooda | 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..... |

VBBR | Try [url="http://216.5.163.53/DirectX4VB/Tutorials/DirectX8/GR_Collision3D.asp"]this[/url] article from DirectX4VB, it's for collisions in 3D but I think it can be adapter to 2D easily. |

Sr. Guapo | The math isn't difficult at all, it's just a compound If statement - [code] If rect1.top >= rect2.bottom And rect1.bottom <= rect2.top And _ rect1.left <= rect2.right And rect1.right >= rect2.left Then 'Code End If [/code] I think that works... And it is pretty fast as well (faster than gdi calls, anyway) |

masterbooda | 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 | 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. |

Brykovian | Are you aware of these: [url]http://voodoovb.talosstudios.com/tutorialscollision.html[/url] 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 |

masterbooda | Thanks, those really helped....... I figured out how to cut the math in half, by not squaring the result...... thanks again.. DaBooda out... |

Chris | 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 |

game_maker | 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: [url="http://www.vbgamer.com/msgboard/uploaded/game_maker/200472164233_triangle.zip"][img]icon_paperclip.gif[/img]triangle.zip[/url]3.89 KB regards [:)] |

Sion | 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 |