CARLA
 
载入中...
搜索中...
未找到
OpenDriveActor.h
浏览该文件的文档.
1// Copyright (c) 2019 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//预处理指令,用于确保这个头文件在单个编译单元中只被包含(include)一次。这有助于防止多重包含问题
8
9#include "GameFramework/Actor.h"
10
11#include "Traffic/RoutePlanner.h"//用于规划交通路线的类或函数的定义
12#include "Vehicle/VehicleSpawnPoint.h"//用于定义车辆生成点的类或函数
13
14#include "Components/BillboardComponent.h"
15#include "Components/SceneComponent.h"
16#include "CoreMinimal.h"//包含了Unreal Engine核心功能的一些基本定义和宏
17
18//由Unreal Engine的Unreal Header Tool(UHT)自动生成的,包含了OpenDriveActor类的反射系统所需的代码。反射系统允许Unreal Engine在运行时动态地查询和操作类的属性和方法
19#include "OpenDriveActor.generated.h"
20
21UCLASS()//这是一个宏,用于在Unreal Engine中声明一个类
22class CARLA_API AOpenDriveActor : public AActor // 定义AOpenDriveActor类,继承自AActor
23{
24 GENERATED_BODY()
25
26protected:
27
28 ///Billboard组件用于显示图标精灵。
29 UBillboardComponent *SpriteComponent;
30
31 /// Billboard组件使用的精灵
32 UTexture2D *SpriteTexture;
33
34private:
35
36 UPROPERTY() ///定义一个数组属性,存储VehicleSpawnPoint对象
37 TArray<AVehicleSpawnPoint *> VehicleSpawners;
38
39#if WITH_EDITORONLY_DATA
40 /// 使用OpenDrive文件生成道路网络(文件名与当前.umap相同)
41 ///
42 UPROPERTY(Category = "Generate", EditAnywhere)
43 bool bGenerateRoutes = false;
44#endif // WITH_EDITORONLY_DATA
45
46 /// 车辆行驶的路径点之间的距离。
47 UPROPERTY(Category = "Generate", EditAnywhere, meta = (ClampMin = "0.01", UIMin = "0.01"))
48 float RoadAccuracy = 2.f;
49
50 ///触发器的高程
51 UPROPERTY(Category = "Generate", EditAnywhere, meta = (ClampMin = "0.01", UIMin = "0.01"))
52 float TriggersHeight = 100.f;
53
54#if WITH_EDITORONLY_DATA ///如果编译时包含编辑器数据。
55 /// 移除之前生成的道路网络,如果需要也会移除生成器
56 ///
57 UPROPERTY(Category = "Generate", EditAnywhere)
58 bool bRemoveRoutes = false;
59#endif // WITH_EDITORONLY_DATA
60
61 /// 如果为true,在生成路径时放置生成器。
62 UPROPERTY(Category = "Spawners", EditAnywhere)
63 bool bAddSpawners = false;
64
65 /// 如果为true,在交叉路口也放置生成器
66 UPROPERTY(Category = "Spawners", EditAnywhere)
67 bool bOnIntersections = false;
68
69 /// 确定生成器放置的高度,相对于每个RoutePlanner。
70 ///
71 UPROPERTY(Category = "Spawners", EditAnywhere)
72 float SpawnersHeight = 300.f;
73
74#if WITH_EDITORONLY_DATA
75 ///如果需要,移除已经放置的生成器。
76 UPROPERTY(Category = "Spawners", EditAnywhere)
77 bool bRemoveCurrentSpawners = false;
78#endif // WITH_EDITORONLY_DATA
79
80#if WITH_EDITORONLY_DATA
81 /// 显示/隐藏额外的调试信息
82 UPROPERTY(Category = "Debug", EditAnywhere)
83 bool bShowDebug = true;
84#endif // WITH_EDITORONLY_DATA
85
86public:
87
88 AOpenDriveActor(const FObjectInitializer &ObjectInitializer);/// 构造函数
89
90 void BuildRoutes();/// 构建路径
91
92 void BuildRoutes(FString MapName); ///根据地图名称构建路径
93
94 /// 移除这个类之前生成的所有ARoutePlanner和VehicleSpawners以避免重叠
95 ///
96 void RemoveRoutes();
97
98 void DebugRoutes() const;// 调试路径
99
100 void RemoveDebugRoutes() const;
101
102#if WITH_EDITOR
103 void PostEditChangeProperty(struct FPropertyChangedEvent &PropertyChangedEvent);// 属性改变后的处理
104
105#endif // WITH_EDITOR
106
107 void AddSpawners(); // 添加生成器
108
109 void RemoveSpawners(); // 移除生成器
110
111 UPROPERTY() // 定义一个数组属性,存储RoutePlanner对象
112 TArray<ARoutePlanner *> RoutePlanners;
113};
UBillboardComponent * SpriteComponent
Billboard组件用于显示图标精灵。
UTexture2D * SpriteTexture
Billboard组件使用的精灵
为每个进入触发体积的 ACarlaWheeledVehicle 分配一条随机路线。 将此参与者放入世界后,必须在编辑器中添加路线。样条线切线将被忽略,仅考虑位置来制定路线。
Base class for spawner locations for walkers.