maps4fs 0.9.99__py3-none-any.whl → 1.0.0__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/tile.py CHANGED
@@ -36,10 +36,10 @@ class Tile(DEM):
36
36
 
37
37
  self.logger.debug("Generating tile for code %s", self.code)
38
38
 
39
- tiles_directory = os.path.join(self.map_directory, "objects", "tiles")
40
- os.makedirs(tiles_directory, exist_ok=True)
39
+ background_directory = os.path.join(self.map_directory, "background")
40
+ os.makedirs(background_directory, exist_ok=True)
41
41
 
42
- self._dem_path = os.path.join(tiles_directory, f"{self.code}.png")
42
+ self._dem_path = os.path.join(background_directory, f"{self.code}.png")
43
43
  self.logger.debug("DEM path for tile %s is %s", self.code, self._dem_path)
44
44
 
45
45
  def get_output_resolution(self) -> tuple[int, int]:
@@ -0,0 +1,63 @@
1
+ """This module contains functions to work with the background terrain of the map."""
2
+
3
+ import cv2
4
+ import numpy as np
5
+ import trimesh # type: ignore
6
+
7
+
8
+ # pylint: disable=R0801, R0914
9
+ def plane_from_np(
10
+ dem_data: np.ndarray,
11
+ resize_factor: float,
12
+ simplify_factor: int,
13
+ save_path: str,
14
+ ) -> None:
15
+ """Generates a 3D obj file based on DEM data.
16
+
17
+ Arguments:
18
+ dem_data (np.ndarray) -- The DEM data as a numpy array.
19
+ resize_factor (float) -- The factor by which the DEM data will be resized. Bigger values
20
+ will result in a bigger mesh.
21
+ simplify_factor (int) -- The factor by which the mesh will be simplified. Bigger values
22
+ will result in a simpler mesh.
23
+ save_path (str) -- The path to save the obj file.
24
+ """
25
+ dem_data = cv2.resize( # pylint: disable=no-member
26
+ dem_data, (0, 0), fx=resize_factor, fy=resize_factor
27
+ )
28
+
29
+ # Invert the height values.
30
+ dem_data = dem_data.max() - dem_data
31
+
32
+ rows, cols = dem_data.shape
33
+ x = np.linspace(0, cols - 1, cols)
34
+ y = np.linspace(0, rows - 1, rows)
35
+ x, y = np.meshgrid(x, y)
36
+ z = dem_data
37
+
38
+ vertices = np.column_stack([x.ravel(), y.ravel(), z.ravel()])
39
+ faces = []
40
+
41
+ for i in range(rows - 1):
42
+ for j in range(cols - 1):
43
+ top_left = i * cols + j
44
+ top_right = top_left + 1
45
+ bottom_left = top_left + cols
46
+ bottom_right = bottom_left + 1
47
+
48
+ faces.append([top_left, bottom_left, bottom_right])
49
+ faces.append([top_left, bottom_right, top_right])
50
+
51
+ faces = np.array(faces) # type: ignore
52
+ mesh = trimesh.Trimesh(vertices=vertices, faces=faces)
53
+
54
+ # Apply rotation: 180 degrees around Y-axis and Z-axis
55
+ rotation_matrix_y = trimesh.transformations.rotation_matrix(np.pi, [0, 1, 0])
56
+ rotation_matrix_z = trimesh.transformations.rotation_matrix(np.pi, [0, 0, 1])
57
+ mesh.apply_transform(rotation_matrix_y)
58
+ mesh.apply_transform(rotation_matrix_z)
59
+
60
+ # Simplify the mesh to reduce the number of faces.
61
+ mesh = mesh.simplify_quadric_decimation(face_count=len(faces) // simplify_factor)
62
+
63
+ mesh.export(save_path)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: maps4fs
3
- Version: 0.9.99
3
+ Version: 1.0.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
@@ -31,8 +31,10 @@ Requires-Dist: pympler
31
31
  <p align="center">
32
32
  <a href="#Quick-Start">Quick Start</a> •
33
33
  <a href="#Overview">Overview</a> •
34
- <a href="#How-To-Run">How-To-Run</a> •
34
+ <a href="#Step-by-step">Create a map in 10 steps</a> •
35
+ <a href="#How-To-Run">How-To-Run</a><br>
35
36
  <a href="docs/FAQ.md">FAQ</a> •
37
+ <a href="docs/map_structure.md">Map Structure</a> •
36
38
  <a href="#Modder-Toolbox">Modder Toolbox</a><br>
37
39
  <a href="#Supported-objects">Supported objects</a> •
38
40
  <a href="#Generation-info">Generation info</a> •
@@ -129,6 +131,9 @@ Parameters:
129
131
  - coordinates: 45.15, 19.71
130
132
  - size: 16 x 16 km
131
133
 
134
+ ## Step by step
135
+ Don't know where to start? Don't worry, just follow this [step-by-step guide](docs/step_by_step.md) to create your first map in 10 simple steps.<br>
136
+
132
137
  ## How-To-Run
133
138
 
134
139
  You'll find detailed instructions on how to run the project below. But if you prefer video tutorials, here's one for you:
@@ -205,12 +210,15 @@ The map will be saved in the `map_directory` directory.
205
210
  ## Modder Toolbox
206
211
  The tool now has a Modder Toolbox, which is a set of tools to help you with various tasks. You can open the toolbox by switching to the `🧰 Modder Toolbox` tab in the StreamLit app.<br>
207
212
 
208
- ![Modder Toolbox](https://github.com/user-attachments/assets/18f169e9-1a5b-474c-b488-6becfffadcea)
213
+ ![Modder Toolbox](https://github.com/user-attachments/assets/dffb252f-f5c0-4021-9d45-31e5bccc0d9b)
209
214
 
210
215
  ### Tool categories
211
216
  Tools are divided into categories, which are listed below.
212
217
  #### Textures and DEM
213
- - **GeoTIFF windowing** - allows you to upload your GeoTIFF file and select the region of interest to extract it from the image.
218
+ - **GeoTIFF windowing** - allows you to upload your GeoTIFF file and select the region of interest to extract it from the image. It's useful when you have high-resolution DEM data and want to create the height map using it.
219
+
220
+ #### Background terrain
221
+ - **Convert image to obj model** - allows you to convert the image to the obj model. You can use this tool to create the background terrain for your map. It can be extremely useful if you have access to the sources of high-resolution DEM data and want to create the background terrain using it.
214
222
 
215
223
  ## Supported objects
216
224
  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.
@@ -379,7 +387,7 @@ Let's have a closer look at the fields:
379
387
 
380
388
  ## Background terrain
381
389
  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 which can (and should) be texture to look fine.<br>
382
- So, the tool generates the background terrain in the form of the 8 tiles, which surround the map. The tiles are named as the cardinal points, e.g. "N", "NE", "E" and so on. All those tiles will be saved in the `objects/tiles` directory with corresponding names: `N.obj`, `NE.obj`, `E.obj` and so on.<br>
390
+ So, the tool generates the background terrain in the form of the 8 tiles, which surround the map. The tiles are named as the cardinal points, e.g. "N", "NE", "E" and so on. All those tiles will be saved in the `background` directory with corresponding names: `N.obj`, `NE.obj`, `E.obj` and so on.<br>
383
391
  If you don't want to work with separate tiles, the tool also generates the `FULL.obj` file, which includes everything around the map and the map itself. It may be a convinient approach to work with one file, one texture and then just cut the map from it.<br>
384
392
 
385
393
  ![Complete background terrain in Blender](https://github.com/user-attachments/assets/7266b8f1-bfa2-4c14-a740-1c84b1030a66)
@@ -12,11 +12,12 @@ maps4fs/generator/map.py,sha256=1EJfq5928xbV7v9vBBuoC3VpD5gC1SMDBTQ7geH6yaA,4678
12
12
  maps4fs/generator/path_steps.py,sha256=yeN6hmOD8O2LMozUf4HcQMIy8WJ5sHF5pGQT_s2FfOw,3147
13
13
  maps4fs/generator/qgis.py,sha256=Es8hLuqN_KH8lDfnJE6He2rWYbAKJ3RGPn-o87S6CPI,6116
14
14
  maps4fs/generator/texture.py,sha256=uSuqJyZom861_BO-3aUqU8_OkroExmN25PsRBjdddkw,23799
15
- maps4fs/generator/tile.py,sha256=6zUpDidPcPRTGzQvYSNw-0Pj-if2WiakU2qb-40vyOk,2151
15
+ maps4fs/generator/tile.py,sha256=_UZ-iHGPghUfpYcG0OboquNczpZ1FaCVYpBgNLd72eo,2160
16
16
  maps4fs/toolbox/__init__.py,sha256=zZMLEkGzb4z0xql650gOtGSvcgX58DnJ2yN3vC2daRk,43
17
+ maps4fs/toolbox/background.py,sha256=9BXWNqs_n3HgqDiPztWylgYk_QM4YgBpe6_ZNQAWtSc,2154
17
18
  maps4fs/toolbox/dem.py,sha256=z9IPFNmYbjiigb3t02ZenI3Mo8odd19c5MZbjDEovTo,3525
18
- maps4fs-0.9.99.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
19
- maps4fs-0.9.99.dist-info/METADATA,sha256=e23P4VVbfJ9L9OvW0k1j9ppNIRDGAMUBW623o1n9-zM,25393
20
- maps4fs-0.9.99.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
21
- maps4fs-0.9.99.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
22
- maps4fs-0.9.99.dist-info/RECORD,,
19
+ maps4fs-1.0.0.dist-info/LICENSE.md,sha256=pTKD_oUexcn-yccFCTrMeLkZy0ifLRa-VNcDLqLZaIw,10749
20
+ maps4fs-1.0.0.dist-info/METADATA,sha256=x6wxcTW4FKrS_F7hrak7CcnB8aXCQ06MPkeR18YpjCM,26085
21
+ maps4fs-1.0.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
22
+ maps4fs-1.0.0.dist-info/top_level.txt,sha256=Ue9DSRlejRQRCaJueB0uLcKrWwsEq9zezfv5dI5mV1M,8
23
+ maps4fs-1.0.0.dist-info/RECORD,,