Skip to content

Commit

Permalink
Integrated FS25 template.
Browse files Browse the repository at this point in the history
  • Loading branch information
iwatkot committed Nov 22, 2024
1 parent 2811c0e commit 76e71d6
Show file tree
Hide file tree
Showing 7 changed files with 363 additions and 24 deletions.
Binary file added data/fs25-map-template.zip
Binary file not shown.
197 changes: 197 additions & 0 deletions data/fs25-texture-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
[
{
"name": "asphalt",
"count": 2,
"tags": { "highway": ["motorway", "trunk", "primary"] },
"width": 8,
"color": [70, 70, 70]
},
{
"name": "asphaltCracks",
"count": 2
},
{
"name": "asphaltDirt",
"count": 2
},
{
"name": "asphaltDusty",
"count": 2
},
{
"name": "asphaltGravel",
"count": 2
},
{
"name": "asphaltTwigs",
"count": 2
},
{
"name": "concrete",
"count": 2,
"tags": { "building": true },
"width": 8,
"color": [130, 130, 130]
},
{
"name": "concreteGravelSand",
"count": 2
},
{
"name": "concretePebbles",
"count": 2
},
{
"name": "concreteShattered",
"count": 2
},
{
"name": "forestGrass",
"count": 2
},
{
"name": "forestLeaves",
"count": 2
},
{
"name": "forestNeedels",
"count": 2
},
{
"name": "forestRockRoots",
"count": 2,
"exclude_weight": true
},
{
"name": "grass",
"count": 2,
"tags": { "natural": "grassland" },
"color": [34, 255, 34]
},
{
"name": "grassClovers",
"count": 2
},
{
"name": "grassCut",
"count": 2
},
{
"name": "grassDirtPatchy",
"count": 2,
"tags": { "natural": ["wood", "tree_row"] },
"width": 2,
"color": [0, 252, 124]
},
{
"name": "grassDirtPatchyDry",
"count": 2
},
{
"name": "grassDirtStones",
"count": 2
},
{
"name": "grassFreshMiddle",
"count": 2
},
{
"name": "grassFreshShort",
"count": 2
},
{
"name": "grassMoss",
"count": 2
},
{
"name": "gravel",
"count": 2,
"tags": { "highway": ["secondary", "tertiary", "road"] },
"width": 4,
"color": [140, 180, 210]
},
{
"name": "gravelDirtMoss",
"count": 2
},
{
"name": "gravelPebblesMoss",
"count": 2
},
{
"name": "gravelPebblesMossPatchy",
"count": 2
},
{
"name": "gravelSmall",
"count": 2
},
{
"name": "mudDark",
"count": 2,
"tags": { "highway": ["unclassified", "residential", "track"] },
"width": 2,
"color": [33, 67, 101]
},
{
"name": "mudDarkGrassPatchy",
"count": 2
},
{
"name": "mudDarkMossPatchy",
"count": 2
},
{
"name": "mudLeaves",
"count": 2
},
{
"name": "mudLight",
"count": 2
},
{
"name": "mudPebbles",
"count": 2
},
{
"name": "mudPebblesLight",
"count": 2
},
{
"name": "mudTracks",
"count": 2
},
{
"name": "pebblesForestGround",
"count": 2
},
{
"name": "rock",
"count": 2
},
{
"name": "rockFloorTiles",
"count": 2
},
{
"name": "rockFloorTilesPattern",
"count": 2
},
{
"name": "rockForest",
"count": 2
},
{
"name": "rockyForestGround",
"count": 2,
"tags": { "landuse": "farmland" },
"color": [47, 107, 85]
},
{
"name": "sand",
"count": 2,
"tags": { "natural": "water", "waterway": true },
"width": 10,
"color": [255, 20, 20]
}
]
6 changes: 6 additions & 0 deletions maps4fs/generator/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def process(self) -> None:
cv2.imwrite(self._dem_path, resampled_data)
self.logger.debug("DEM data was saved to %s.", self._dem_path)

if self.game.additional_dem_name is not None:
dem_directory = os.path.dirname(self._dem_path)
additional_dem_path = os.path.join(dem_directory, self.game.additional_dem_name)
shutil.copyfile(self._dem_path, additional_dem_path)
self.logger.debug("Additional DEM data was copied to %s.", additional_dem_path)

def _tile_info(self, lat: float, lon: float) -> tuple[str, str]:
"""Returns latitude band and tile name for SRTM tile from coordinates.
Expand Down
53 changes: 52 additions & 1 deletion maps4fs/generator/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Game:

code: str | None = None
dem_multipliyer: int = 1
_additional_dem_name: str | None = None
_map_template_path: str | None = None
_texture_schema: str | None = None

Expand Down Expand Up @@ -102,6 +103,24 @@ def dem_file_path(self, map_directory: str) -> str:
"""
raise NotImplementedError

def weights_dir_path(self, map_directory: str) -> str:
"""Returns the path to the weights directory.
Arguments:
map_directory (str): The path to the map directory.
Returns:
str: The path to the weights directory."""
raise NotImplementedError

@property
def additional_dem_name(self) -> str | None:
"""Returns the name of the additional DEM file.
Returns:
str | None: The name of the additional DEM file."""
return self._additional_dem_name


class FS22(Game):
"""Class used to define the game version FS22."""
Expand All @@ -120,12 +139,23 @@ def dem_file_path(self, map_directory: str) -> str:
str: The path to the DEM file."""
return os.path.join(map_directory, "maps", "map", "data", "map_dem.png")

def weights_dir_path(self, map_directory: str) -> str:
"""Returns the path to the weights directory.
Arguments:
map_directory (str): The path to the map directory.
Returns:
str: The path to the weights directory."""
return os.path.join(map_directory, "maps", "map", "data")


class FS25(Game):
"""Class used to define the game version FS25."""

code = "FS25"
dem_multipliyer: int = 2
_additional_dem_name = "unprocessedHeightMap.png"
_map_template_path = os.path.join(working_directory, "data", "fs25-map-template.zip")
_texture_schema = os.path.join(working_directory, "data", "fs25-texture-schema.json")

Expand All @@ -137,4 +167,25 @@ def dem_file_path(self, map_directory: str) -> str:
Returns:
str: The path to the DEM file."""
return os.path.join(map_directory, "maps", "map", "data", "dem.png")
return os.path.join(map_directory, "mapUS", "data", "dem.png")

def map_xml_path(self, map_directory: str) -> str:
"""Returns the path to the map.xml file.
Arguments:
map_directory (str): The path to the map directory.
Returns:
str: The path to the map.xml file.
"""
return os.path.join(map_directory, "mapUS", "mapUS.xml")

def weights_dir_path(self, map_directory: str) -> str:
"""Returns the path to the weights directory.
Arguments:
map_directory (str): The path to the map directory.
Returns:
str: The path to the weights directory."""
return os.path.join(map_directory, "mapUS", "data")
Loading

0 comments on commit 76e71d6

Please sign in to comment.