Reproducible map generation
Posted: 06 Jul 2014 01:06
The only safe method of changing newgrf within existing scenery is to create new scenery.
Therefore, we need a method to instant generation of such scenery (with a little random effect).
My rough attempt to reproducible map generation is based on two issues:
1. generation of rivers where they are supposed to be,
2. importing landmarks (cities, objects, signs, industries etc) from external txt file.
Ad.1.
Forcing rivers to flow along adequate paths is simple - just engrave riverbeds in your heightmap.
Because 16 height levels are too small to precisely reproduce river valleys, you need to have additional data.
Even with more height level available now, river valleys are usually not well defined in original heightmaps.
If you are creating real based map, you can use GIS date for inland water, it can be found for example here:
http://www.diva-gis.org/gdata
Now we can use GIS data, if converted into bitmap, to apply as mask layer and decrease slightly brightness of the original heightmap.
Raw data of combined rivers and inland reservoirs, converted to bitmap, looks like that:
http://149.156.194.203/~mczapkie/Train/ ... lwater.png
Before you can use it to engrave riverbeds, you need to thicken rivers, because one pixel is to small to make functional riverbed.
You can use erode or dilate filter (available for GIMP and other graphic editors), depending on colour of water and background.
Dilate and erode filters are also great for removing discretisation noise from height bitmap.
Height bitmap before riverbed and lake beds engraving:
http://149.156.194.203/~mczapkie/Train/ ... 96_16c.png
and after:
http://149.156.194.203/~mczapkie/Train/ ... nd2048.png
By the way, rivers in valleys are, in my opinion, better that plain ones, because:
1. valleys itself add a subtle structure to the landscape (landscapes based on real heightmaps have usually flat lowlands due to discretisation threshold),
2, bridges over river in valley looks (and works) much better than "bumpy" one,
3. it is possible to build dock without making heap at the river bank (which is barely possible if basecosts are set to prohibit terraforming).
Even if we have heightmap with riverbeds, existing river generator does not work fine - lakes are small and located randomly, rivers are tiny and not continuous: but it can be improved by scenario import tool, described below.
Scenario import tool can import towns, industries and other objects from txt files.
You can prepare these files in text editor manually (see syntax description in second post) or use aDe converter/importer:
http://ade.se/ttd/scenario-import-tool/
which can import towns from GeoNames and prepare input text for this patch, or convert water bitmap into text (other objects also can be imported if some text editor search&replace trick are used).
Currently following additional console commands are available:
import_land
(for importing all stuff from text file into scenario editor)
expand_towns
(for expanding imported towns - if some are to small)
industry_list
object_list
(both useful to check numeric Id's)
Note: it doesn't work in standard openttd version.
You need modified version of console_cmds.cpp - you can overwrite original file and recompile whole openttd.
Alternatively you can get already compiled Win32 version.
Both files, the newest version, are located here:
http://149.156.194.203/~mczapkie/Train/ ... load/rmgp/
Detailed description of input txt files goes in next post, below.
Therefore, we need a method to instant generation of such scenery (with a little random effect).
My rough attempt to reproducible map generation is based on two issues:
1. generation of rivers where they are supposed to be,
2. importing landmarks (cities, objects, signs, industries etc) from external txt file.
Ad.1.
Forcing rivers to flow along adequate paths is simple - just engrave riverbeds in your heightmap.
Because 16 height levels are too small to precisely reproduce river valleys, you need to have additional data.
Even with more height level available now, river valleys are usually not well defined in original heightmaps.
If you are creating real based map, you can use GIS date for inland water, it can be found for example here:
http://www.diva-gis.org/gdata
Now we can use GIS data, if converted into bitmap, to apply as mask layer and decrease slightly brightness of the original heightmap.
Raw data of combined rivers and inland reservoirs, converted to bitmap, looks like that:
http://149.156.194.203/~mczapkie/Train/ ... lwater.png
Before you can use it to engrave riverbeds, you need to thicken rivers, because one pixel is to small to make functional riverbed.
You can use erode or dilate filter (available for GIMP and other graphic editors), depending on colour of water and background.
Dilate and erode filters are also great for removing discretisation noise from height bitmap.
Height bitmap before riverbed and lake beds engraving:
http://149.156.194.203/~mczapkie/Train/ ... 96_16c.png
and after:
http://149.156.194.203/~mczapkie/Train/ ... nd2048.png
By the way, rivers in valleys are, in my opinion, better that plain ones, because:
1. valleys itself add a subtle structure to the landscape (landscapes based on real heightmaps have usually flat lowlands due to discretisation threshold),
2, bridges over river in valley looks (and works) much better than "bumpy" one,
3. it is possible to build dock without making heap at the river bank (which is barely possible if basecosts are set to prohibit terraforming).
Even if we have heightmap with riverbeds, existing river generator does not work fine - lakes are small and located randomly, rivers are tiny and not continuous: but it can be improved by scenario import tool, described below.
Scenario import tool can import towns, industries and other objects from txt files.
You can prepare these files in text editor manually (see syntax description in second post) or use aDe converter/importer:
http://ade.se/ttd/scenario-import-tool/
which can import towns from GeoNames and prepare input text for this patch, or convert water bitmap into text (other objects also can be imported if some text editor search&replace trick are used).
Currently following additional console commands are available:
import_land
(for importing all stuff from text file into scenario editor)
expand_towns
(for expanding imported towns - if some are to small)
industry_list
object_list
(both useful to check numeric Id's)
Note: it doesn't work in standard openttd version.
You need modified version of console_cmds.cpp - you can overwrite original file and recompile whole openttd.
Alternatively you can get already compiled Win32 version.
Both files, the newest version, are located here:
http://149.156.194.203/~mczapkie/Train/ ... load/rmgp/
Detailed description of input txt files goes in next post, below.