I’m wondering if anyone has an idea how to create a dynamic world map… I would love to get all the countries as vector of polygon, then redraw them in different shapes styles and positions.
After this I want to play with all them in Box2d library.…
I’ve been looking at MapThing library, has function to draw the outline as a simplified contour.
But I’ve not a clear way how to re-code it in my own to be able to manipulate them later on.
Any tips so welcome.
Are you looking for a data source for country vectors, or do you have that data already? If so, what is it / what does it look like?
I believe the three available wrappers for JBox2D are
- “Box2D for Processing”
However, I think none of the Box2D-based systems are going to work if you are hoping to import national boarder outlines as Custom Polygons.
“Convex shapes only!” (link to video at time 225)
Box2D doesn’t handle convex polygons, and very very few nations have convex boarders – most are at least partially concave. For example, even a very simple outline of the United States of America is concave on the eastern seaboard, the northern border, and the Gulf of Mexico.
So you either need a different collision system – or you need to model each national boarder as an assemblage of multiple simple convex shapes.
…yep, it looks like the thing to do is decompose into convex polygons.
Check out the toy bunny rabbit in this Phaser demo based on Box2D – there are faint lines tracing the way that it is broken down into convex shapes so that box2d can model collisions:
…and an old related project based on SVG map data import: