Entradas

Mostrando entradas de marzo, 2016

Imagine there's no countries

Imagen
Hello everyone! I know, it's been months since the last time I wrote in this dev blog... But I haven't been staring at the ceiling or watching the grass grow, I made a lot of progress in Winds of Trade, I swear! I'll write about that later, though.

Today I want to share with all of you how I implemented the algorithm to put labels for the procedurally generated countries on the map.

First of all, let's start with the finished result so you can have a notion of what I'm talking about:


So, basically I have a two-dimensional array where I store what country owns each square in the map and I had to generate labels for them. I wanted to achieve something similar to what Europa Universalis 4 does but using straight labels instead of curved ones in order to make implementation easier. So I needed an algorithm capable of:

1) Identifying every contiguous region in the map.
2) Finding the best orientation (rotation) for the label.
3) Deciding where to place the label.
4) Cho…