Generates a random city using the meshes provided. More...
#include <CityMapGenerator.h>
Public Member Functions | |
Constructor and destructor | |
ACityMapGenerator (const FObjectInitializer &ObjectInitializer) | |
~ACityMapGenerator () | |
Overriden from UObject | |
virtual void | PreSave (const ITargetPlatform *TargetPlatform) override |
Public Member Functions inherited from ACityMapMeshHolder | |
ACityMapMeshHolder (const FObjectInitializer &ObjectInitializer) | |
Initializes the mesh holders. More... | |
Private Member Functions | |
Overriden from ACityMapMeshHolder | |
virtual void | UpdateMap () override |
Here does nothing, implement in derived classes. More... | |
Map construction and update related methods | |
void | UpdateSeeds () |
Update the random seeds. Generate random if no fixed seed is used. More... | |
void | GenerateGraph () |
Regenerate the DCEL. More... | |
void | GenerateRoads () |
Add the road meshes to the scene based on the current DCEL. More... | |
void | GenerateRoadMap () |
Generate the road map image and save to disk if requested. More... | |
Private Attributes | |
Map generation properties | |
uint32 | MapSizeX = 20u |
Size X of the map in map units. More... | |
uint32 | MapSizeY = 20u |
Size Y of the map in map units. More... | |
bool | bGenerateRoads = true |
If false, no mesh is added, only the internal representation of road is generated. More... | |
bool | bUseFixedSeed = true |
If false, a random seed is generated each time. More... | |
int32 | Seed = 123456789 |
Seed of the random map generated. More... | |
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). More... | |
uint32 | PixelsPerMapUnit = 50u |
The resolution in pixels per map unit of the road map. More... | |
bool | bLeftHandTraffic = false |
Whether the road map should be generated based on left-hand traffic. More... | |
bool | bSaveRoadMapToDisk = true |
If true, the road map encoded as an image is saved to disk. More... | |
bool | bDrawDebugPixelsToLevel = false |
If true, a debug point is drawn in the level for each pixel of the road map. More... | |
bool | bGenerateRoadMapOnSave = true |
The road map is re-computed on save so we always store an up-to-date version. More... | |
bool | bTagForSemanticSegmentation = false |
If true, activate the custom depth pass of each tagged actor in the level. More... | |
URoadMap * | RoadMap |
URoadMap * | GetRoadMap () |
Additional Inherited Members | |
Protected Member Functions inherited from ACityMapMeshHolder | |
void | AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y) |
Add an instance of a mesh with a given tile location. More... | |
void | AddInstance (ECityMapMeshTag Tag, uint32 X, uint32 Y, float Angle) |
Add an instance of a mesh with a given tile location and rotation. More... | |
void | AddInstance (ECityMapMeshTag Tag, FTransform Transform) |
Add an instance of a mesh with a given transform. More... | |
float | GetMapScale () const |
UStaticMesh * | GetStaticMesh (ECityMapMeshTag Tag) |
Return the static mesh corresponding to Tag. More... | |
const UStaticMesh * | GetStaticMesh (ECityMapMeshTag Tag) const |
Return the static mesh corresponding to Tag. More... | |
ECityMapMeshTag | GetTag (const UStaticMesh &StaticMesh) const |
Return the tag corresponding to StaticMesh. More... | |
FVector | GetTileLocation (uint32 X, uint32 Y) const |
Return the 3D world location (relative to this actor) of the given 2D tile. More... | |
virtual void | OnConstruction (const FTransform &Transform) override |
Initializes the instantiators. More... | |
virtual void | PostInitializeComponents () override |
void | SetStaticMesh (ECityMapMeshTag Tag, UStaticMesh *Mesh) |
Set the static mesh associated with Tag. More... | |
Generates a random city using the meshes provided.
Definition at line 22 of file CityMapGenerator.h.
ACityMapGenerator::ACityMapGenerator | ( | const FObjectInitializer & | ObjectInitializer | ) |
Definition at line 51 of file CityMapGenerator.cpp.
References RoadMap.
ACityMapGenerator::~ACityMapGenerator | ( | ) |
Definition at line 57 of file CityMapGenerator.cpp.
|
private |
Regenerate the DCEL.
Definition at line 109 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 262 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 153 of file CityMapGenerator.cpp.
References ADD_INTERSECTION, ACityMapMeshHolder::AddInstance(), Dcel, CityMapMeshTag::GetRoadIntersectionSize(), FHalfEdgeCounter::Insert(), min(), MapGen::TIntersection, MapGen::Turn90Deg, and MapGen::XIntersection.
Referenced by UpdateMap().
|
inline |
Definition at line 62 of file CityMapGenerator.h.
|
overridevirtual |
Definition at line 63 of file CityMapGenerator.cpp.
References bGenerateRoadMapOnSave, GenerateRoadMap(), and RoadMap.
|
overrideprivatevirtual |
Here does nothing, implement in derived classes.
Reimplemented from ACityMapMeshHolder.
Definition at line 83 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 100 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 152 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 159 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 109 of file CityMapGenerator.h.
Referenced by UpdateMap().
|
private |
Whether the road map should be generated based on left-hand traffic.
Definition at line 140 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 146 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 167 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 130 of file CityMapGenerator.h.
Referenced by UpdateMap().
|
private |
If false, a random seed is generated each time.
Definition at line 113 of file CityMapGenerator.h.
Referenced by UpdateSeeds().
|
private |
Definition at line 179 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and GenerateRoads().
|
private |
Definition at line 181 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 97 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 103 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 136 of file CityMapGenerator.h.
Referenced by GenerateRoadMap().
|
private |
Definition at line 170 of file CityMapGenerator.h.
Referenced by ACityMapGenerator(), GenerateRoadMap(), and PreSave().
|
private |
Seed of the random map generated.
Definition at line 117 of file CityMapGenerator.h.
Referenced by GenerateGraph(), and UpdateSeeds().