maps4fs 1.2.4__tar.gz → 1.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {maps4fs-1.2.4 → maps4fs-1.5.0}/PKG-INFO +68 -35
  2. {maps4fs-1.2.4 → maps4fs-1.5.0}/README.md +66 -34
  3. maps4fs-1.5.0/maps4fs/__init__.py +13 -0
  4. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/background.py +27 -29
  5. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/component.py +80 -24
  6. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/config.py +1 -1
  7. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/dem.py +11 -13
  8. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/game.py +1 -1
  9. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/grle.py +18 -14
  10. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/i3d.py +192 -35
  11. maps4fs-1.5.0/maps4fs/generator/map.py +372 -0
  12. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/texture.py +108 -34
  13. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs.egg-info/PKG-INFO +68 -35
  14. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs.egg-info/requires.txt +1 -0
  15. {maps4fs-1.2.4 → maps4fs-1.5.0}/pyproject.toml +2 -1
  16. {maps4fs-1.2.4 → maps4fs-1.5.0}/tests/test_generator.py +54 -57
  17. maps4fs-1.2.4/maps4fs/__init__.py +0 -4
  18. maps4fs-1.2.4/maps4fs/generator/map.py +0 -160
  19. {maps4fs-1.2.4 → maps4fs-1.5.0}/LICENSE.md +0 -0
  20. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/__init__.py +0 -0
  21. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/generator/qgis.py +0 -0
  22. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/logger.py +0 -0
  23. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/toolbox/__init__.py +0 -0
  24. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/toolbox/background.py +0 -0
  25. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs/toolbox/dem.py +0 -0
  26. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs.egg-info/SOURCES.txt +0 -0
  27. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs.egg-info/dependency_links.txt +0 -0
  28. {maps4fs-1.2.4 → maps4fs-1.5.0}/maps4fs.egg-info/top_level.txt +0 -0
  29. {maps4fs-1.2.4 → maps4fs-1.5.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 1.2.4
3
+ Version: 1.5.0
4
4
  Summary: Generate map templates for Farming Simulator from real places.
5
5
  Author-email: iwatkot <iwatkot@gmail.com>
6
6
  License: MIT License
@@ -22,6 +22,7 @@ Requires-Dist: trimesh
22
22
  Requires-Dist: imageio
23
23
  Requires-Dist: tifffile
24
24
  Requires-Dist: pympler
25
+ Requires-Dist: pydantic
25
26
 
26
27
  <div align="center" markdown>
27
28
  <a href="https://discord.gg/Sj5QKKyE42">
@@ -44,6 +45,7 @@ Requires-Dist: pympler
44
45
  <a href="#Overview-image">Overview image</a><br>
45
46
  <a href="#DDS-conversion">DDS conversion</a> •
46
47
  <a href="#Advanced-settings">Advanced settings</a> •
48
+ <a href="#Expert-settings">Expert settings</a> •
47
49
  <a href="#Resources">Resources</a> •
48
50
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a><br>
49
51
  <a href="#Special-thanks">Special thanks</a>
@@ -60,7 +62,8 @@ Requires-Dist: pympler
60
62
  [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
61
63
  [![Build Status](https://github.com/iwatkot/maps4fs/actions/workflows/checks.yml/badge.svg)](https://github.com/iwatkot/maps4fs/actions)
62
64
  [![Test Coverage](https://api.codeclimate.com/v1/badges/b922fd0a7188d37e61de/test_coverage)](https://codeclimate.com/github/iwatkot/maps4fs/test_coverage)
63
- [![GitHub Repo stars](https://img.shields.io/github/stars/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs/stargazers)
65
+ [![GitHub Repo stars](https://img.shields.io/github/stars/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs/stargazers)<br>
66
+ [![Lines of code](https://tokei.rs/b1/github/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs)
64
67
 
65
68
  </div>
66
69
 
@@ -71,7 +74,9 @@ Requires-Dist: pympler
71
74
  🌿 Automatically generates decorative foliage 🆕<br>
72
75
  🌲 Automatically generates forests 🆕<br>
73
76
  🌊 Automatically generates water planes 🆕<br>
77
+ 📈 Automatically generates splines 🆕<br>
74
78
  🌍 Based on real-world data from OpenStreetMap<br>
79
+ 🗺️ Supports [custom OSM maps](/docs/custom_osm.md)<br>
75
80
  🏞️ Generates height map using SRTM dataset<br>
76
81
  📦 Provides a ready-to-use map template for the Giants Editor<br>
77
82
  🚜 Supports Farming Simulator 22 and 25<br>
@@ -79,7 +84,6 @@ Requires-Dist: pympler
79
84
  📄 Generates scripts to download high-resolution satellite images from [QGIS](https://qgis.org/download/) in one click<br>
80
85
  📕 Detailed [documentation](/docs) and tutorials <br>
81
86
  🧰 Modder Toolbox to help you with various tasks <br>
82
-
83
87
  <p align="center">
84
88
  <img src="https://github.com/user-attachments/assets/cf8f5752-9c69-4018-bead-290f59ba6976"><br>
85
89
  🌎 Detailed terrain based on real-world data.<br><br>
@@ -93,6 +97,8 @@ Requires-Dist: pympler
93
97
  🌲 Automatically generates forests.<br><br>
94
98
  <img src="https://github.com/user-attachments/assets/cce7d4e0-cba2-4dd2-b22d-03137fb2e860"><br>
95
99
  🌊 Automatically generates water planes.<br><br>
100
+ <img src="https://github.com/user-attachments/assets/0b05b511-a595-48e7-a353-8298081314a4"><br>
101
+ 📈 Automatically generates splines.<br><br>
96
102
  <img src="https://github.com/user-attachments/assets/80e5923c-22c7-4dc0-8906-680902511f3a"><br>
97
103
  🗒️ True-to-life blueprints for fast and precise modding.<br><br>
98
104
  <img width="480" src="https://github.com/user-attachments/assets/1a8802d2-6a3b-4bfa-af2b-7c09478e199b"><br>
@@ -110,14 +116,7 @@ Requires-Dist: pympler
110
116
  ## Quick Start
111
117
  There are several ways to use the tool. You obviously need the **first one**, but you can choose any of the others depending on your needs.<br>
112
118
  ### 🚜 For most users
113
- **Option 1:** Open the [maps4fs](https://maps4fs.streamlit.app) on StreamLit and generate a map template in a few clicks.<br>
114
- <i>Note, that StreamLit community hosting has some limitations, such as: <br>
115
- 1. Maximum map size is 4096x4096 meters. <br>
116
- 2. Advanced settings are disabled. <br>
117
- 3. Texture dissolving is disabled (they will look worse). </i><br>
118
-
119
- If you run the application locally, you won't have any of these limitations and will be able to generate maps of any size with any settings you want and nice looking textures.<br>
120
- So, jump to [Docker version](#option-2-docker-version) to launch the tool with one command and get the full experience.<br>
119
+ **Option 1:** Open the [maps4fs](https://maps4fs.xyz) and generate a map template in a few clicks.<br>
121
120
 
122
121
  ![Basic WebUI](https://github.com/user-attachments/assets/52f499cc-f28a-4da3-abef-0e818abe8dbe)
123
122
 
@@ -165,13 +164,13 @@ Don't know where to start? Don't worry, just follow this [step-by-step guide](do
165
164
 
166
165
  ## How-To-Run
167
166
 
168
- ### Option 1: StreamLit
169
- 🟢 Recommended for all users.
167
+ ### Option 1: Public version
168
+ 🟢 Recommended for all users.
170
169
  🛠️ Don't need to install anything.
171
- 🗺️ Supported map sizes: 2x2, 4x4 km.
172
- ⚙️ Advanced settings: disabled.
173
- 🖼️ Texture dissolving: disabled.
174
- Using the [StreamLit](https://maps4fs.streamlit.app) version of the tool is the easiest way to generate a map template. Just open the link and follow the instructions.
170
+ 🗺️ Supported map sizes: 2x2, 4x4, 8x8 km.
171
+ ⚙️ Advanced settings: enabled.
172
+ 🖼️ Texture dissolving: enabled.
173
+ Using the public version on [maps4fs.xyz](https://maps4fs.xyz) is the easiest way to generate a map template. Just open the link and follow the instructions.
175
174
  Note: due to CPU and RAM limitations of the hosting, the generation may take some time. If you need faster processing, use the [Docker version](#option-2-docker-version).<br>
176
175
 
177
176
  Using it is easy and doesn't require any guides. Enjoy!
@@ -258,18 +257,12 @@ Tools are divided into categories, which are listed below.
258
257
 
259
258
  ## Supported objects
260
259
  The project is based on the [OpenStreetMap](https://www.openstreetmap.org/) data. So, refer to [this page](https://wiki.openstreetmap.org/wiki/Map_Features) to understand the list below.
261
- - "building": True
262
- - "highway": ["motorway", "trunk", "primary"]
263
- - "highway": ["secondary", "tertiary", "road", "service"]
264
- - "highway": ["unclassified", "residential", "track"]
265
- - "natural": ["grassland", "scrub"]
266
- - "landuse": "farmland"
267
- - "natural": ["water"]
268
- - "waterway": True
269
- - "natural": ["wood", "tree_row"]
270
- - "railway": True
271
-
272
- The list will be updated as the project develops.
260
+
261
+ You can find the active schemas here:
262
+ - [FS25](/data/fs25-texture-schema.json)
263
+ - [FS22](/data/fs22-texture-schema.json)
264
+
265
+ Learn more how to work with the schema in the [Texture schema](#texture-schema) section. You can also use your own schema in the [Expert settings](#expert-settings) section.
273
266
 
274
267
  ## Generation info
275
268
  The script will generate the `generation_info.json` file in the `output` folder. It is split into different sections, which represent the components of the map generator. You may need this information to use some other tools and services to obtain additional data for your map.<br>
@@ -420,6 +413,10 @@ Let's have a closer look at the fields:
420
413
  - `priority` - the priority of the texture for overlapping. Textures with higher priorities will be drawn over the textures with lower priorities.
421
414
  ℹ️ The texture with 0 priority considers the base layer, which means that all empty areas will be filled with this texture.
422
415
  - `exclude_weight` - this is only used for the forestRockRoots texture from FS25. It just means that this texture has no `weight` postfix, that's all.
416
+ - `usage` - the usage of the texture. Mainly used to group different textures by the purpose. For example, the `grass`, `forest`, `drain`.
417
+ - `background` - set it to True for the textures, which should have impact on the Background Terrain, by default it's used to subtract the water depth from the DEM and background terrain.
418
+ - `info_layer` - if the layer is saving some data in JSON format, this section will describe it's name in the JSON file. Used to find the needed JSON data, for example for fields it will be `fields` and as a value - list of polygon coordinates.
419
+ - `invisible` - set it to True for the textures, which should not be drawn in the files, but only to save the data in the JSON file (related to the previous field).
423
420
 
424
421
  ## Background terrain
425
422
  The tool now supports the generation of the background terrain. If you don't know what it is, here's a brief explanation. The background terrain is the world around the map. It's important to create it because if you don't, the map will look like it's floating in the void. The background terrain is a simple plane that can (and should) be textured to look fine.<br>
@@ -476,27 +473,58 @@ You can also apply some advanced settings to the map generation process. Note th
476
473
 
477
474
  ### DEM Advanced settings
478
475
 
476
+ - Auto process: the tool will automatically try to find suitable multiplier. As a result, the DEM image WILL not match real world values. If this option is disabled, you'll probably see completely black DEM image, but it's not empty. It's just you can't see the values of 16-bit image by eye, because they're too small. Learn more what's DEM image and how to work with it in [docs](docs/dem.md). By default, it's set to True.
477
+
479
478
  - Multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum available value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the DEM file and the heightScale parameter in [docs](docs/dem.md). By default, it's set to 1.
480
479
 
481
480
  - Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result in a Minecraft-like map.
482
481
 
483
- - Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
482
+ - Plateau: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
484
483
 
485
484
  - Water depth: this value will be subtracted from each pixel of the DEM image, where water resources are located. Pay attention that it's not in meters, instead it in the pixel value of DEM, which is 16 bit image with possible values from 0 to 65535. When this value is set, the same value will be added to the plateau setting to avoid negative heights.
486
485
 
487
- ### Texture Advanced settings
486
+ ### Background terrain Advanced settings
488
487
 
489
- - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
488
+ - Generate background - if enabled, the obj files for the background terrain will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
489
+
490
+ - Generate water - if enabled, the water planes obj files will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
491
+
492
+ - Resize factor - the factor by which the background terrain will be resized. It will be used as 1 / resize_factor while generating the models. Which means that the larger the value the more the terrain will be resized. The lowest value is 1, in this case background terrain will not be resized. Note, than low values will lead to long processing and enormous size of the obj files.
490
493
 
491
- ### Farmlands Advanced settings
494
+ ### GRLE Advanced settings
492
495
 
493
496
  - Farmlands margin - this value (in meters) will be applied to each farmland, making it bigger. You can use the value to adjust how much the farmland should be bigger than the actual field. By default, it's set to 3.
494
497
 
495
- ### Vegetation Advanced settings
498
+ - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
499
+
500
+ - Add Farmyards - if enabled, the tool will create farmlands from the regions that are marked as farmyards in the OSM data. Those farmlands will not have fields and also will not be drawn on textures. By default, it's turned off.
501
+
502
+ ### I3D Advanced settings
496
503
 
497
504
  - Forest density - the density of the forest in meters. The lower the value, the lower the distance between the trees, which makes the forest denser. Note, that low values will lead to enormous number of trees, which may cause the Giants Editor to crash or lead to performance issues. By default, it's set to 10.
498
505
 
499
- - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
506
+ ### Texture Advanced settings
507
+
508
+ - Dissolve - if enabled, the values from one layer will be splitted between different layers of texture, making it look more natural. Warning: it's a time-consuming process, recommended to enable it, when you generating the final version of the map, not some test versions.
509
+
510
+ - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
511
+
512
+ - Skip drains - if enabled, the tool will not generate the drains and ditches on the map. By default, it's set to False. Use this if you don't need the drains on the map.
513
+
514
+ ## Splines Advanced settings
515
+
516
+ - Splines density - number of points, which will be added (interpolate) between each pair of existing points. The higher the value, the denser the spline will be. It can smooth the splines, but high values can in opposite make the splines look unnatural.
517
+
518
+ ## Expert Settings
519
+ The tool also supports the expert settings. Do not use them until you read the documentation and understand what they do. Here's the list of the expert settings:
520
+
521
+ - Enable debug logs - if enabled, the tool will print the debug logs to the console. It can be useful if you're using with a custom OSM map, have some issues with it and want to know what's wrong.
522
+
523
+ - Upload custom OSM file - you'll be able to upload your own OSM file. Before using it, carefully read the [Custom OSM](docs/custom_osm.md) documentation, otherwise, the tool will not work as expected.
524
+
525
+ - Show raw configuration - you'll be able to change all the settings in a single JSON file. It's useful if you want to save the configuration and use it later, without changing the settings in the UI. Be extremely careful with this setting, because you can break the tool with incorrect settings.
526
+
527
+ - Show schemas - you'll be able to edit or define your own texture or tree schemas. It's useful if you want to add some custom textures or trees to the map. Refer to the [Texture schema](#texture-schema) section to learn more about the schema structure. Any incorrect value here will lead to the completely broken map.
500
528
 
501
529
  ## Resources
502
530
  In this section, you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
@@ -522,3 +550,8 @@ But also, I want to thank the people who helped me with the project in some way,
522
550
  - [Ka5tis](https://github.com/Ka5tis) - for investigating the issue with a "spiky terrain" and finding a solution - changing the `DisplacementLayer` size to a higher value.
523
551
  - [Kalderone](https://www.youtube.com/@Kalderone_FS22) - for useful feedback, suggestions, expert advice on the map-making process and highlihting some important settings in the Giants Editor.
524
552
  - [OneSunnySunday](https://www.artstation.com/onesunnysunday) - for expert advice on Blender, help in processing background terrain, and compiling detailed tutorials on how to prepare the OBJ files for use in Giants Editor.
553
+ - [BFernaesds](https://github.com/BFernaesds) - for the manual tests of the app.
554
+ - [gamerdesigns](https://github.com/gamerdesigns) - for the manual tests of the app.
555
+ - [Tox3](https://github.com/Tox3) - for the manual tests of the app.
556
+ - [Lucandia](https://github.com/Lucandia) - for the awesome StreamLit [widget to preview STL files](https://github.com/Lucandia/streamlit_stl).
557
+ - [H4rdB4se](https://github.com/H4rdB4se) - for investigating the issue with custom OSM files and finding a proper way to work with the files in JOSM.
@@ -19,6 +19,7 @@
19
19
  <a href="#Overview-image">Overview image</a><br>
20
20
  <a href="#DDS-conversion">DDS conversion</a> •
21
21
  <a href="#Advanced-settings">Advanced settings</a> •
22
+ <a href="#Expert-settings">Expert settings</a> •
22
23
  <a href="#Resources">Resources</a> •
23
24
  <a href="#Bugs-and-feature-requests">Bugs and feature requests</a><br>
24
25
  <a href="#Special-thanks">Special thanks</a>
@@ -35,7 +36,8 @@
35
36
  [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
36
37
  [![Build Status](https://github.com/iwatkot/maps4fs/actions/workflows/checks.yml/badge.svg)](https://github.com/iwatkot/maps4fs/actions)
37
38
  [![Test Coverage](https://api.codeclimate.com/v1/badges/b922fd0a7188d37e61de/test_coverage)](https://codeclimate.com/github/iwatkot/maps4fs/test_coverage)
38
- [![GitHub Repo stars](https://img.shields.io/github/stars/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs/stargazers)
39
+ [![GitHub Repo stars](https://img.shields.io/github/stars/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs/stargazers)<br>
40
+ [![Lines of code](https://tokei.rs/b1/github/iwatkot/maps4fs)](https://github.com/iwatkot/maps4fs)
39
41
 
40
42
  </div>
41
43
 
@@ -46,7 +48,9 @@
46
48
  🌿 Automatically generates decorative foliage 🆕<br>
47
49
  🌲 Automatically generates forests 🆕<br>
48
50
  🌊 Automatically generates water planes 🆕<br>
51
+ 📈 Automatically generates splines 🆕<br>
49
52
  🌍 Based on real-world data from OpenStreetMap<br>
53
+ 🗺️ Supports [custom OSM maps](/docs/custom_osm.md)<br>
50
54
  🏞️ Generates height map using SRTM dataset<br>
51
55
  📦 Provides a ready-to-use map template for the Giants Editor<br>
52
56
  🚜 Supports Farming Simulator 22 and 25<br>
@@ -54,7 +58,6 @@
54
58
  📄 Generates scripts to download high-resolution satellite images from [QGIS](https://qgis.org/download/) in one click<br>
55
59
  📕 Detailed [documentation](/docs) and tutorials <br>
56
60
  🧰 Modder Toolbox to help you with various tasks <br>
57
-
58
61
  <p align="center">
59
62
  <img src="https://github.com/user-attachments/assets/cf8f5752-9c69-4018-bead-290f59ba6976"><br>
60
63
  🌎 Detailed terrain based on real-world data.<br><br>
@@ -68,6 +71,8 @@
68
71
  🌲 Automatically generates forests.<br><br>
69
72
  <img src="https://github.com/user-attachments/assets/cce7d4e0-cba2-4dd2-b22d-03137fb2e860"><br>
70
73
  🌊 Automatically generates water planes.<br><br>
74
+ <img src="https://github.com/user-attachments/assets/0b05b511-a595-48e7-a353-8298081314a4"><br>
75
+ 📈 Automatically generates splines.<br><br>
71
76
  <img src="https://github.com/user-attachments/assets/80e5923c-22c7-4dc0-8906-680902511f3a"><br>
72
77
  🗒️ True-to-life blueprints for fast and precise modding.<br><br>
73
78
  <img width="480" src="https://github.com/user-attachments/assets/1a8802d2-6a3b-4bfa-af2b-7c09478e199b"><br>
@@ -85,14 +90,7 @@
85
90
  ## Quick Start
86
91
  There are several ways to use the tool. You obviously need the **first one**, but you can choose any of the others depending on your needs.<br>
87
92
  ### 🚜 For most users
88
- **Option 1:** Open the [maps4fs](https://maps4fs.streamlit.app) on StreamLit and generate a map template in a few clicks.<br>
89
- <i>Note, that StreamLit community hosting has some limitations, such as: <br>
90
- 1. Maximum map size is 4096x4096 meters. <br>
91
- 2. Advanced settings are disabled. <br>
92
- 3. Texture dissolving is disabled (they will look worse). </i><br>
93
-
94
- If you run the application locally, you won't have any of these limitations and will be able to generate maps of any size with any settings you want and nice looking textures.<br>
95
- So, jump to [Docker version](#option-2-docker-version) to launch the tool with one command and get the full experience.<br>
93
+ **Option 1:** Open the [maps4fs](https://maps4fs.xyz) and generate a map template in a few clicks.<br>
96
94
 
97
95
  ![Basic WebUI](https://github.com/user-attachments/assets/52f499cc-f28a-4da3-abef-0e818abe8dbe)
98
96
 
@@ -140,13 +138,13 @@ Don't know where to start? Don't worry, just follow this [step-by-step guide](do
140
138
 
141
139
  ## How-To-Run
142
140
 
143
- ### Option 1: StreamLit
144
- 🟢 Recommended for all users.
141
+ ### Option 1: Public version
142
+ 🟢 Recommended for all users.
145
143
  🛠️ Don't need to install anything.
146
- 🗺️ Supported map sizes: 2x2, 4x4 km.
147
- ⚙️ Advanced settings: disabled.
148
- 🖼️ Texture dissolving: disabled.
149
- Using the [StreamLit](https://maps4fs.streamlit.app) version of the tool is the easiest way to generate a map template. Just open the link and follow the instructions.
144
+ 🗺️ Supported map sizes: 2x2, 4x4, 8x8 km.
145
+ ⚙️ Advanced settings: enabled.
146
+ 🖼️ Texture dissolving: enabled.
147
+ Using the public version on [maps4fs.xyz](https://maps4fs.xyz) is the easiest way to generate a map template. Just open the link and follow the instructions.
150
148
  Note: due to CPU and RAM limitations of the hosting, the generation may take some time. If you need faster processing, use the [Docker version](#option-2-docker-version).<br>
151
149
 
152
150
  Using it is easy and doesn't require any guides. Enjoy!
@@ -233,18 +231,12 @@ Tools are divided into categories, which are listed below.
233
231
 
234
232
  ## Supported objects
235
233
  The project is based on the [OpenStreetMap](https://www.openstreetmap.org/) data. So, refer to [this page](https://wiki.openstreetmap.org/wiki/Map_Features) to understand the list below.
236
- - "building": True
237
- - "highway": ["motorway", "trunk", "primary"]
238
- - "highway": ["secondary", "tertiary", "road", "service"]
239
- - "highway": ["unclassified", "residential", "track"]
240
- - "natural": ["grassland", "scrub"]
241
- - "landuse": "farmland"
242
- - "natural": ["water"]
243
- - "waterway": True
244
- - "natural": ["wood", "tree_row"]
245
- - "railway": True
246
-
247
- The list will be updated as the project develops.
234
+
235
+ You can find the active schemas here:
236
+ - [FS25](/data/fs25-texture-schema.json)
237
+ - [FS22](/data/fs22-texture-schema.json)
238
+
239
+ Learn more how to work with the schema in the [Texture schema](#texture-schema) section. You can also use your own schema in the [Expert settings](#expert-settings) section.
248
240
 
249
241
  ## Generation info
250
242
  The script will generate the `generation_info.json` file in the `output` folder. It is split into different sections, which represent the components of the map generator. You may need this information to use some other tools and services to obtain additional data for your map.<br>
@@ -395,6 +387,10 @@ Let's have a closer look at the fields:
395
387
  - `priority` - the priority of the texture for overlapping. Textures with higher priorities will be drawn over the textures with lower priorities.
396
388
  ℹ️ The texture with 0 priority considers the base layer, which means that all empty areas will be filled with this texture.
397
389
  - `exclude_weight` - this is only used for the forestRockRoots texture from FS25. It just means that this texture has no `weight` postfix, that's all.
390
+ - `usage` - the usage of the texture. Mainly used to group different textures by the purpose. For example, the `grass`, `forest`, `drain`.
391
+ - `background` - set it to True for the textures, which should have impact on the Background Terrain, by default it's used to subtract the water depth from the DEM and background terrain.
392
+ - `info_layer` - if the layer is saving some data in JSON format, this section will describe it's name in the JSON file. Used to find the needed JSON data, for example for fields it will be `fields` and as a value - list of polygon coordinates.
393
+ - `invisible` - set it to True for the textures, which should not be drawn in the files, but only to save the data in the JSON file (related to the previous field).
398
394
 
399
395
  ## Background terrain
400
396
  The tool now supports the generation of the background terrain. If you don't know what it is, here's a brief explanation. The background terrain is the world around the map. It's important to create it because if you don't, the map will look like it's floating in the void. The background terrain is a simple plane that can (and should) be textured to look fine.<br>
@@ -451,27 +447,58 @@ You can also apply some advanced settings to the map generation process. Note th
451
447
 
452
448
  ### DEM Advanced settings
453
449
 
450
+ - Auto process: the tool will automatically try to find suitable multiplier. As a result, the DEM image WILL not match real world values. If this option is disabled, you'll probably see completely black DEM image, but it's not empty. It's just you can't see the values of 16-bit image by eye, because they're too small. Learn more what's DEM image and how to work with it in [docs](docs/dem.md). By default, it's set to True.
451
+
454
452
  - Multiplier: the height of the map is multiplied by this value. So the DEM map is just a 16-bit grayscale image, which means that the maximum available value there is 65535, while the actual difference between the deepest and the highest point on Earth is about 20 km. Just note that this setting mostly does not matter, because you can always adjust it in the Giants Editor, learn more about the DEM file and the heightScale parameter in [docs](docs/dem.md). By default, it's set to 1.
455
453
 
456
454
  - Blur radius: the radius of the Gaussian blur filter applied to the DEM map. By default, it's set to 21. This filter just makes the DEM map smoother, so the height transitions will be more natural. You can set it to 1 to disable the filter, but it will result in a Minecraft-like map.
457
455
 
458
- - Plateau height: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
456
+ - Plateau: this value will be added to each pixel of the DEM image, making it "higher". It's useful when you want to add some negative heights on the map, that appear to be in a "low" place. By default, it's set to 0.
459
457
 
460
458
  - Water depth: this value will be subtracted from each pixel of the DEM image, where water resources are located. Pay attention that it's not in meters, instead it in the pixel value of DEM, which is 16 bit image with possible values from 0 to 65535. When this value is set, the same value will be added to the plateau setting to avoid negative heights.
461
459
 
462
- ### Texture Advanced settings
460
+ ### Background terrain Advanced settings
463
461
 
464
- - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
462
+ - Generate background - if enabled, the obj files for the background terrain will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
463
+
464
+ - Generate water - if enabled, the water planes obj files will be generated. You can turn it off if you already have those files or don't need them. By default, it's set to True.
465
+
466
+ - Resize factor - the factor by which the background terrain will be resized. It will be used as 1 / resize_factor while generating the models. Which means that the larger the value the more the terrain will be resized. The lowest value is 1, in this case background terrain will not be resized. Note, than low values will lead to long processing and enormous size of the obj files.
465
467
 
466
- ### Farmlands Advanced settings
468
+ ### GRLE Advanced settings
467
469
 
468
470
  - Farmlands margin - this value (in meters) will be applied to each farmland, making it bigger. You can use the value to adjust how much the farmland should be bigger than the actual field. By default, it's set to 3.
469
471
 
470
- ### Vegetation Advanced settings
472
+ - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
473
+
474
+ - Add Farmyards - if enabled, the tool will create farmlands from the regions that are marked as farmyards in the OSM data. Those farmlands will not have fields and also will not be drawn on textures. By default, it's turned off.
475
+
476
+ ### I3D Advanced settings
471
477
 
472
478
  - Forest density - the density of the forest in meters. The lower the value, the lower the distance between the trees, which makes the forest denser. Note, that low values will lead to enormous number of trees, which may cause the Giants Editor to crash or lead to performance issues. By default, it's set to 10.
473
479
 
474
- - Random plants - when adding decorative foliage, enabling this option will add different species of plants to the map. If unchecked only basic grass (smallDenseMix) will be added. Defaults to True.
480
+ ### Texture Advanced settings
481
+
482
+ - Dissolve - if enabled, the values from one layer will be splitted between different layers of texture, making it look more natural. Warning: it's a time-consuming process, recommended to enable it, when you generating the final version of the map, not some test versions.
483
+
484
+ - Fields padding - this value (in meters) will be applied to each field, making it smaller. It's useful when the fields are too close to each other and you want to make them smaller. By default, it's set to 0.
485
+
486
+ - Skip drains - if enabled, the tool will not generate the drains and ditches on the map. By default, it's set to False. Use this if you don't need the drains on the map.
487
+
488
+ ## Splines Advanced settings
489
+
490
+ - Splines density - number of points, which will be added (interpolate) between each pair of existing points. The higher the value, the denser the spline will be. It can smooth the splines, but high values can in opposite make the splines look unnatural.
491
+
492
+ ## Expert Settings
493
+ The tool also supports the expert settings. Do not use them until you read the documentation and understand what they do. Here's the list of the expert settings:
494
+
495
+ - Enable debug logs - if enabled, the tool will print the debug logs to the console. It can be useful if you're using with a custom OSM map, have some issues with it and want to know what's wrong.
496
+
497
+ - Upload custom OSM file - you'll be able to upload your own OSM file. Before using it, carefully read the [Custom OSM](docs/custom_osm.md) documentation, otherwise, the tool will not work as expected.
498
+
499
+ - Show raw configuration - you'll be able to change all the settings in a single JSON file. It's useful if you want to save the configuration and use it later, without changing the settings in the UI. Be extremely careful with this setting, because you can break the tool with incorrect settings.
500
+
501
+ - Show schemas - you'll be able to edit or define your own texture or tree schemas. It's useful if you want to add some custom textures or trees to the map. Refer to the [Texture schema](#texture-schema) section to learn more about the schema structure. Any incorrect value here will lead to the completely broken map.
475
502
 
476
503
  ## Resources
477
504
  In this section, you'll find a list of the resources that you need to create a map for the Farming Simulator.<br>
@@ -497,3 +524,8 @@ But also, I want to thank the people who helped me with the project in some way,
497
524
  - [Ka5tis](https://github.com/Ka5tis) - for investigating the issue with a "spiky terrain" and finding a solution - changing the `DisplacementLayer` size to a higher value.
498
525
  - [Kalderone](https://www.youtube.com/@Kalderone_FS22) - for useful feedback, suggestions, expert advice on the map-making process and highlihting some important settings in the Giants Editor.
499
526
  - [OneSunnySunday](https://www.artstation.com/onesunnysunday) - for expert advice on Blender, help in processing background terrain, and compiling detailed tutorials on how to prepare the OBJ files for use in Giants Editor.
527
+ - [BFernaesds](https://github.com/BFernaesds) - for the manual tests of the app.
528
+ - [gamerdesigns](https://github.com/gamerdesigns) - for the manual tests of the app.
529
+ - [Tox3](https://github.com/Tox3) - for the manual tests of the app.
530
+ - [Lucandia](https://github.com/Lucandia) - for the awesome StreamLit [widget to preview STL files](https://github.com/Lucandia/streamlit_stl).
531
+ - [H4rdB4se](https://github.com/H4rdB4se) - for investigating the issue with custom OSM files and finding a proper way to work with the files in JOSM.
@@ -0,0 +1,13 @@
1
+ # pylint: disable=missing-module-docstring
2
+ from maps4fs.generator.game import Game
3
+ from maps4fs.generator.map import (
4
+ BackgroundSettings,
5
+ DEMSettings,
6
+ GRLESettings,
7
+ I3DSettings,
8
+ Map,
9
+ SettingsModel,
10
+ SplineSettings,
11
+ TextureSettings,
12
+ )
13
+ from maps4fs.logger import Logger
@@ -13,16 +13,10 @@ import numpy as np
13
13
  import trimesh # type: ignore
14
14
 
15
15
  from maps4fs.generator.component import Component
16
- from maps4fs.generator.dem import (
17
- DEFAULT_BLUR_RADIUS,
18
- DEFAULT_MULTIPLIER,
19
- DEFAULT_PLATEAU,
20
- DEM,
21
- )
16
+ from maps4fs.generator.dem import DEM
22
17
  from maps4fs.generator.texture import Texture
23
18
 
24
19
  DEFAULT_DISTANCE = 2048
25
- RESIZE_FACTOR = 1 / 8
26
20
  FULL_NAME = "FULL"
27
21
  FULL_PREVIEW_NAME = "PREVIEW"
28
22
  ELEMENTS = [FULL_NAME, FULL_PREVIEW_NAME]
@@ -46,8 +40,6 @@ class Background(Component):
46
40
  # pylint: disable=R0801
47
41
  def preprocess(self) -> None:
48
42
  """Registers the DEMs for the background terrain."""
49
- self.light_version = self.kwargs.get("light_version", False)
50
- self.water_depth = self.kwargs.get("water_depth", 0)
51
43
  self.stl_preview_path: str | None = None
52
44
  self.water_resources_path: str | None = None
53
45
 
@@ -65,11 +57,12 @@ class Background(Component):
65
57
  os.makedirs(self.background_directory, exist_ok=True)
66
58
  os.makedirs(self.water_directory, exist_ok=True)
67
59
 
68
- autoprocesses = [self.kwargs.get("auto_process", False), False]
60
+ autoprocesses = [self.map.dem_settings.auto_process, False]
69
61
  self.output_paths = [
70
62
  os.path.join(self.background_directory, f"{name}.png") for name in ELEMENTS
71
63
  ]
72
64
  self.not_substracted_path = os.path.join(self.background_directory, "not_substracted.png")
65
+ self.not_resized_path = os.path.join(self.background_directory, "not_resized.png")
73
66
 
74
67
  dems = []
75
68
 
@@ -83,13 +76,12 @@ class Background(Component):
83
76
  self.rotation,
84
77
  self.map_directory,
85
78
  self.logger,
86
- auto_process=autoprocess,
87
- blur_radius=self.kwargs.get("blur_radius", DEFAULT_BLUR_RADIUS),
88
- multiplier=self.kwargs.get("multiplier", DEFAULT_MULTIPLIER),
89
- plateau=self.kwargs.get("plateau", DEFAULT_PLATEAU),
90
79
  )
91
80
  dem.preprocess()
92
81
  dem.is_preview = self.is_preview(name) # type: ignore
82
+ if dem.is_preview: # type: ignore
83
+ dem.multiplier = 1
84
+ dem.auto_process = autoprocess
93
85
  dem.set_output_resolution((self.rotated_size, self.rotated_size))
94
86
  dem.set_dem_path(output_path)
95
87
  dems.append(dem)
@@ -117,8 +109,9 @@ class Background(Component):
117
109
  dem.process()
118
110
  if not dem.is_preview: # type: ignore
119
111
  shutil.copyfile(dem.dem_path, self.not_substracted_path)
112
+ self.cutout(dem.dem_path, save_path=self.not_resized_path)
120
113
 
121
- if self.water_depth:
114
+ if self.map.dem_settings.water_depth:
122
115
  self.subtraction()
123
116
 
124
117
  for dem in self.dems:
@@ -127,11 +120,10 @@ class Background(Component):
127
120
  if self.game.additional_dem_name is not None:
128
121
  self.make_copy(cutted_dem_path, self.game.additional_dem_name)
129
122
 
130
- if not self.light_version:
123
+ if self.map.background_settings.generate_background:
131
124
  self.generate_obj_files()
125
+ if self.map.background_settings.generate_water:
132
126
  self.generate_water_resources_obj()
133
- else:
134
- self.logger.info("Light version is enabled, obj files will not be generated.")
135
127
 
136
128
  def make_copy(self, dem_path: str, dem_name: str) -> None:
137
129
  """Copies DEM data to additional DEM file.
@@ -145,7 +137,7 @@ class Background(Component):
145
137
  additional_dem_path = os.path.join(dem_directory, dem_name)
146
138
 
147
139
  shutil.copyfile(dem_path, additional_dem_path)
148
- self.logger.info("Additional DEM data was copied to %s.", additional_dem_path)
140
+ self.logger.debug("Additional DEM data was copied to %s.", additional_dem_path)
149
141
 
150
142
  def info_sequence(self) -> dict[str, str | float | int]:
151
143
  """Returns a dictionary with information about the background terrain.
@@ -207,11 +199,12 @@ class Background(Component):
207
199
  self.plane_from_np(dem_data, save_path, is_preview=dem.is_preview) # type: ignore
208
200
 
209
201
  # pylint: disable=too-many-locals
210
- def cutout(self, dem_path: str) -> str:
202
+ def cutout(self, dem_path: str, save_path: str | None = None) -> str:
211
203
  """Cuts out the center of the DEM (the actual map) and saves it as a separate file.
212
204
 
213
205
  Arguments:
214
206
  dem_path (str): The path to the DEM file.
207
+ save_path (str, optional): The path where the cutout DEM file will be saved.
215
208
 
216
209
  Returns:
217
210
  str -- The path to the cutout DEM file.
@@ -226,6 +219,11 @@ class Background(Component):
226
219
  y2 = center[1] + half_size
227
220
  dem_data = dem_data[x1:x2, y1:y2]
228
221
 
222
+ if save_path:
223
+ cv2.imwrite(save_path, dem_data) # pylint: disable=no-member
224
+ self.logger.debug("Not resized DEM saved: %s", save_path)
225
+ return save_path
226
+
229
227
  output_size = self.map_size + 1
230
228
 
231
229
  main_dem_path = self.game.dem_file_path(self.map_directory)
@@ -261,11 +259,12 @@ class Background(Component):
261
259
  is_preview (bool, optional) -- If True, the preview mesh will be generated.
262
260
  include_zeros (bool, optional) -- If True, the mesh will include the zero height values.
263
261
  """
262
+ resize_factor = 1 / self.map.background_settings.resize_factor
264
263
  dem_data = cv2.resize( # pylint: disable=no-member
265
- dem_data, (0, 0), fx=RESIZE_FACTOR, fy=RESIZE_FACTOR
264
+ dem_data, (0, 0), fx=resize_factor, fy=resize_factor
266
265
  )
267
266
  self.logger.debug(
268
- "DEM data resized to shape: %s with factor: %s", dem_data.shape, RESIZE_FACTOR
267
+ "DEM data resized to shape: %s with factor: %s", dem_data.shape, resize_factor
269
268
  )
270
269
 
271
270
  # Invert the height values.
@@ -325,13 +324,13 @@ class Background(Component):
325
324
  self.mesh_to_stl(mesh)
326
325
  else:
327
326
  if not include_zeros:
328
- multiplier = self.kwargs.get("multiplier", DEFAULT_MULTIPLIER)
327
+ multiplier = self.map.dem_settings.multiplier
329
328
  if multiplier != 1:
330
329
  z_scaling_factor = 1 / multiplier
331
330
  else:
332
331
  z_scaling_factor = 1 / 2**5
333
332
  self.logger.debug("Z scaling factor: %s", z_scaling_factor)
334
- mesh.apply_scale([1 / RESIZE_FACTOR, 1 / RESIZE_FACTOR, z_scaling_factor])
333
+ mesh.apply_scale([1 / resize_factor, 1 / resize_factor, z_scaling_factor])
335
334
 
336
335
  mesh.export(save_path)
337
336
  self.logger.debug("Obj file saved: %s", save_path)
@@ -347,7 +346,7 @@ class Background(Component):
347
346
  preview_path = os.path.join(self.previews_directory, "background_dem.stl")
348
347
  mesh.export(preview_path)
349
348
 
350
- self.logger.info("STL file saved: %s", preview_path)
349
+ self.logger.debug("STL file saved: %s", preview_path)
351
350
 
352
351
  self.stl_preview_path = preview_path # pylint: disable=attribute-defined-outside-init
353
352
 
@@ -485,8 +484,7 @@ class Background(Component):
485
484
  rotation=self.rotation,
486
485
  map_directory=self.map_directory,
487
486
  logger=self.logger,
488
- light_version=self.light_version,
489
- custom_schema=background_layers,
487
+ texture_custom_schema=background_layers, # type: ignore
490
488
  )
491
489
 
492
490
  self.background_texture.preprocess()
@@ -509,7 +507,7 @@ class Background(Component):
509
507
 
510
508
  background_save_path = os.path.join(self.water_directory, "water_resources.png")
511
509
  cv2.imwrite(background_save_path, background_image)
512
- self.logger.info("Background texture saved: %s", background_save_path)
510
+ self.logger.debug("Background texture saved: %s", background_save_path)
513
511
  self.water_resources_path = background_save_path # pylint: disable=W0201
514
512
 
515
513
  def subtraction(self) -> None:
@@ -534,7 +532,7 @@ class Background(Component):
534
532
 
535
533
  # Create a mask where water_resources_image is 255 (or not 0)
536
534
  # Subtract water_depth from dem_image where mask is True
537
- dem_image[mask] = dem_image[mask] - self.water_depth
535
+ dem_image[mask] = dem_image[mask] - self.map.dem_settings.water_depth
538
536
 
539
537
  # Save the modified dem_image back to the output path
540
538
  cv2.imwrite(output_path, dem_image)