maps4fs 1.6.4__py3-none-any.whl → 1.6.5__py3-none-any.whl
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.
- maps4fs/generator/texture.py +54 -1
- {maps4fs-1.6.4.dist-info → maps4fs-1.6.5.dist-info}/METADATA +5 -2
- {maps4fs-1.6.4.dist-info → maps4fs-1.6.5.dist-info}/RECORD +6 -6
- {maps4fs-1.6.4.dist-info → maps4fs-1.6.5.dist-info}/LICENSE.md +0 -0
- {maps4fs-1.6.4.dist-info → maps4fs-1.6.5.dist-info}/WHEEL +0 -0
- {maps4fs-1.6.4.dist-info → maps4fs-1.6.5.dist-info}/top_level.txt +0 -0
maps4fs/generator/texture.py
CHANGED
@@ -5,6 +5,7 @@ from __future__ import annotations
|
|
5
5
|
import json
|
6
6
|
import os
|
7
7
|
import re
|
8
|
+
import shutil
|
8
9
|
from collections import defaultdict
|
9
10
|
from typing import Any, Callable, Generator, Optional
|
10
11
|
|
@@ -69,6 +70,7 @@ class Texture(Component):
|
|
69
70
|
usage: str | None = None,
|
70
71
|
background: bool = False,
|
71
72
|
invisible: bool = False,
|
73
|
+
procedural: list[str] | None = None,
|
72
74
|
):
|
73
75
|
self.name = name
|
74
76
|
self.count = count
|
@@ -81,6 +83,7 @@ class Texture(Component):
|
|
81
83
|
self.usage = usage
|
82
84
|
self.background = background
|
83
85
|
self.invisible = invisible
|
86
|
+
self.procedural = procedural
|
84
87
|
|
85
88
|
def to_json(self) -> dict[str, str | list[str] | bool]: # type: ignore
|
86
89
|
"""Returns dictionary with layer data.
|
@@ -99,6 +102,7 @@ class Texture(Component):
|
|
99
102
|
"usage": self.usage,
|
100
103
|
"background": self.background,
|
101
104
|
"invisible": self.invisible,
|
105
|
+
"procedural": self.procedural,
|
102
106
|
}
|
103
107
|
|
104
108
|
data = {k: v for k, v in data.items() if v is not None}
|
@@ -212,6 +216,10 @@ class Texture(Component):
|
|
212
216
|
|
213
217
|
self._weights_dir = self.game.weights_dir_path(self.map_directory)
|
214
218
|
self.logger.debug("Weights directory: %s.", self._weights_dir)
|
219
|
+
self.procedural_dir = os.path.join(self._weights_dir, "masks")
|
220
|
+
os.makedirs(self.procedural_dir, exist_ok=True)
|
221
|
+
self.logger.debug("Procedural directory: %s.", self.procedural_dir)
|
222
|
+
|
215
223
|
self.info_save_path = os.path.join(self.map_directory, "generation_info.json")
|
216
224
|
self.logger.debug("Generation info save path: %s.", self.info_save_path)
|
217
225
|
|
@@ -251,11 +259,56 @@ class Texture(Component):
|
|
251
259
|
return layer
|
252
260
|
return None
|
253
261
|
|
254
|
-
def process(self):
|
262
|
+
def process(self) -> None:
|
263
|
+
"""Processes the data to generate textures."""
|
255
264
|
self._prepare_weights()
|
256
265
|
self._read_parameters()
|
257
266
|
self.draw()
|
258
267
|
self.rotate_textures()
|
268
|
+
self.copy_procedural()
|
269
|
+
|
270
|
+
def copy_procedural(self) -> None:
|
271
|
+
"""Copies some of the textures to use them as mask for procedural generation.
|
272
|
+
Creates an empty blockmask if it does not exist."""
|
273
|
+
blockmask_path = os.path.join(self.procedural_dir, "BLOCKMASK.png")
|
274
|
+
if not os.path.isfile(blockmask_path):
|
275
|
+
self.logger.debug("BLOCKMASK.png not found, creating an empty file.")
|
276
|
+
img = np.zeros((self.map_size, self.map_size), dtype=np.uint8)
|
277
|
+
cv2.imwrite(blockmask_path, img) # pylint: disable=no-member
|
278
|
+
|
279
|
+
pg_layers_by_type = defaultdict(list)
|
280
|
+
for layer in self.layers:
|
281
|
+
if layer.procedural:
|
282
|
+
# Get path to the original file.
|
283
|
+
texture_path = layer.get_preview_or_path(self._weights_dir)
|
284
|
+
for procedural_layer_name in layer.procedural:
|
285
|
+
pg_layers_by_type[procedural_layer_name].append(texture_path)
|
286
|
+
|
287
|
+
if not pg_layers_by_type:
|
288
|
+
self.logger.debug("No procedural layers found.")
|
289
|
+
return
|
290
|
+
|
291
|
+
for procedural_layer_name, texture_paths in pg_layers_by_type.items():
|
292
|
+
procedural_save_path = os.path.join(self.procedural_dir, f"{procedural_layer_name}.png")
|
293
|
+
if len(texture_paths) > 1:
|
294
|
+
# If there are more than one texture, merge them.
|
295
|
+
merged_texture = np.zeros((self.map_size, self.map_size), dtype=np.uint8)
|
296
|
+
for texture_path in texture_paths:
|
297
|
+
# pylint: disable=E1101
|
298
|
+
texture = cv2.imread(texture_path, cv2.IMREAD_UNCHANGED)
|
299
|
+
merged_texture[texture == 255] = 255
|
300
|
+
cv2.imwrite(procedural_save_path, merged_texture) # pylint: disable=no-member
|
301
|
+
self.logger.debug(
|
302
|
+
"Procedural file %s merged from %s textures.",
|
303
|
+
procedural_save_path,
|
304
|
+
len(texture_paths),
|
305
|
+
)
|
306
|
+
elif len(texture_paths) == 1:
|
307
|
+
# Otherwise, copy the texture.
|
308
|
+
shutil.copyfile(texture_paths[0], procedural_save_path)
|
309
|
+
self.logger.debug(
|
310
|
+
"Procedural file %s copied from %s.", procedural_save_path, texture_paths[0]
|
311
|
+
)
|
259
312
|
|
260
313
|
def rotate_textures(self) -> None:
|
261
314
|
"""Rotates textures of the layers which have tags."""
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 1.6.
|
3
|
+
Version: 1.6.5
|
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
|
@@ -131,6 +131,7 @@ docker run -d -p 8501:8501 --name maps4fs iwatkot/maps4fs
|
|
131
131
|
```
|
132
132
|
And open [http://localhost:8501](http://localhost:8501) in your browser.<br>
|
133
133
|
If you don't know how to use Docker, navigate to the [Docker version](#option-2-docker-version), it's really simple.<br>
|
134
|
+
Check out the [Docker FAQ](docs/FAQ_docker.md) if you have any questions.<br>
|
134
135
|
|
135
136
|
### 🤯 For developers
|
136
137
|
**Option 3:** Python package. Install the package using the following command:
|
@@ -185,6 +186,7 @@ Using it is easy and doesn't require any guides. Enjoy!
|
|
185
186
|
🗺️ Supported map sizes: 2x2, 4x4, 8x8, 16x16 km and any custom size.
|
186
187
|
⚙️ Advanced settings: enabled.
|
187
188
|
🖼️ Texture dissolving: enabled.
|
189
|
+
Check out the [Docker FAQ](docs/FAQ_docker.md) if you have any questions.<br>
|
188
190
|
You can launch the project with minimalistic UI in your browser using Docker. Follow these steps:
|
189
191
|
|
190
192
|
1. Install [Docker](https://docs.docker.com/get-docker/) for your OS.
|
@@ -421,6 +423,7 @@ Let's have a closer look at the fields:
|
|
421
423
|
- `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.
|
422
424
|
- `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.
|
423
425
|
- `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).
|
426
|
+
- `procedural` - is a list of corresponding files, that will be used for a procedural generation. For example: `"procedural": ["PG_meadow", "PG_acres"]` - means that the texture will be used for two procedural generation files: `masks/PG_meadow.png` and `masks/PG_acres.png`. Note, that the one procuderal name can be applied to multiple textures, in this case they will be merged into one mask.
|
424
427
|
|
425
428
|
## Background terrain
|
426
429
|
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>
|
@@ -472,7 +475,7 @@ You can also apply some advanced settings to the map generation process.<br>
|
|
472
475
|
|
473
476
|
### DEM Advanced settings
|
474
477
|
|
475
|
-
- 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).
|
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). To match the in-game heights with SRTM Data provider, the recommended value is 255 (if easy mode is disabled), but depending on the place, you will need to play with both multiplier and the height scale in Giants Editor to find the best values.
|
476
479
|
|
477
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.
|
478
481
|
|
@@ -12,7 +12,7 @@ maps4fs/generator/map.py,sha256=8CYUs7NNVoQBvABqtoKtnbj280JuvseNORDCsebkQ_c,9357
|
|
12
12
|
maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
|
13
13
|
maps4fs/generator/satellite.py,sha256=_7RcuNmR1mjxEJWMDsjnzKUIqWxnGUn50XtjB7HmSPg,3661
|
14
14
|
maps4fs/generator/settings.py,sha256=zPdewt348ulparOAlWo-TmfyF77bm1567fcliL6YP6s,4951
|
15
|
-
maps4fs/generator/texture.py,sha256=
|
15
|
+
maps4fs/generator/texture.py,sha256=jWorYVOzBI-plzy_mh42O2NZuB13M5yDaCOfrpX6Dck,33836
|
16
16
|
maps4fs/generator/dtm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
17
17
|
maps4fs/generator/dtm/dtm.py,sha256=azy-RWsc5PgenKDtgG0lrddMwWEw1hYzdng9V8zphMk,9167
|
18
18
|
maps4fs/generator/dtm/srtm.py,sha256=2-pX6bWrJX6gr8IM7ueX6mm_PW7_UQ58MtdzDHae2OQ,9030
|
@@ -20,8 +20,8 @@ maps4fs/generator/dtm/usgs.py,sha256=ZTi10RNDA3EBrsVg2ZoYrdN4uqiG1Jvk7FzdcKdgNkU
|
|
20
20
|
maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
21
21
|
maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
|
22
22
|
maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
|
23
|
-
maps4fs-1.6.
|
24
|
-
maps4fs-1.6.
|
25
|
-
maps4fs-1.6.
|
26
|
-
maps4fs-1.6.
|
27
|
-
maps4fs-1.6.
|
23
|
+
maps4fs-1.6.5.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
24
|
+
maps4fs-1.6.5.dist-info/METADATA,sha256=OUF4EOb79OP5f4LT18s7UL4MdYtupLqFv8Y9Cle9hWo,37195
|
25
|
+
maps4fs-1.6.5.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
26
|
+
maps4fs-1.6.5.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
27
|
+
maps4fs-1.6.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|