0 votes

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.

in Engine by (12 points)
edited by

https://github.com/godotengine/godot/issues/4826#issuecomment-336081175
based on this, you can use svg with godot 3.0.
would you try it?

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" (https://github.com/godotengine/collada-exporter) 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...

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!

1 Answer

0 votes

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:
https://gamedev.stackexchange.com/questions/92038/how-can-i-map-regions-on-a-world-map-image

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.

by (30 points)

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?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.