maps4fs 1.6.3__py3-none-any.whl → 1.6.4__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/background.py +52 -4
- maps4fs/generator/grle.py +2 -2
- maps4fs/generator/i3d.py +2 -2
- maps4fs/generator/settings.py +4 -0
- maps4fs/generator/texture.py +1 -1
- {maps4fs-1.6.3.dist-info → maps4fs-1.6.4.dist-info}/METADATA +11 -7
- {maps4fs-1.6.3.dist-info → maps4fs-1.6.4.dist-info}/RECORD +10 -10
- {maps4fs-1.6.3.dist-info → maps4fs-1.6.4.dist-info}/LICENSE.md +0 -0
- {maps4fs-1.6.3.dist-info → maps4fs-1.6.4.dist-info}/WHEEL +0 -0
- {maps4fs-1.6.3.dist-info → maps4fs-1.6.4.dist-info}/top_level.txt +0 -0
maps4fs/generator/background.py
CHANGED
@@ -179,7 +179,13 @@ class Background(Component):
|
|
179
179
|
self.logger.debug("Generating obj file in path: %s", save_path)
|
180
180
|
|
181
181
|
dem_data = cv2.imread(self.dem.dem_path, cv2.IMREAD_UNCHANGED) # pylint: disable=no-member
|
182
|
-
self.plane_from_np(
|
182
|
+
self.plane_from_np(
|
183
|
+
dem_data,
|
184
|
+
save_path,
|
185
|
+
create_preview=True,
|
186
|
+
remove_center=self.map.background_settings.remove_center,
|
187
|
+
include_zeros=False,
|
188
|
+
) # type: ignore
|
183
189
|
|
184
190
|
# pylint: disable=too-many-locals
|
185
191
|
def cutout(self, dem_path: str, save_path: str | None = None) -> str:
|
@@ -222,17 +228,37 @@ class Background(Component):
|
|
222
228
|
)
|
223
229
|
|
224
230
|
cv2.imwrite(main_dem_path, resized_dem_data) # pylint: disable=no-member
|
225
|
-
self.logger.
|
231
|
+
self.logger.debug("DEM cutout saved: %s", main_dem_path)
|
226
232
|
|
227
233
|
return main_dem_path
|
228
234
|
|
229
|
-
|
235
|
+
def remove_center(self, dem_data: np.ndarray, resize_factor: float) -> np.ndarray:
|
236
|
+
"""Removes the center part of the DEM data.
|
237
|
+
|
238
|
+
Arguments:
|
239
|
+
dem_data (np.ndarray) -- The DEM data as a numpy array.
|
240
|
+
resize_factor (float) -- The resize factor of the DEM data.
|
241
|
+
|
242
|
+
Returns:
|
243
|
+
np.ndarray -- The DEM data with the center part removed.
|
244
|
+
"""
|
245
|
+
center = (dem_data.shape[0] // 2, dem_data.shape[1] // 2)
|
246
|
+
half_size = int(self.map_size // 2 * resize_factor)
|
247
|
+
x1 = center[0] - half_size
|
248
|
+
x2 = center[0] + half_size
|
249
|
+
y1 = center[1] - half_size
|
250
|
+
y2 = center[1] + half_size
|
251
|
+
dem_data[x1:x2, y1:y2] = 0
|
252
|
+
return dem_data
|
253
|
+
|
254
|
+
# pylint: disable=R0913, R0917, R0915
|
230
255
|
def plane_from_np(
|
231
256
|
self,
|
232
257
|
dem_data: np.ndarray,
|
233
258
|
save_path: str,
|
234
259
|
include_zeros: bool = True,
|
235
260
|
create_preview: bool = False,
|
261
|
+
remove_center: bool = False,
|
236
262
|
) -> None:
|
237
263
|
"""Generates a 3D obj file based on DEM data.
|
238
264
|
|
@@ -241,11 +267,17 @@ class Background(Component):
|
|
241
267
|
save_path (str) -- The path where the obj file will be saved.
|
242
268
|
include_zeros (bool, optional) -- If True, the mesh will include the zero height values.
|
243
269
|
create_preview (bool, optional) -- If True, a simplified mesh will be saved as an STL.
|
270
|
+
remove_center (bool, optional) -- If True, the center of the mesh will be removed.
|
271
|
+
This setting is used for a Background Terrain, where the center part where the
|
272
|
+
playable area is will be cut out.
|
244
273
|
"""
|
245
274
|
resize_factor = 1 / self.map.background_settings.resize_factor
|
246
275
|
dem_data = cv2.resize( # pylint: disable=no-member
|
247
276
|
dem_data, (0, 0), fx=resize_factor, fy=resize_factor
|
248
277
|
)
|
278
|
+
if remove_center:
|
279
|
+
dem_data = self.remove_center(dem_data, resize_factor)
|
280
|
+
self.logger.debug("Center removed from DEM data.")
|
249
281
|
self.logger.debug(
|
250
282
|
"DEM data resized to shape: %s with factor: %s", dem_data.shape, resize_factor
|
251
283
|
)
|
@@ -306,12 +338,28 @@ class Background(Component):
|
|
306
338
|
self.logger.debug("Z scaling factor: %s", z_scaling_factor)
|
307
339
|
mesh.apply_scale([1 / resize_factor, 1 / resize_factor, z_scaling_factor])
|
308
340
|
|
341
|
+
old_faces = len(mesh.faces)
|
342
|
+
self.logger.debug("Mesh generated with %s faces.", old_faces)
|
343
|
+
|
344
|
+
if self.map.background_settings.apply_decimation:
|
345
|
+
percent = self.map.background_settings.decimation_percent / 100
|
346
|
+
mesh = mesh.simplify_quadric_decimation(
|
347
|
+
percent=percent, aggression=self.map.background_settings.decimation_agression
|
348
|
+
)
|
349
|
+
|
350
|
+
new_faces = len(mesh.faces)
|
351
|
+
decimation_percent = (old_faces - new_faces) / old_faces * 100
|
352
|
+
|
353
|
+
self.logger.debug(
|
354
|
+
"Mesh simplified to %s faces. Decimation percent: %s", new_faces, decimation_percent
|
355
|
+
)
|
356
|
+
|
309
357
|
mesh.export(save_path)
|
310
358
|
self.logger.debug("Obj file saved: %s", save_path)
|
311
359
|
|
312
360
|
if create_preview:
|
313
361
|
# Simplify the preview mesh to reduce the size of the file.
|
314
|
-
mesh = mesh.simplify_quadric_decimation(face_count=len(mesh.faces) // 2**7)
|
362
|
+
# mesh = mesh.simplify_quadric_decimation(face_count=len(mesh.faces) // 2**7)
|
315
363
|
|
316
364
|
# Apply scale to make the preview mesh smaller in the UI.
|
317
365
|
mesh.apply_scale([0.5, 0.5, 0.5])
|
maps4fs/generator/grle.py
CHANGED
@@ -114,12 +114,12 @@ class GRLE(Component):
|
|
114
114
|
self.logger.warning("Fields data not found in textures info layer.")
|
115
115
|
return
|
116
116
|
|
117
|
-
self.logger.
|
117
|
+
self.logger.debug("Found %s fields in textures info layer.", len(fields))
|
118
118
|
|
119
119
|
farmyards: list[list[tuple[int, int]]] | None = textures_info_layer.get("farmyards")
|
120
120
|
if farmyards and self.map.grle_settings.add_farmyards:
|
121
121
|
fields.extend(farmyards)
|
122
|
-
self.logger.
|
122
|
+
self.logger.debug("Found %s farmyards in textures info layer.", len(farmyards))
|
123
123
|
|
124
124
|
info_layer_farmlands_path = os.path.join(
|
125
125
|
self.game.weights_dir_path(self.map_directory), "infoLayer_farmlands.png"
|
maps4fs/generator/i3d.py
CHANGED
@@ -155,7 +155,7 @@ class I3d(Component):
|
|
155
155
|
self.logger.warning("Roads polylines data not found in textures info layer.")
|
156
156
|
return
|
157
157
|
|
158
|
-
self.logger.
|
158
|
+
self.logger.debug("Found %s roads polylines in textures info layer.", len(roads_polylines))
|
159
159
|
self.logger.debug("Starging to add roads polylines to the I3D file.")
|
160
160
|
|
161
161
|
root = tree.getroot()
|
@@ -300,7 +300,7 @@ class I3d(Component):
|
|
300
300
|
self.logger.warning("Fields data not found in textures info layer.")
|
301
301
|
return
|
302
302
|
|
303
|
-
self.logger.
|
303
|
+
self.logger.debug("Found %s fields in textures info layer.", len(fields))
|
304
304
|
self.logger.debug("Starging to add fields to the I3D file.")
|
305
305
|
|
306
306
|
root = tree.getroot()
|
maps4fs/generator/settings.py
CHANGED
@@ -98,6 +98,10 @@ class BackgroundSettings(SettingsModel):
|
|
98
98
|
generate_background: bool = False
|
99
99
|
generate_water: bool = False
|
100
100
|
resize_factor: int = 8
|
101
|
+
remove_center: bool = False
|
102
|
+
apply_decimation: bool = False
|
103
|
+
decimation_percent: int = 25
|
104
|
+
decimation_agression: int = 3
|
101
105
|
|
102
106
|
|
103
107
|
class GRLESettings(SettingsModel):
|
maps4fs/generator/texture.py
CHANGED
@@ -507,7 +507,7 @@ class Texture(Component):
|
|
507
507
|
cv2.imwrite(sublayer_path, sublayer)
|
508
508
|
self.logger.debug("Sublayer %s saved.", sublayer_path)
|
509
509
|
|
510
|
-
self.logger.
|
510
|
+
self.logger.debug("Dissolved layer %s.", layer.name)
|
511
511
|
|
512
512
|
def draw_base_layer(self, cumulative_image: np.ndarray) -> None:
|
513
513
|
"""Draws base layer and saves it into the png file.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: maps4fs
|
3
|
-
Version: 1.6.
|
3
|
+
Version: 1.6.4
|
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
|
@@ -467,13 +467,8 @@ List of the important DDS files:
|
|
467
467
|
- `mapsUS/overview.dds` - 4096x4096 pixels, the overview image of the map (in-game map)
|
468
468
|
|
469
469
|
## Advanced settings
|
470
|
-
The tool supports the custom size of the map. To use this feature select `Custom` in the `Map size` dropdown and enter the desired size. The tool will generate a map with the size you entered.<br>
|
471
470
|
|
472
|
-
|
473
|
-
|
474
|
-

|
475
|
-
|
476
|
-
You can also apply some advanced settings to the map generation process. Note that they're ADVANCED, so you don't need to use them if you're not sure what they do.<br>
|
471
|
+
You can also apply some advanced settings to the map generation process.<br>
|
477
472
|
|
478
473
|
### DEM Advanced settings
|
479
474
|
|
@@ -493,6 +488,15 @@ You can also apply some advanced settings to the map generation process. Note th
|
|
493
488
|
|
494
489
|
- 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.
|
495
490
|
|
491
|
+
- Remove center - if enabled, the playable region (map terrain) will be removed from the background terrain. Note, that it will require low resize factors, to avoid gaps between the map and the background terrain.
|
492
|
+
|
493
|
+
- Apply decimation - if enabled, the mesh will be simplified to reduce the number of faces.
|
494
|
+
|
495
|
+
- Decimation percent - the target percentage of decimation. The higher the value, the more simplified the mesh will be. Note, that high values will break the 3D model entirely.
|
496
|
+
|
497
|
+
- Decimation agression - the aggression of the decimation. The higher the value, the more aggressive the
|
498
|
+
decimation will be, which means the higher it will affect the geometry. It's not recommended to make it higher than the default value, otherwise the background terrain will not match the map terrain.
|
499
|
+
|
496
500
|
### GRLE Advanced settings
|
497
501
|
|
498
502
|
- 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.
|
@@ -1,18 +1,18 @@
|
|
1
1
|
maps4fs/__init__.py,sha256=WbT36EzJ_74GN0RUUrLIYECdSdtRiZaxKl17KUt7pjA,492
|
2
2
|
maps4fs/logger.py,sha256=B-NEYpMjPAAqlV4VpfTi6nbBFnEABVtQOaYe6nMpidg,1489
|
3
3
|
maps4fs/generator/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
|
4
|
-
maps4fs/generator/background.py,sha256=
|
4
|
+
maps4fs/generator/background.py,sha256=JZNSiPZzA6_Kihu83qdCbsJc9bGeeSBY0SP6jTtdvU4,24595
|
5
5
|
maps4fs/generator/component.py,sha256=GrTI7803gOQFhqocdjFG-wh0HOkC6HWoyKr8pR2Xp28,20409
|
6
6
|
maps4fs/generator/config.py,sha256=0QmK052B8bxyHVhg3jzCORLfOBMMmqVfhhbqXKf6OMk,4383
|
7
7
|
maps4fs/generator/dem.py,sha256=20gx0dzX0LyO6ipvDitst-BwGfcKogFqgQf9Q2qMH5U,10933
|
8
8
|
maps4fs/generator/game.py,sha256=QHgVnyGYvEnfwGZ84-u-dpbCRr3UeVVqBbrwr5WG8dE,7992
|
9
|
-
maps4fs/generator/grle.py,sha256=
|
10
|
-
maps4fs/generator/i3d.py,sha256=
|
9
|
+
maps4fs/generator/grle.py,sha256=rU84Q1PBHr-V-JzdHJ7BXLHC_LztGw6Z1FS2w_1HIF0,17848
|
10
|
+
maps4fs/generator/i3d.py,sha256=D1QBHCFygTkml6GZmLRlUagWEVQb0tNeyZ-MAY-Uf0Q,24945
|
11
11
|
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
|
-
maps4fs/generator/settings.py,sha256=
|
15
|
-
maps4fs/generator/texture.py,sha256=
|
14
|
+
maps4fs/generator/settings.py,sha256=zPdewt348ulparOAlWo-TmfyF77bm1567fcliL6YP6s,4951
|
15
|
+
maps4fs/generator/texture.py,sha256=C3gjAd5yAF0uw7QP3hU2In9iHAXg-oXzYAuBVWd3FD8,31135
|
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.4.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
|
24
|
+
maps4fs-1.6.4.dist-info/METADATA,sha256=huMhHVyVy7sduTij2eOj0GAAVxSCgUSX4unrmkEeW-s,36425
|
25
|
+
maps4fs-1.6.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
26
|
+
maps4fs-1.6.4.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
|
27
|
+
maps4fs-1.6.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|