Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [Linux][c][c++]Dwarf Fortress Heightmap Translator  (Read 1275 times)

DonPerotti

  • Bay Watcher
    • View Profile
[Linux][c][c++]Dwarf Fortress Heightmap Translator
« on: August 03, 2020, 09:14:25 pm »

So, this "utility" is something that spun out of my desire to have a world with a central ocean surrounded by a good-aligned jungle, because i can't tell the game directly which squares i want to be good or evil aligned, someone suggested that i do that by carefully adjusting the size of the generated biomes by PWDF, but since PWDF doesn't allow for any "Hard coding" other than a simple brush (you can't input a heightmap for anything other than actual height) i decided to make this program, as painting pixel by pixel on a 257x257 implies painting 66049 by hand(instead of using a bucket tool, and the big brush wasn't much more helpfull either).

The results of this whole experiment were... mixed, while it did allow me to relatively quickly design the world i wanted with regions that did not mix, 257x257 is such a big map that almost all regions will end up being more than a 100 tiles in size, which defeats the whole purpose of this, as creating small and medium regions that do not cross with each other on such a large map is about as much work as painting them by hand on PWDF.

It was a lot more useful on smaller worlds (65x65), as regions tended to be all medium (close to 90 tiles but less than a 100).

So after going down this rabbit hole and back, I figured I'd share it with everyone, in case there's any madman who would need such an specific tool as well.

While the program is allegedly made with c++, it really just a c program with a c++ library, I initially intended to make it a proper c++ program but gave up midway and wound but with this frankestein, you may be wondering why I chose c of all languages to make this or why it doesn't have any visual interface, and the answer is because that's what I had available, I only know how to code basic c and some concepts of c++, and I learned to do all that with the Linux console.

You'll have to download the source code from github and run make to generate the executable, as c "executables" are not really portable.
You'll also need g++, this is the version that I used, anything above (and I figure a good deal below) that should work: g++ (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411
While you don't need to download it, as it is already bundled with the source code, I would like to share a link to the library that made this way easier (and arguably possible at all): http://easybmp.sourceforge.net/

Download: https://github.com/CrainFartor/Dwarf-Fortress-Heightmap-Translator/releases/

Once you use it, you'll have to manually copy the preset values from the output file to your world_gen.txt, you can further modify this preset with PWDF, so long as you don't override the presets you've generated on this program with PWDF maps.

Instructions:
Spoiler (click to show/hide)

How to calculate what values to assign to each color:
Spoiler (click to show/hide)

Usefull values for generating biomes:
Spoiler (click to show/hide)

Example results:
Here is an example of a Biome mode input with "sharp" colors:
Spoiler (click to show/hide)

And here is the same input, after we blur it a bit to avoid such sharp changes:
Spoiler (click to show/hide)
« Last Edit: August 03, 2020, 09:33:16 pm by DonPerotti »
Logged
This is a C++ program, all craftsmanship is of the shoddiest quality, it menaces with poor code and lack of documentation: Dwarf Fortress Heightmap Translator: https://github.com/CrainFartor/Dwarf-Fortress-Heightmap-Translator

(it takes a .bmp and outputs a .txt with a preset for one of the values of world gen)