CARLA
 
载入中...
搜索中...
未找到
CarlaLight.h
浏览该文件的文档.
1// Copyright (c) 2020 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// 包含禁用UE4宏的编译器指令
10// 包含carla的rpc LightState
12// 包含启用UE4宏的编译器指令
14
15#include "CoreMinimal.h"//CoreMinimal.h是虚幻引擎的一个基础头文件。
16#include "Components/ActorComponent.h"//这表示这个源文件(假设是一个.cpp文件)正在包含ActorComponent.h头文件。
17#include "CarlaLight.generated.h"//这是一个自定义的头文件
18
19
20// 将carla的rpc枚举值转换为UE4的枚举值
21#define CARLA_ENUM_FROM_RPC(e) static_cast<uint8>(carla::rpc::LightState::LightGroup:: e)
22// 定义一个枚举类型,用于表示不同类型的灯光
23UENUM(BlueprintType)
24enum class ELightType : uint8
25{
26 Null = 0, // UE4.24 枚举问题的解决方法
27 Vehicle = CARLA_ENUM_FROM_RPC(Vehicle) UMETA(DisplayName = "Vehicle"),
28 Street = CARLA_ENUM_FROM_RPC(Street) UMETA(DisplayName = "Street"),
29 Building = CARLA_ENUM_FROM_RPC(Building) UMETA(DisplayName = "Building"),
30 Other = CARLA_ENUM_FROM_RPC(Other) UMETA(DisplayName = "Other"),
31};
32// 取消宏定义,以便在其他地方重新使用
33#undef CARLA_ENUM_FROM_RPC
34
35// 表示场景中灯光的类
36UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
37class CARLA_API UCarlaLight : public UActorComponent
38{
39 GENERATED_BODY()
40
41public:
42 // 构造函数
43 UCarlaLight();
44// 当组件开始播放时调用
45 void BeginPlay() override;
46 // 当组件结束播放时调用
47 void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
48// 当组件被销毁时调用
49 void OnComponentDestroyed(bool bDestroyingHierarchy) override;
50// 注册灯光的蓝图可调用函数
51 UFUNCTION(BlueprintCallable, Category = "Carla Light")
52 void RegisterLight();
53 // 更新灯光的蓝图可实现事件
54 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
55 void UpdateLights();
56// 根据天气注册灯光的蓝图可实现事件
57 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
58 void RegisterLightWithWeather();
59// 设置灯光强度的蓝图可调用函数
60 UFUNCTION(BlueprintCallable, Category = "Carla Light")
61 void SetLightIntensity(float Intensity);
62// 获取灯光强度的蓝图纯函数
63 UFUNCTION(BlueprintPure, Category = "Carla Light")
64 float GetLightIntensity() const;
65 // 设置灯光颜色的蓝图可调用函数
66 UFUNCTION(BlueprintCallable, Category = "Carla Light")
67 void SetLightColor(FLinearColor Color);
68// 获取灯光颜色的蓝图纯函数
69 UFUNCTION(BlueprintPure, Category = "Carla Light")
70 FLinearColor GetLightColor() const;
71 // 获取灯光开关状态的蓝图纯函数
72 UFUNCTION(BlueprintCallable, Category = "Carla Light")
73 void SetLightOn(bool bOn);
74 // 获取灯光开关状态的蓝图纯函数
75
76 UFUNCTION(BlueprintPure, Category = "Carla Light")
77 bool GetLightOn() const;
78 // 设置灯光类型的蓝图可调用函数
79 UFUNCTION(BlueprintCallable, Category = "Carla Light")
80 void SetLightType(ELightType Type);
81 // 获取灯光类型的蓝图纯函数
82 UFUNCTION(BlueprintPure, Category = "Carla Light")
83 ELightType GetLightType() const;
84// 获取carla的rpc LightState
85 carla::rpc::LightState GetLightState();
86// 设置carla的rpc LightState
87 void SetLightState(carla::rpc::LightState LightState);
88
89 // 获取灯光位置
90 FVector GetLocation() const;
91// 获取灯光ID的蓝图纯函数
92 UFUNCTION(BlueprintPure, Category = "Carla Light")
93 int GetId() const;
94// 设置灯光ID的蓝图可调用函数
95 UFUNCTION(BlueprintCallable, Category = "Carla Light")
96 void SetId(int InId);
97
98protected:
99 // 可编辑的属性,灯光类型
100 UPROPERTY(EditAnywhere, Category = "Carla Light")
101 ELightType LightTyp e = ELightType::Street;
102 // 可编辑的属性,灯光强度
103 UPROPERTY(EditAnywhere, Category = "Carla Light")
104 float LightIntensity;
105
106 // 可编辑的属性,灯光颜色
107 UPROPERTY(EditAnywhere, Category = "Carla Light")
108 FLinearColor LightColor;
109 // 可编辑的属性,灯光开关状态
110 UPROPERTY(EditAnywhere, Category = "Carla Light")
111 bool bLightOn;
112// 可编辑的属性,灯光ID
113 UPROPERTY(EditAnywhere, Category = "Carla Light")
114 int Id = -1;
115
116 private:
117// 记录灯光变化的私有函数
118 void RecordLightChange() const;
119// 标记灯光是否已注册
120 bool bRegistered = false;
121};
FVehicleLightState LightState
Definition ActorData.h:131
sode override
Definition ActorData.h:280
ELightType
Definition CarlaLight.h:25
#define CARLA_ENUM_FROM_RPC(e)
Definition CarlaLight.h:21
CARLA模拟器的主命名空间。
Definition Carla.cpp:139