Skip to content

Commit

Permalink
Overview generation info, DDS converters, tutorials
Browse files Browse the repository at this point in the history
* Components update, added scripts.

* Overview generation info.

* DDS converters.

* DDS converters.

* Requirements update.

* QGIS tutorial and README update.

* README update.

* README update.

* README update.

* Texture schema update.

* Blender tutorial.

* Giants Editor tutorial.
  • Loading branch information
iwatkot authored Nov 26, 2024
1 parent c722e95 commit d175eac
Show file tree
Hide file tree
Showing 15 changed files with 475 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy pylint opencv-python "osmnx<2.0.0" "fast-simplification" geopy trimesh rasterio pandas-stubs types-requests pytest pytest-cov
pip install mypy pylint opencv-python tifffile imageio "osmnx<2.0.0" "fast-simplification" geopy trimesh rasterio pandas-stubs types-requests pytest pytest-cov
- name: Run mypy to generate cache
run: mypy maps4fs || true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ WORKDIR /usr/src/app
COPY data /usr/src/app/data
COPY webui /usr/src/app/webui

RUN pip install "opencv-python" "pyproj" "folium" "geopy" "osmnx<2.0.0" "fast-simplification" "rasterio" "trimesh" "streamlit" "maps4fs"
RUN pip install "opencv-python" "pyproj" "tifffile" "imageio" "folium" "geopy" "osmnx<2.0.0" "fast-simplification" "rasterio" "trimesh" "streamlit" "maps4fs"

EXPOSE 8501

Expand Down
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<a href="#Supported-objects">Supported objects</a> •
<a href="#Generation-info">Generation info</a> •
<a href="#Texture-schema">Texture schema</a> •
<a href="#Background-terrain">Background terrain</a><br>
<a href="#Background-terrain">Background terrain</a> •
<a href="#Overview-image">Overview image</a><br>
<a href="#DDS-conversion">DDS conversion</a> •
<a href="#For-advanced-users">For advanced users</a> •
<a href="#Resources">Resources</a> •
<a href="#Bugs-and-feature-requests">Bugs and feature requests</a>
Expand Down Expand Up @@ -183,6 +185,31 @@ List of components:
Below you'll find descriptions of the components and the fields that they contain.<br>
ℹ️ If there's no information about the component, it means that at the moment it does not store any data in the `generation_info.json` file.

### Config
Example of the `Config` component:
```json
"Config": {
"Overview": {
"epsg3857_string": "2249906.6679576184,2255734.9033189337,5663700.389039194,5669528.6247056825 [EPSG:3857]",
"south": 45.304132173367165,
"west": 45.267296012425376,
"north": 20.263611405732693,
"east": 20.211255476687537,
"height": 4096,
"width": 4096
}
},
```
The `Overview` section contains information to create an overview image, which represents the in-game map. You can use the `epsg3857_string` to obtain the satellite images in the QGIS. So this section describes the region of the map plus the borders. Usually, it's exact 2X the size of the map.<br>
And here's the list of the fields:
- `"epsg3857_string"` - the string representation of the bounding box in the EPSG:3857 projection, it's required to obtain the satellite images in the QGIS,<br>
- `"south"` - the southern border of overview region,<br>
- `"west"` - the western border of overview region,<br>
- `"north"` - the northern border of overview region,<br>
- `"east"` - the eastern border of overview region,<br>
- `"height"` - the height of the overview region in meters (2X the size of the map),<br>
- `"width"` - the width of the overview region in meters,<br>

### Texture

Example of the `Texture` component:
Expand Down Expand Up @@ -315,6 +342,34 @@ If you're afraid of this task, please don't be. It's really simple and I've prep
2. [Prepare the i3d files](README_i3d.md).
3. [Import the i3d files to Giants Editor](README_giants_editor.md).

## Overview image
The overview image is an image that is used as in-game map. No matter what the size of the map, this file is always `4096x4096 pixels`, while the region of your map is `2048x2048 pixels` in center of this file. The rest of the image is just here for nice view, but you still may add satellite pictures to this region.<br>

