|
CARLA
|
Generates a random city using the meshes provided. More...
#include <CityMapGenerator.h>
Inheritance diagram for ACityMapGenerator:Public Member Functions | |
Constructor and destructor | |
| ACityMapGenerator (const FObjectInitializer &ObjectInitializer) | |
| ~ACityMapGenerator () | |
Overriden from UObject | |
| virtual void | PreSave (FObjectPreSaveContext ObjectSaveContext) override |
Public Member Functions inherited from ACityMapMeshHolder | |
| ACityMapMeshHolder (const FObjectInitializer &ObjectInitializer) | |
| Initializes the mesh holders. | |
Private Member Functions | |
Overriden from ACityMapMeshHolder | |
| virtual void | UpdateMap () override |
| Here does nothing, implement in derived classes. | |
Map construction and update related methods | |
| void | UpdateSeeds () |
| Update the random seeds. Generate random if no fixed seed is used. | |
| void | GenerateGraph () |
| Regenerate the DCEL. | |
| void | GenerateRoads () |
| Add the road meshes to the scene based on the current DCEL. | |
| void | GenerateRoadMap () |
| Generate the road map image and save to disk if requested. | |
Private Attributes | |
Map generation properties | |
| uint32 | MapSizeX = 20u |
| Size X of the map in map units. | |
| uint32 | MapSizeY = 20u |
| Size Y of the map in map units. | |
| bool | bGenerateRoads = true |
| If false, no mesh is added, only the internal representation of road is generated. | |
| bool | bUseFixedSeed = true |
| If false, a random seed is generated each time. | |
| int32 | Seed = 123456789 |
| Seed of the random map generated. | |
Other private members | |
| TUniquePtr< MapGen::DoublyConnectedEdgeList > | Dcel |
| TUniquePtr< MapGen::GraphParser > | DcelParser |
Road map | |
| bool | bTriggerRoadMapGeneration = false |
| Trigger the generation a the road map image of the current layout (used for off-road and opposite lane invasion detection). | |
| uint32 | PixelsPerMapUnit = 50u |
| The resolution in pixels per map unit of the road map. | |
| bool | bLeftHandTraffic = false |
| Whether the road map should be generated based on left-hand traffic. | |
| bool | bSaveRoadMapToDisk = true |
| If true, the road map encoded as an image is saved to disk. | |
| bool | bDrawDebugPixelsToLevel = false |
| If true, a debug point is drawn in the level for each pixel of the road map. | |
| bool | bGenerateRoadMapOnSave = true |
| The road map is re-computed on save so we always store an up-to-date version. | |
| bool | bTagForSemanticSegmentation = false |
| If true, activate the custom depth pass of each tagged actor in the level. | |
| URoadMap * | RoadMap |
| URoadMap * | GetRoadMap () |
Additional Inherited Members | |
Protected Member Functions inherited from ACityMapMeshHolder | |
| void | AddInstance (ECityMapMeshTag Tag, FTransform Transform) |
| Add an instance of a mesh with a given transform. | |
| void | AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y) |
| Add an instance of a mesh with a given tile location. | |
| void | AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y, float Angle) |
| Add an instance of a mesh with a given tile location and rotation. | |
| float | GetMapScale () const |
| UStaticMesh * | GetStaticMesh (ECityMapMeshTag Tag) |
| Return the static mesh corresponding to Tag. | |
| const UStaticMesh * | GetStaticMesh (ECityMapMeshTag Tag) const |
| Return the static mesh corresponding to Tag. | |
| ECityMapMeshTag | GetTag (const UStaticMesh &StaticMesh) const |
| Return the tag corresponding to StaticMesh. | |
| FVector | GetTileLocation (uint32 X, uint32 Y) const |
| Return the 3D world location (relative to this actor) of the given 2D tile. | |
| virtual void | OnConstruction (const FTransform &Transform) override |
| Initializes the instantiators. | |
| virtual void | PostInitializeComponents () override |
| void | SetStaticMesh (ECityMapMeshTag Tag, UStaticMesh *Mesh) |
| Set the static mesh associated with Tag. | |
Generates a random city using the meshes provided.
Definition at line 25 of file CityMapGenerator.h.
| ACityMapGenerator::ACityMapGenerator | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 52 of file CityMapGenerator.cpp.
References RoadMap.
| ACityMapGenerator::~ACityMapGenerator | ( | ) |
Definition at line 58 of file CityMapGenerator.cpp.
|
private |
Regenerate the DCEL.
Definition at line 110 of file CityMapGenerator.cpp.
References Dcel, DcelParser, MapGen::GraphGenerator::Generate(), MapSizeX, MapSizeY, and Seed.
Referenced by UpdateMap().
|
private |
Generate the road map image and save to disk if requested.
Definition at line 263 of file CityMapGenerator.cpp.
References bDrawDebugPixelsToLevel, bLeftHandTraffic, bSaveRoadMapToDisk, bTagForSemanticSegmentation, ACityMapMeshHolder::GetMapScale(), CityMapMeshTag::GetRoadIntersectionSize(), ACityMapMeshHolder::GetTag(), LineTrace(), MapSizeX, MapSizeY, PixelsPerMapUnit, URoadMap::Reset(), RoadMap, URoadMap::SaveAsPNG(), URoadMap::SetPixelAt(), and ATagger::TagActorsInLevel().
Referenced by PreSave(), and UpdateMap().
|
private |
Add the road meshes to the scene based on the current DCEL.
Definition at line 154 of file CityMapGenerator.cpp.
References ADD_INTERSECTION, ACityMapMeshHolder::AddInstance(), Dcel, CityMapMeshTag::GetRoadIntersectionSize(), FHalfEdgeCounter::Insert(), node, MapGen::TIntersection, MapGen::Turn90Deg, x, MapGen::XIntersection, and y.
Referenced by UpdateMap().
|
inline |
Definition at line 65 of file CityMapGenerator.h.
|
overridevirtual |
Definition at line 64 of file CityMapGenerator.cpp.
References bGenerateRoadMapOnSave, GenerateRoadMap(), and RoadMap.
|
overrideprivatevirtual |
Here does nothing, implement in derived classes.
Reimplemented from ACityMapMeshHolder.
Definition at line 84 of file CityMapGenerator.cpp.
References bGenerateRoads, bTriggerRoadMapGeneration, GenerateGraph(), GenerateRoadMap(), GenerateRoads(), and UpdateSeeds().
|
private |
Update the random seeds. Generate random if no fixed seed is used.
Definition at line 101 of file CityMapGenerator.cpp.
References bUseFixedSeed, and Seed.
Referenced by UpdateMap().
|
private |
If true, a debug point is drawn in the level for each pixel of the road map.
Definition at line 155 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
The road map is re-computed on save so we always store an up-to-date version.
Uncheck this only for testing purposes as the road map might get out-of-sync with the current road layout.
Definition at line 162 of file CityMapGenerator.h.
Referenced by PreSave().
|
private |
If false, no mesh is added, only the internal representation of road is generated.
Definition at line 112 of file CityMapGenerator.h.
Referenced by UpdateMap().
|
private |
Whether the road map should be generated based on left-hand traffic.
Definition at line 143 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
If true, the road map encoded as an image is saved to disk.
The image is saved to the "Saved" folder of the project.
Definition at line 149 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
If true, activate the custom depth pass of each tagged actor in the level.
This pass is necessary for rendering the semantic segmentation. However, it may add a performance penalty since occlusion doesn't seem to be applied to objects having this value active.
Definition at line 170 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
Trigger the generation a the road map image of the current layout (used for off-road and opposite lane invasion detection).
Definition at line 133 of file CityMapGenerator.h.
Referenced by UpdateMap().
|
private |
If false, a random seed is generated each time.
Definition at line 116 of file CityMapGenerator.h.
Referenced by UpdateSeeds().
|
private |
Definition at line 182 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and GenerateRoads().
|
private |
Definition at line 184 of file CityMapGenerator.h.
Referenced by GenerateGraph().
|
private |
Size X of the map in map units.
The map unit is calculated based in the tile mesh of the road (see Map Scale).
Definition at line 100 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and GenerateRoadMap().
|
private |
Size Y of the map in map units.
The map unit is calculated based in the tile mesh of the road (see Map Scale).
Definition at line 106 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and GenerateRoadMap().
|
private |
The resolution in pixels per map unit of the road map.
The map unit is calculated based in the tile mesh of the road (see Map Scale).
Definition at line 139 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
Definition at line 173 of file CityMapGenerator.h.
Referenced by ACityMapGenerator(), GenerateRoadMap(), and PreSave().
|
private |
Seed of the random map generated.
Definition at line 120 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and UpdateSeeds().