CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Util
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
16
USTRUCT(BlueprintType)
17
struct 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
54
UCLASS()
55
class CARLA_API
ARoadPainterWrapper
: public
AActor
56
{
57
GENERATED_BODY()
58
59
public
:
60
61
ARoadPainterWrapper
();
62
63
void
BeginPlay
()
override
;
64
65
/// Event used for spawning meshes via blueprint
66
UFUNCTION(BlueprintImplementableEvent, Category =
"RoadPainter Wrapper"
)
67
void
SpawnMeshesEvent
();
68
69
/// Event used for spawning decals via blueprint
70
UFUNCTION(BlueprintImplementableEvent, Category =
"RoadPainter Wrapper"
)
71
void
SpawnDecalsEvent
();
72
73
/// Event for setting the necessary variables in blueprint in order to paint the roads
74
UFUNCTION(BlueprintImplementableEvent, Category =
"RoadPainter Wrapper"
)
75
void
SetBlueprintVariables
();
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"
)
84
FDecalsProperties
DecalPropertiesConfig
;
85
86
private:
87
88
/// Function to read 3D vectors from a JSON file
89
FVector
ReadVectorFromJsonObject
(TSharedPtr<FJsonObject> JsonObject);
90
};
AActor
ARoadPainterWrapper::ARoadPainterWrapper
ARoadPainterWrapper()
Definition
RoadPainterWrapper.cpp:24
ARoadPainterWrapper::ReadVectorFromJsonObject
FVector ReadVectorFromJsonObject(TSharedPtr< FJsonObject > JsonObject)
Function to read 3D vectors from a JSON file.
Definition
RoadPainterWrapper.cpp:102
ARoadPainterWrapper::BeginPlay
void BeginPlay() override
Definition
RoadPainterWrapper.cpp:47
ARoadPainterWrapper::DecalPropertiesConfig
FDecalsProperties DecalPropertiesConfig
Variable used for storing the JSON values of the decals so it can be later used by the blueprint (Roa...
Definition
RoadPainterWrapper.h:84
ARoadPainterWrapper::SpawnMeshesEvent
void SpawnMeshesEvent()
Event used for spawning meshes via blueprint.
ARoadPainterWrapper::ReadConfigFile
void ReadConfigFile(const FString &CurrentMapName, const TMap< FString, FString > &DecalNamesMap)
Function for reading the decals configuration file (in JSON format).
Definition
RoadPainterWrapper.cpp:53
ARoadPainterWrapper::SpawnDecalsEvent
void SpawnDecalsEvent()
Event used for spawning decals via blueprint.
ARoadPainterWrapper::SetBlueprintVariables
void SetBlueprintVariables()
Event for setting the necessary variables in blueprint in order to paint the roads.
FDecalsProperties
Definition
RoadPainterWrapper.h:18
FDecalsProperties::DecalRandomYaw
float DecalRandomYaw
The decal yaw to be applied randomly.
Definition
RoadPainterWrapper.h:47
FDecalsProperties::DecalMaxScale
float DecalMaxScale
Maximum scale to be applied to the decals.
Definition
RoadPainterWrapper.h:39
FDecalsProperties::DecalNumToSpawn
TArray< int32 > DecalNumToSpawn
How many decals (or material instances) of each, should be applied to the road.
Definition
RoadPainterWrapper.h:27
FDecalsProperties::RandomOffset
float RandomOffset
Random offset from one decal to another.
Definition
RoadPainterWrapper.h:51
FDecalsProperties::DecalMaterials
TArray< UMaterialInstance * > DecalMaterials
The decals used on the road.
Definition
RoadPainterWrapper.h:23
FDecalsProperties::DecalMinScale
float DecalMinScale
Min scale to be applied to the decals.
Definition
RoadPainterWrapper.h:43
FDecalsProperties::DecalScale
FVector DecalScale
Scale of each decal on the road.
Definition
RoadPainterWrapper.h:31
FDecalsProperties::FixedDecalOffset
FVector FixedDecalOffset
Min offset from one decal to another.
Definition
RoadPainterWrapper.h:35
Generated by
1.18.0