<img width="400" src="https://github.com/user-attachments/assets/ede9ea81-ef97-4914-9dbf-9761ef1eb7ca">

Cool image by [@ZenJakey](https://github.com/ZenJakey).

So, the same way you've downloaded the satellite images for the background terrain, you can download them for the overview image. Just use the `epsg3857_string` from the `generation_info.json` file. You'll find the needed string in the `Config` component in the `Overview` section:

```json
"Config": {
"Overview": {
"epsg3857_string": "2249906.6679576184,2255734.9033189337,5663700.389039194,5669528.6247056825 [EPSG:3857]",
}
},
```

After it you need to resize the image to 4096x4096 pixels and convert it to the `.dds` format.

## DDS conversion
The `.dds` format is the format used in the Farming Simulator for the textures, icons, overview and preview images. There's a plenty of options to convert the images to the `.dds` format, you can just google something like `png to dds` and the first link probably will help you with it.<br>
But if you prefer using scripts, you'll find Python converters in the `scripts` directory in this repository.<br>

List of the important DDS files:
- `icon.dds` - 256x256 pixels, the icon of the map,
- `preview.dds` - 2048x2048 pixels, the preview image of the map on loading screen,
- `mapsUS/overview.dds` - 4096x4096 pixels, the overview image of the map (in-game map)

## For advanced users
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>

Expand All @@ -340,4 +395,4 @@ To create a basic map, you only need the Giants Editor. But if you want to creat
4. [QGIS](https://qgis.org/download/) - the open-source GIS software that you can use to obtain high-resolution satellite images for your map.

## Bugs and feature requests
If you find a bug or have an idea for a new feature, please create an issue [here](https://github.com/iwatkot/maps4fs/issues) or contact me directly on [Telegram](https://t.me/iwatkot).<br>
If you find a bug or have an idea for a new feature, please create an issue [here](https://github.com/iwatkot/maps4fs/issues) or contact me directly on [Telegram](https://t.me/iwatkot) or on Discord: `iwatkot`.
43 changes: 42 additions & 1 deletion README_giants_editor.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
It will be ready soon. Stay tuned!
## How to import background terrain into the Giants Editor

So, at this point, you should have the `*.i3d` files with the background terrain. Now, let's import them into the Giants Editor.

ℹ️ In this tutorials it's assumed that you have already generated the map, downloaded satellite images using this tutorial: [Download high-resolution satellite images](README_satellite_images.md), and created a background terrain as described in the previous tutorial: [Prepare the i3d files](README_i3d.md).

Here's what you need to do:

1. Download and install the Giants Editor from the official website: [https://gdn.giants-software.com/downloads.php](https://gdn.giants-software.com/downloads.php). Note that for working with a map for Farming Simulator 25, you need to use the Giants Editor 10.0.0 or later, while for Farming Simulator 22, you need to use the Giants Editor 9.0.0 or later. If you try to open the map for the editor of the wrong version, it will crash.

2. Open the main map file, for example for the Farming Simulator 25 it's a `mapUS/mapUS.i3d` file.

3. Click on the `File` menu and select `Import...` select the `*.i3d` file with the background terrain. Note, that aftet the import, the terrain will have no textures, so don't worry, it's ok.

![Import](https://github.com/user-attachments/assets/32145805-6583-4147-ac04-4c69d041b554)

4. Postition the terrain in the correct place. You can use the `Transform` panel to move, rotate, and scale the terrain.

![Position](https://github.com/user-attachments/assets/8202b2f5-2286-4213-8785-c3779e9ad88a)

5. Open the `Material Editing` panel (if it's not visible click on the `Window` menu and select `Material Editing`) and ensure that you've selected the correct object in the `Scenegraph` panel. Find the `Albedo map` and click on the `...` button to select the texture for the terrain.

![Albedo map](https://github.com/user-attachments/assets/20a197cd-dadf-4e61-8ad2-c6752d60fb17)

6. The new window will appear, click on the `...` button and select the texture for the terrain.

![Select the texture](https://github.com/user-attachments/assets/29940c6d-1c18-4077-a0f0-ce525a9bc503)

7. If you did not convert the textures to the `.dds` format, you will see the warning message asking you `Convert now?`. Click on the `Yes` button to convert the texture to the `.dds` format.

![Convert now](https://github.com/user-attachments/assets/1778363a-1701-4c49-9fc7-67a1e67b3257)

8. You should be able to see the texture on the terrain now. So now you only need to adjust the position of the terrain in the world.

![Terrain with texture](https://github.com/user-attachments/assets/a5da03a6-42b3-4010-997e-787c0d9bee38)

So, we'are done here.<br>
ℹ️ Please note, that is almost no way to align all background terrain with map perfectly without editing them in the 3D editor, Blender for example. You can find a lot of tutorials on YouTube on how to do it, this won't be covered here. Or you can just leave it as is and find the best possible position for the terrain, and maybe hiding the edges with some objects. It's up to you.<br>

If you want, you can go back to the previous step: [Prepare the i3d files](README_i3d.md).<br>

Happy mapping! 🚜🌾
82 changes: 81 additions & 1 deletion README_i3d.md
Original file line number Diff line number Diff line change
@@ -1 +1,81 @@
It will be ready soon. Stay tuned!
## How to create a background terrain

To create a background terrain for the Farming Simulator map, you need to open the `*.obj` files with the terrain, obtain the satellite images as described in the [Download high-resolution satellite images](README_satellite_images.md) tutorial to use them as textures and export your results to the `*.i3d` format.<br>

ℹ️ In this tutorials it's assumed that you have already generated the map and downloaded satellite images from the previous step: [Download high-resolution satellite images](README_satellite_images.md).<br>

Let's go straight to the deal:

1. Download and install the [Blender](https://www.blender.org/download/) software.
2. Download and install the [Blender Exporter Plugins](https://gdn.giants-software.com/downloads.php) from the official Giants Software website.
3. Activate the `Blender Exporter Plugins` in the Blender.
4. Now, you can import the `*.obj`. Go to `File` -> `Import` -> `Wavefront (.obj)` and select the `*.obj` file.

![Import obj](https://github.com/user-attachments/assets/0fea21f6-3f1e-40e1-9d3e-6844fbb9f0de)

5. Select the imported object, right-click on it, click on `Set Origin` -> `Origin to Geometry`.

![Origin to geometry](https://github.com/user-attachments/assets/379fd7b3-3b27-4b45-b9cc-e39218fa7a6b)

6. Click on the arrow icon or press the `N` key.

![413003](https://github.com/user-attachments/assets/c3b74d01-624a-4c1f-b5ad-ef620cbb33d4)

7. In the `Item` tab, change the `Location` to `0, 0, 0` and the `Rotation` to `0, 0, 0`.

![Transformation](https://github.com/user-attachments/assets/3fa04f93-12c2-420d-9313-a5cf0186e686)

8. Swtich to the `View` tab and change the `End` value to `10000` or something like that. It's just to make sure that the terrain is visible, otherwise it may partially disappear.

![Item end](https://github.com/user-attachments/assets/e838aa9c-09b7-4ede-b666-de83eb82fbbe)

9. Now we need to add a `Modifier` to the terrain. Click on the `Modifiers` tab, then click on the `Add Modifier`.

![Add modifier](https://github.com/user-attachments/assets/491c0d43-5f16-4a0e-b11c-a8e138107fbe)

10. In the dropdown menu, select the `Decimate` modifier.

![Select decimate](https://github.com/user-attachments/assets/1524ec71-a252-491e-8d39-84e7435980cd)

11. Now you need to adjust the `Ratio` value. The `Ratio` value will determine how much the terrain will be simplified. The lower the value, the more simplified the terrain will be. It depends on your actual terrain, but a good starting point is something like `0.5` and lower. Remember, that this is a background terrain, which almost not visible in the game, so it's quality doesn't really matter. And the more simplified the terrain is, the less resources it will consume.

![Apply decimate](https://github.com/user-attachments/assets/c7111d5d-a32a-4264-9810-bcfd948d8cd3)

12. Select the object, right-click on it, and select `Shade Smooth`. It will automatically smooth the terrain. Note that it may not work perfectly, so you may need to `Ctrl + Z` it, change the value of the `Decimate` modifier, and try again. And again: it's a background terrain, so it doesn't need to be perfect.

![Shade smooth](https://github.com/user-attachments/assets/b9b8f0ec-fea7-467e-8032-364c0d704efc)

The object should look more like a terrain now with the `Shade Smooth` applied.

![After shade smooth](https://github.com/user-attachments/assets/c3006eba-0e5b-470f-88be-04cab9dd4139)

13. It's time to add a material to the terrain. Click on the `Material Properties` tab, then click on the `New` button.

![Material](https://github.com/user-attachments/assets/b4a5ae03-b9ce-441f-925c-70ed7085ed7e)

14. Go to the `Surface` section, click on the `Base Color` **CIRCLE** (not the color itself), and select the `Image Texture`. Provide the path to the satellite image you want to use as a texture.

![Image texture](https://github.com/user-attachments/assets/ecbd8c35-80c9-4bfb-b384-2545aa8f0f63)

15. Go to the `Emission` section, click on the `Color` **THE COLOR ITSELF** now (not the circle), and select completely black color. Otherise, you wont be able to see the material in the Giants Editor.

![Emission](https://github.com/user-attachments/assets/cd6350cf-e7da-40ef-9e6d-fc6c551ce4d1)

16. Open the `UV Editing` tab, and in the right tab change the view to `Top` by pressing `7` on the numpad or holding the `Z` key and selecting the `Top`.

![UV editing](https://github.com/user-attachments/assets/55694f85-74ea-438a-b7ed-0f6eea7c5655)

17. Now ensure that the texture has a correct orientation relative to the terrain. If it's not, you can rotate the texture image before moving on. After you ensured that the texture is correctly oriented, switch to the right tab and select everything by pressing `A`. Everything on the right side should be selected (orange). Now press the `U` key and select one of the `Unwrap` options. Recommended one is `Unwrap` -> `Angle Based`. It should work fine for the most cases. The second one is Project from View (bounds). It will project the texture from the view you are currently in. Note that it should be done in the `Top` view, otherwise the texture may be projected incorrectly.

![Unwrap](https://github.com/user-attachments/assets/34973898-75fb-4f37-ba47-db26fba965b9)

18. Now return to the `Layout` tab, press and hold `Z` and select `Material Preview`. You should see the terrain with the texture applied. Now you can adjust the scale of the object in the `Transform` tab. Note, that you can do it later in the Giants Editor as well.

![Materail preview](https://github.com/user-attachments/assets/30f8434b-0e68-4b67-b39b-cdd91d2a68d1)

19. It's finally time to export our object as an `*.i3d` file. Open the side panel by pressing `N` and select the `GIANTS I3D Exporter` tab. If you can not see it here, that means you did not installed the `Blender Exporter Plugins` (step 2) or you did not activated it (step 3).
Now ensure that the object is selected [1], specify the path to the output file [3], and click on the `Export selected` button [4]. You can also use the `Export all` option, but ensure that you don't have any other objects in the scene, for example by default Blender adds a camera and a light source and a cube.

![Export to i3d](https://github.com/user-attachments/assets/ad3913d7-a16e-47c0-a039-9f792e34ad4c)

Now we can go to the final section of the tutorial: [Import the i3d files to Giants Editor](README_giants_editor.md). Or you can go back to the previous step: [Download high-resolution satellite images](README_satellite_images.md).
Loading

0 comments on commit d175eac

Please sign in to comment.