Feature Builders
The LightshipMap
prefab uses configurable feature builders for generating and rendering meshes for map tiles features.
There are five base types of feature builders:
- GroundBuilder builds the default ground mesh.
- StructureFeatureBuilder builds structures.
- AreaFeatureBuilder builds areas of land and water.
- LinearFeatureBuilder builds linear features such as highways, roads, paths, streams and rivers.
Each feature builder builds for a configured map layer and a configured list of features belonging to the category of each map layer. In feature builders, layer names are prefixed with LAYER_
, and feature kind names are prefixed with KIND_
.
AreaFeatureBuilderAsync, GroundBuilderAsync, and LinearFeatureBuilderAsync are performance versions of their respective builders.
In a future release, these classes will be renamed to remove the term 'Async' as they are not truly asynchronous.
Each theme comes configured with a set of builders to handle certain aspects of areas and linear features, along with a generic ground and structure builder:
Ground: GroundBuilderAsync
Structures: BuildingBuilderAsync
Areas: ParkBuilderAsync, WaterAreaBuilderAsync, ParkingBuilderAsync, TransitAreaBuilderAsync, SandBuilderAsync
Linear Features: HighwayBuilderAsync, PathBuilderAsync, RoadBuilderAsync, WaterLinearBuilderAsync, TransitLinearBuilderAsync
Each builder type has these properties:
- Script - The script to excute for the builder.
- Builder Name - The name of the builder, which will be associated with the meshes it generates. Must be unique within a project.
- Min LOD - The Minimum Level Of Detail. The lowest zoom level of map tiles.
- Max LOD - The Maximum Level Of Detail. The highest zoom level of map tiles.
- Z Offset - An optional offset from the ground plane to mitigate Z-fighting.
- Materials - A list of materials used by the builder.
- Map Layer - The map layer kind to build features for.
- Features for Layer - The list of feature kinds to build. If the list is blank, render all the features.
GroundBuilderAsync
The GroundBuilderAsync uses Undefined as its map layer. It builds all features.
BuildingBuilderAsync
The BuildingBuilderAsync uses the Buildings layer. It builds all features. It also adds these properties:
- Min Height - The minimum height of rendered buildings.
- Max Height - The maximum height of rendered buildings.
AreaFeatureBuilderAsync
ParkBuilderAsync, WaterAreaBuilderAsync, ParkingBuilderAsync, TransitAreaBuilderAsync, and SandBuilderAsync are predefined area builders that are in included in the base theme prefab.
Each of the predefined area builders has a chosen layer and a set of features for that layer.
LinearFeatureBuilderAsync
HighwayBuilderAsync, PathBuilderAsync, RoadBuilderAsync, WaterLinearBuilderAsync, and TransitLinearBuilderAsync are predefined linear feature builders tha are included in the base theme prefab.
Each of the predefined linear feature builders has a chosen layer and a set of features for that layer. LinearFeatureBuildAsync adds these properties:
- Smooth Linear Feature Knobs
- End Cap Point Count - The number of vertices for the rounded “cap” at the end of a road.
- Bend Threshold - Roads with bends that are sharper, or greater, than this threshold (
cos(x)
in degrees) have their outer edges smoothed with more vertices. - Smooth Factor - Smooths the edge between where two line segments of a road meet. A higher factor adds more vertices for a rounder geometry.
- Linear Feature Size Settings
- Linear Feature Size - A set of predefined minimum and maximum values used to calculate the width of a linear feature. The values can be found and adjusted in the
LinearFeatureSizeSettings.cs
file. This helps to make it easier to set values for multiple Linear Feature Builders. There are Small, Medium, and Large preset values. You can also set a custom value by selecting the Custom option in the dropdown.- Custom Linear Feature Min - How narrow a linear feature should be based on the map's current zoom level and Maptile size.
- Custom Linear Feature Max - How wide a linear feature should be based on the map's current zoom level and Maptile size.
- Minimum Width - The minimum width of a linear feature.
- Maximum Width - The maximum width of a linear feature.
- Linear Feature Size - A set of predefined minimum and maximum values used to calculate the width of a linear feature. The values can be found and adjusted in the
Level of Detail
Level of detail controls the zoom level of the map. The Min LOD
control allows you to control the lowest level of detail in the map (when the map is zoomed out). The Max LOD
control allows you to control the highest level of detail in the map (when the map is zoomed in). You can set the level of detail through the Unity UI or by setting the MinLOD
and MaxLOD
properties on a builder class.