polygons

BlitzMax Forums/BlitzMax Programming/polygons

GfK(Posted 2014) [#1]
Hello. Is there a mod somewhere that can draw filled (or not) arbitrary polygons, and handle collisions with them?


zoqfotpik(Posted 2014) [#2]
There is indeed a chunk of source on here that does filled polygons.

For checking collisions, point collision is easy-- just iterate the edges of your poly and check that the point is on the inner side of each one. For that you will need to keep your poly winding direction consistent, eg always add vertices clockwise.

For poly-poly collision, go through all the points of poly1 and do the point check above to see if a given point is in poly2. Then reverse the process and check if poly2 points are within poly 1.

There is probably a simpler way of doing it but this should work and should be fast enough if you are using some culling first, like checking intersection of bounding circles.


GfK(Posted 2014) [#3]
Just discovered after five or six years using Blitzmax, that it has a native DrawPoly function. Also Odd2D mod (which I'm also using) has DrawPolyImage.

I'm going to crawl down a hole and die of embarrassment.


Kryzon(Posted 2014) [#4]
Actually, thank you for sharing that Odd2D has those features. It might be useful for others.