CARLA
 
载入中...
搜索中...
未找到
CarlaHUD.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
8
9// Workaround to fix Windows conflict: Windows changes the name of some functions (DrawText, LoadLibrary...)
10// with Unicode / ANSI versions for his own API (DrawTextW, DrawTextA, LoadLibraryW, LoadLibraryA...).
11// But the changes are global for the compiler. Deep in headers, Windows has something like:
12// #ifdef UNICODE
13// #define DrawText DrawTextW
14// #define LoadLibrary LoadLibraryW
15// #else
16// #define DrawText DrawTextA
17// #define LoadLibrary LoadLibraryA
18// #endif
19// Then the linker tries to find the function DrawTextW on an external DLL and an unresolved external error happens because
20// Unreal has no function DrawTextW, it has just DrawText.
21// We can fix that by just undefining the function that conflicts with the name of the Windows API in Unicode.
22#undef DrawText
23
24#include "Carla.h"
25#include "Containers/Array.h"
26#include "GameFramework/HUD.h"
27#include "WheeledVehicleMovementComponent.h"
28#include "CarlaHUD.generated.h"
29
31{
32 FString Str { "" };
33 FVector Location;
34 FColor Color;
35 double TimeToDie;
36};
37
38struct HUDLine
39{
40 FVector Begin;
41 FVector End;
42 float Thickness;
43 FColor Color;
44 double TimeToDie;
45};
46
47/// Class to draw on HUD
48UCLASS()
49class CARLA_API ACarlaHUD : public AHUD
50{
51 GENERATED_BODY()
52
53public:
54
55 ACarlaHUD(const FObjectInitializer& ObjectInitializer)
56 : Super(ObjectInitializer)
57 {
58 PrimaryActorTick.bCanEverTick = false;
59 }
60
61 virtual void DrawHUD() override;
62
63 UWheeledVehicleMovementComponent* DebugVehicle{nullptr};
64 void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent* Veh) { DebugVehicle = Veh; }
65
66 void AddHUDString(const FString Str, const FVector Location, const FColor Color, double LifeTime);
67 void AddHUDLine(const FVector Begin, const FVector End, const float Thickness, const FColor Color, double LifeTime);
68
69private:
70 TArray<HUDString> StringList;
71 TArray<HUDLine> LineList;
72};
Class to draw on HUD
Definition CarlaHUD.h:50
TArray< HUDLine > LineList
Definition CarlaHUD.h:71
TArray< HUDString > StringList
Definition CarlaHUD.h:70
void AddDebugVehicleForTelemetry(UWheeledVehicleMovementComponent *Veh)
Definition CarlaHUD.h:64
ACarlaHUD(const FObjectInitializer &ObjectInitializer)
Definition CarlaHUD.h:55
FColor Color
Definition CarlaHUD.h:43
FVector Begin
Definition CarlaHUD.h:40
double TimeToDie
Definition CarlaHUD.h:44
FVector End
Definition CarlaHUD.h:41
float Thickness
Definition CarlaHUD.h:42
FVector Location
Definition CarlaHUD.h:33
double TimeToDie
Definition CarlaHUD.h:35
FString Str
Definition CarlaHUD.h:32
FColor Color
Definition CarlaHUD.h:34