To get a seamless texture behind a Box2D world I need to find the outline of a number of arbitrarily placed rectangles. Tricky! Please see illustration below. After a lot of tinkering and Googling this problem is beating me. Any math geniuses out there who could help?
I've now managed to get all the points of the outline, but they're in random order. Next step would be to order them in clockwise order to draw the shape. Still listening for other solutions!
With that kind of complex shape, it might be faster for box2d to process collision with them as the 4 boxes rather than the new shape?
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@sinistersoft: The boxes are individual objects in Box2D already, I'm just looking to fill the "cookie cutter" holes (actually a road) with a background that tiles nicely.
@antix: The edges should never overlap, but I find that the conversion from Rube sometimes isn't as exact as I'd like, so there are small overlaps sometimes.
Wow. I got it to work, but it makes no sense. I fill each individual rectangle with a shape with a tiled pattern. For some reason it tiles perfectly, even though the rectangles (and therefore shapes) are in arbitrary places. I shall accept this magic and move on.
Wow. I got it to work, but it makes no sense. I fill each individual rectangle with a shape with a tiled pattern. For some reason it tiles perfectly, even though the rectangles (and therefore shapes) are in arbitrary places. I shall accept this magic and move on.
Thats how shapes work. If you set your tiling pattern it automatically does that
Comments
https://deluxepixel.com
@antix: The edges should never overlap, but I find that the conversion from Rube sometimes isn't as exact as I'd like, so there are small overlaps sometimes.
In other news, I miraculously managed to find Lua code to sort the points clockwise. Initial tests appear to indicate it works! Code here: http://stackoverflow.com/Questions/6989100/sort-points-in-clockwise-order
Generally most systems breakdown concave shapes into multiple convex ones for processing (or so it seems).
Likes: totebo