forest_gen Module

class forest_gen.ForestGenSpec(asset_path: str, size: int = 256, margin: int = 10, traversability_cfg: TraversabilityConfig | None = None)

Bases: SceneSpec

A specification for generating a forest scene.

generate() HeightmapTerrain

Generate a terrain instance. This method is used to generate the terrain for the scene.

While implementing this method, you can store extra data in the returned object, that then can be used by the asset specifications, thus allowing for more performant scene generation, where interesting spots encountered during terrain generation can be used to place assets.

Returns:

The generated terrain instance

Return type:

TerrainInstance

class forest_gen.HeightmapTerrain(mesh: list[tuple[trimesh.Trimesh, list[tuple[str, str]]]], origin: tuple[float, float, float], size: tuple[float, float], raw: Terrain, traversability_cfg: TraversabilityConfig | None = None)

Bases: TerrainInstance

A wrapper over the TerrainInstance class, that holds the underlying heightmap Callable

class forest_gen.PlantSpec(path: str, sim_duration: int = 10, scene_density: float = 1.0, origin_margin: float = 10.0)

Bases: AssetSpec

Specification for generating all plant assets in a forest scene. One Spec to rule them all.

generate(terrain: HeightmapTerrain) list[AssetInstance]

Generate a list of instances based on the given terrain.

Parameters:

terrain (HeightmapTerrain) – The terrain instance on which to generate.

Returns:

A list of generated grass asset instances.

Return type:

list[AssetInstance]

forest_gen.assets submodule

Submodule providing various asset-related functions.

class forest_gen.assets.PlantModelFactory(scale: float = 0.1, path: str = '../forest-gen/forest_gen/models')

Bases: object

Factory for loading and caching plant asset meshes.

Acts as a facade over asset loading to decouple simulation logic from concrete asset formats and caching behavior.

get_model(plant: Plant) AssetMesh

Retrieve the asset model for a plant instance.

Parameters:

plant (Plant) – Plant instance.

Returns:

Loaded asset mesh.

Return type:

AssetMesh

get_model_by_name(name: str, age: int) AssetMesh

Retrieve or load a plant model by species name and age.

Models are cached by (name, age) to avoid repeated loads.

Parameters:
  • name (str) – Species name.

  • age (int) – Plant age.

Returns:

Loaded asset mesh.

Return type:

AssetMesh

get_usdz_model_by_name(name: str, age: int, scale_mult: float = 1) AssetMesh

Retrieve or load a USDZ plant model by species name and age.

Parameters:
  • name (str) – Species name.

  • age (int) – Plant age.

  • scale_mult (float) – Additional scale multiplier.

Returns:

Loaded asset mesh.

Return type:

AssetMesh