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
12
13#include "CoreMinimal.h"
14#include "Components/ActorComponent.h"
15#include "CarlaLight.generated.h"
16
17
18
19#define CARLA_ENUM_FROM_RPC(e) static_cast<uint8>(carla::rpc::LightState::LightGroup:: e)
20
21UENUM(BlueprintType)
22enum class ELightType : uint8
23{
24 Null = 0, // Workarround for UE4.24 issue with enums
25 Vehicle = CARLA_ENUM_FROM_RPC(Vehicle) UMETA(DisplayName = "Vehicle"),
26 Street = CARLA_ENUM_FROM_RPC(Street) UMETA(DisplayName = "Street"),
27 Building = CARLA_ENUM_FROM_RPC(Building) UMETA(DisplayName = "Building"),
28 Other = CARLA_ENUM_FROM_RPC(Other) UMETA(DisplayName = "Other"),
29};
30
31#undef CARLA_ENUM_FROM_RPC
32
33// Class representing a light in the scene
34UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
35class CARLA_API UCarlaLight : public UActorComponent
36{
37 GENERATED_BODY()
38
39public:
40 UCarlaLight();
41
42 void BeginPlay() override;
43
44 void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
45
46 void OnComponentDestroyed(bool bDestroyingHierarchy) override;
47
48 UFUNCTION(BlueprintCallable, Category = "Carla Light")
49 void RegisterLight();
50
51 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
52 void UpdateLights();
53
54 UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Carla Light")
55 void RegisterLightWithWeather();
56
57 UFUNCTION(BlueprintCallable, Category = "Carla Light")
58 void SetLightIntensity(float Intensity);
59
60 UFUNCTION(BlueprintPure, Category = "Carla Light")
61 float GetLightIntensity() const;
62
63 UFUNCTION(BlueprintCallable, Category = "Carla Light")
64 void SetLightColor(FLinearColor Color);
65
66 UFUNCTION(BlueprintPure, Category = "Carla Light")
67 FLinearColor GetLightColor() const;
68
69 UFUNCTION(BlueprintCallable, Category = "Carla Light")
70 void SetLightOn(bool bOn);
71
72 UFUNCTION(BlueprintPure, Category = "Carla Light")
73 bool GetLightOn() const;
74
75 UFUNCTION(BlueprintCallable, Category = "Carla Light")
76 void SetLightType(ELightType Type);
77
78 UFUNCTION(BlueprintPure, Category = "Carla Light")
79 ELightType GetLightType() const;
80
81 carla::rpc::LightState GetLightState();
82
83 void SetLightState(carla::rpc::LightState LightState);
84
85 FVector GetLocation() const;
86
87 UFUNCTION(BlueprintPure, Category = "Carla Light")
88 int GetId() const;
89
90 UFUNCTION(BlueprintCallable, Category = "Carla Light")
91 void SetId(int InId);
92
93protected:
94
95 UPROPERTY(EditAnywhere, Category = "Carla Light")
96 ELightType LightType = ELightType::Street;
97
98 UPROPERTY(EditAnywhere, Category = "Carla Light")
99 float LightIntensity;
100
101 UPROPERTY(EditAnywhere, Category = "Carla Light")
102 FLinearColor LightColor;
103
104 UPROPERTY(EditAnywhere, Category = "Carla Light")
105 bool bLightOn;
106
107 UPROPERTY(EditAnywhere, Category = "Carla Light")
108 int Id = -1;
109
110 private:
111
112 void RecordLightChange() const;
113
114 bool bRegistered = false;
115};
ELightType
Definition CarlaLight.h:23
#define CARLA_ENUM_FROM_RPC(e)
Definition CarlaLight.h:19
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133