I’m writing an asteroids remake with convex polygons used to represent the bounds of ships, asteroids, and bullets for use with collision detection. Each of these objects also has a bounding rectangle that must intersect another object’s bounding rectangle before polygon collision detection is done. The asteroids and ship must rotate and so must their bounding polygons/rectangles. I used a bit of trig to rotate the polygons, but I don’t believe I will be able to use rotated Rectangle object as I don’t have direct access to its x and y points so I can rotate them. To get around this I was thinking of using another Polygon to represent the bounding rectangle instead of a Rectangle object, but from what I hear Polygon collision detection isnt very efficient and I was wondering if using a 4 sided Polygon would be less efficient than a Rectangle for checking intersection. Obviously a rectangle is a polygon in math terms, but I’m not sure the differences between the objects. Also, Rectangle has a method for checking whether it intersects another Rectangle, but I lose this with Polygon and I can only check if one contains any of the points from another. so my questions are:
will using a 4 sided Polgyon object be slower for checking intersectio than a Rectangle object?
how can I use a Polygon for accurate collision detection, the only way I currently see is to go through and check if one Polygon contains any of the points from another polygon, this obviously isn’t completely accurate.
what is the best way to get around this issue with the rotating Rectangle bounds, do I need to create the four sided Polygon, or is there some other way this is done?
I’m doubting this, but maybe it would be better to just do pixel detection (check if two opaque pixels overlap from the two objects being checked) after bounding box detection, not sure how I would do this with with jogl…
thanks for any help.