Best way to import (earth) world map into single-country entities

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cpnielsen
:warning: Old Version Published before Godot 3 was released.

I have an SVG file with objects for all the countries in the world put together in a world map, and I want to use this as the basis for a game I am working on.

I know that Godot does not do SVG import at this time, but I was wondering if there were other ways to do this. I am a pretty decent programmer, albeit new to Godot, so pre-processing the data into another format before import should not be an obstacle.

Ideally, I was thinking it would be ideal if I could somehow import each country separately to appears as a Polygon2D in Godot, but I am not sure what intermediate format that would make that possible. The idea would be that I could later add a texture or some other graphics on top of the polygon (if that’s possible).

I also heard others recommend saving each country as a separate PNG or similar and importing those.

Both approaches also present the problem of positioning all the countries individually relative to each other (which would be VERY tedious by hand), something that is already done in the SVG file.

I am also open to other (simpler/better) options. In the end I just want each country to be a separate object, but it does not have to be super accurate.

Support vector images · Issue #4826 · godotengine/godot · GitHub
based on this, you can use svg with godot 3.0.
would you try it?

volzhs | 2017-10-12 10:02

Im only doing 3D in Godot so I’m a bit unaware of the 2D vector options.

In 3D you would import the SVG in blender. There are SVGs which define different objects for each country and this also stays like this in the “flat” 3D model which arrives in blender after importing.

Then you could export the map via the “better collader exporter” (GitHub - godotengine/collada-exporter: "Better" Collada exporter for Blender, orignally developed by the Godot Engine community) to a dae file.

In Godot you would import the dae into a scene and would get a scene with individual mesh nodes for each object/country.

But…
I have no Idea if these meshes can be used in any way in a 2D view. Probably 3D only…

wombatstampede | 2017-10-13 08:06

I saw a tutorial for “using 3D in 2D” somewhere, which might be relevant to this. I have previously used Unity and did something like this (import into Blender, export Mesh, import in Unity), so it might be the way to go.

Since this is all “early” stage development, I might just do a “giant PNG” export and overlay each part of the map with a polygon that works with all the clicking and targeting, and worry about specifics regarding graphics and making it nice later (the important part for now is to be able to prototype game logic and such).

Thanks for the info!

cpnielsen | 2017-10-16 09:55

:bust_in_silhouette: Reply From: Fallayn

The “easiest” way I know of (that I used successfully in the past) is to use a color mask.

So you start with a black and white map and color each country you want to with different colors. Then you load both your normal world map and the colored one.

To the user, you display the normal one. In the background you use the colored mask to differentiate the areas.

For example, if you want to see which country the mouse cursor is over, you get the cursor coordinates, and lookup what color the pixel in your colored mask is at that coordinates, then you know what country that color is.

See the first answer here:

Edit: As the commenter above said, Godot 3.0 has early support for SVG, but that is really orthogonal to your issue. I think using this way is easier then trying to mess with XML/SVG or single textures per country and trying to stitch them together. Plus, it gives you more artistic control and is easier to maintain/change as you only have to edit the mask in your favorite tool.

So, I would export the map twice, one black/white and one colorized, to seperate image files and import each image into Godot and position them correctly (overlapping)?

Then, seperately, I would have a “color lookup table” to check which country is currently being hovered / clicked / etc.

Is this correctly understood?

cpnielsen | 2017-10-12 13:29