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