CARLA
 
载入中...
搜索中...
未找到
CityMapGenerator.h
浏览该文件的文档.
1// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once
8
10
12#include "MapGen/GraphParser.h"
13
14#include "CityMapGenerator.generated.h"
15
16class URoadMap;
17
18/// Generates a random city using the meshes provided.
19///
20/// @note At this point it only generates roads and sidewalks.
21UCLASS(HideCategories=(Input,Rendering,Actor))
22class CARLA_API ACityMapGenerator : public ACityMapMeshHolder
23{
24 GENERATED_BODY()
25
26 // ===========================================================================
27 /// @name Constructor and destructor
28 // ===========================================================================
29 /// @{
30public:
31
32 ACityMapGenerator(const FObjectInitializer& ObjectInitializer);
33
35
36 /// @}
37 // ===========================================================================
38 /// @name Overriden from UObject
39 // ===========================================================================
40 /// @{
41public:
42
43 virtual void PreSave(const ITargetPlatform *TargetPlatform) override;
44
45 /// @}
46 // ===========================================================================
47 /// @name Overriden from ACityMapMeshHolder
48 // ===========================================================================
49 /// @{
50private:
51
52 virtual void UpdateMap() override;
53
54 /// @}
55 // ===========================================================================
56 /// @name Road map
57 // ===========================================================================
58 /// @{
59public:
60
61 UFUNCTION(BlueprintCallable)
62 URoadMap *GetRoadMap()
63 {
64 return RoadMap;
65 }
66
67 /// @}
68 // ===========================================================================
69 /// @name Map construction and update related methods
70 // ===========================================================================
71 /// @{
72private:
73
74 /// Update the random seeds. Generate random if no fixed seed is used.
75 void UpdateSeeds();
76
77 /// Regenerate the DCEL.
78 void GenerateGraph();
79
80 /// Add the road meshes to the scene based on the current DCEL.
81 void GenerateRoads();
82
83 /// Generate the road map image and save to disk if requested.
84 void GenerateRoadMap();
85
86 /// @}
87 // ===========================================================================
88 /// @name Map generation properties
89 // ===========================================================================
90 /// @{
91private:
92
93 /** Size X of the map in map units. The map unit is calculated based in the
94 * tile mesh of the road (see Map Scale).
95 */
96 UPROPERTY(Category = "Map Generation", EditAnywhere, meta = (ClampMin = "10", ClampMax = "200"))
97 uint32 MapSizeX = 20u;
98
99 /** Size Y of the map in map units. The map unit is calculated based in the
100 * tile mesh of the road (see Map Scale).
101 */
102 UPROPERTY(Category = "Map Generation", EditAnywhere, meta = (ClampMin = "10", ClampMax = "200"))
103 uint32 MapSizeY = 20u;
104
105 /** If false, no mesh is added, only the internal representation of road is
106 * generated.
107 */
108 UPROPERTY(Category = "Map Generation", EditAnywhere)
109 bool bGenerateRoads = true;
110
111 /** If false, a random seed is generated each time. */
112 UPROPERTY(Category = "Map Generation", EditAnywhere)
113 bool bUseFixedSeed = true;
114
115 /** Seed of the random map generated. */
116 UPROPERTY(Category = "Map Generation", EditAnywhere, meta = (EditCondition = bUseFixedSeed))
117 int32 Seed = 123456789;
118
119 /// @}
120 // ===========================================================================
121 /// @name Road Map
122 // ===========================================================================
123 /// @{
124private:
125
126 /** Trigger the generation a the road map image of the current layout (used
127 * for off-road and opposite lane invasion detection).
128 */
129 UPROPERTY(Category = "Road Map", EditAnywhere)
130 bool bTriggerRoadMapGeneration = false;
131
132 /** The resolution in pixels per map unit of the road map. The map unit is
133 * calculated based in the tile mesh of the road (see Map Scale).
134 */
135 UPROPERTY(Category = "Road Map", EditAnywhere, meta = (ClampMin = "1", ClampMax = "500"))
136 uint32 PixelsPerMapUnit = 50u;
137
138 /** Whether the road map should be generated based on left-hand traffic. */
139 UPROPERTY(Category = "Road Map", EditAnywhere)
140 bool bLeftHandTraffic = false;
141
142 /** If true, the road map encoded as an image is saved to disk. The image is
143 * saved to the "Saved" folder of the project.
144 */
145 UPROPERTY(Category = "Road Map", EditAnywhere)
146 bool bSaveRoadMapToDisk = true;
147
148 /** If true, a debug point is drawn in the level for each pixel of the road
149 * map.
150 */
151 UPROPERTY(Category = "Road Map", EditAnywhere)
152 bool bDrawDebugPixelsToLevel = false;
153
154 /** The road map is re-computed on save so we always store an up-to-date
155 * version. Uncheck this only for testing purposes as the road map might get
156 * out-of-sync with the current road layout.
157 */
158 UPROPERTY(Category = "Road Map", EditAnywhere, AdvancedDisplay)
159 bool bGenerateRoadMapOnSave = true;
160
161 /** If true, activate the custom depth pass of each tagged actor in the level.
162 * This pass is necessary for rendering the semantic segmentation. However,
163 * it may add a performance penalty since occlusion doesn't seem to be
164 * applied to objects having this value active.
165 */
166 UPROPERTY(Category = "Road Map", EditAnywhere, AdvancedDisplay)
167 bool bTagForSemanticSegmentation = false;
168
169 UPROPERTY()
170 URoadMap *RoadMap;
171
172 /// @}
173 // ===========================================================================
174 /// @name Other private members
175 // ===========================================================================
176 /// @{
177private:
178
179 TUniquePtr<MapGen::DoublyConnectedEdgeList> Dcel;
180
181 TUniquePtr<MapGen::GraphParser> DcelParser;
182 /// @}
183};
Generates a random city using the meshes provided.
Holds the static meshes and instances necessary for building a city map.
Road map of the level.
Definition RoadMap.h:91