CARLA
RoadPainterWrapper.h
Go to the documentation of this file.
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 
9 #include "GameFramework/Actor.h"
10 #include "Materials/MaterialInstanceConstant.h"
11 #include "RoadPainterWrapper.generated.h"
12 
13 USTRUCT(BlueprintType)
14 struct CARLA_API FDecalsProperties
15 {
16  GENERATED_USTRUCT_BODY()
17 
18  /// The decals used on the road
19  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
20  TArray<UMaterialInstance*> DecalMaterials;
21 
22  /// How many decals (or material instances) of each, should be applied to the road
23  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
24  TArray<int32> DecalNumToSpawn;
25 
26  /// Scale of each decal on the road
27  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
28  FVector DecalScale;
29 
30  /// Min offset from one decal to another
31  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
32  FVector FixedDecalOffset;
33 
34  /// Maximum scale to be applied to the decals
35  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
36  float DecalMaxScale = 1.0f;
37 
38  /// Min scale to be applied to the decals
39  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
40  float DecalMinScale = 1.0f;
41 
42  /// The decal yaw to be applied randomly
43  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
44  float DecalRandomYaw = 90.0f;
45 
46  /// Random offset from one decal to another
47  UPROPERTY(BlueprintReadOnly, Category = "Decals Properties")
48  float RandomOffset = 3.0f;
49 };
50 
51 UCLASS()
52 class CARLA_API ARoadPainterWrapper : public AActor
53 {
54  GENERATED_BODY()
55 
56 public:
57 
59 
60  void BeginPlay() override;
61 
62  /// Event used for spawning meshes via blueprint
63  UFUNCTION(BlueprintImplementableEvent, Category = "RoadPainter Wrapper")
64  void SpawnMeshesEvent();
65 
66  /// Event used for spawning decals via blueprint
67  UFUNCTION(BlueprintImplementableEvent, Category = "RoadPainter Wrapper")
68  void SpawnDecalsEvent();
69 
70  /// Event for setting the necessary variables in blueprint in order to paint the roads
71  UFUNCTION(BlueprintImplementableEvent, Category = "RoadPainter Wrapper")
72  void SetBlueprintVariables();
73 
74  /// Function for reading the decals configuration file (in JSON format)
75  UFUNCTION(Category = "RoadPainter Wrapper")
76  void ReadConfigFile(const FString &CurrentMapName, const TMap<FString, FString> &DecalNamesMap);
77 
78  /// Variable used for storing the JSON values of the decals
79  /// so it can be later used by the blueprint (Road Painter Preset)
80  UPROPERTY(BlueprintReadOnly, Category = "RoadPainter Wrapper")
81  FDecalsProperties DecalPropertiesConfig;
82 
83 private:
84 
85  /// Function to read 3D vectors from a JSON file
86  FVector ReadVectorFromJsonObject(TSharedPtr<FJsonObject> JsonObject);
87 };