CARLA
Loading...
Searching...
No Matches
VehicleActorFactory.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
12
13#include <util/ue-header-guard-begin.h>
14#include "Json.h"
15#include "JsonUtilities.h"
16#include <util/ue-header-guard-end.h>
17
18#include "VehicleActorFactory.generated.h"
19
20/// Factory in charge of spawning static meshes. This factory is able to spawn
21/// any mesh in content.
22UCLASS()
24{
25 GENERATED_BODY()
26
27 /// Retrieve the definitions of the static mesh actor
28 virtual TArray<FActorDefinition> GetDefinitions() override;
29
31 const FTransform &SpawnAtTransform,
32 const FActorDescription &ActorDescription) override;
33
34public:
35
36 UFUNCTION(BlueprintCallable, Category = "VehicleActorFactory")
37 static void SaveVehicleParametersArrayToFile(const TArray<FVehicleParameters>& VehicleParamsArray, const FString& FileName);
38 UFUNCTION(BlueprintCallable, Category = "VehicleActorFactory")
39 static void LoadVehicleParametersArrayFromFile(const FString& FileName, TArray<FVehicleParameters>& OutVehicleParamsArray);
40
41 UFUNCTION(BlueprintImplementableEvent, Category = "VehicleActorFactory")
42 bool PostProcessVehicle(AActor* SpawnedActor, const FActorDescription& VehicleParams);
43private:
44 static TSharedPtr<FJsonObject> FVehicleParametersToJsonObject(const FVehicleParameters& VehicleParams);
45 static FString FVehicleParametersArrayToJson(const TArray<FVehicleParameters>& VehicleParamsArray);
46 static bool JsonToFVehicleParameters(const TSharedPtr<FJsonObject> JsonObject, FVehicleParameters& OutVehicleParams);
47 static bool JsonToFVehicleParametersArray(const FString& JsonString, TArray<FVehicleParameters>& OutVehicleParamsArray);
48
49 virtual void ReleaseContentPack(const FString &MountPoint) override;
50
51protected:
52 // Transient: GetDefinitions() rebuilds these from the JSON catalogs every
53 // episode, and a saved copy bakes a stale catalog into the map.
54
55 UPROPERTY(EditAnywhere, Transient)
57 UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient)
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient)
61};
ACarlaActorFactory(const FObjectInitializer &ObjectInitializer)
Factory in charge of spawning static meshes.
static void SaveVehicleParametersArrayToFile(const TArray< FVehicleParameters > &VehicleParamsArray, const FString &FileName)
static bool JsonToFVehicleParametersArray(const FString &JsonString, TArray< FVehicleParameters > &OutVehicleParamsArray)
static bool JsonToFVehicleParameters(const TSharedPtr< FJsonObject > JsonObject, FVehicleParameters &OutVehicleParams)
static TSharedPtr< FJsonObject > FVehicleParametersToJsonObject(const FVehicleParameters &VehicleParams)
virtual FActorSpawnResult SpawnActor(const FTransform &SpawnAtTransform, const FActorDescription &ActorDescription) override
Spawn an actor based on ActorDescription and Transform.
bool PostProcessVehicle(AActor *SpawnedActor, const FActorDescription &VehicleParams)
virtual TArray< FActorDefinition > GetDefinitions() override
Retrieve the definitions of the static mesh actor.
static FString FVehicleParametersArrayToJson(const TArray< FVehicleParameters > &VehicleParamsArray)
static void LoadVehicleParametersArrayFromFile(const FString &FileName, TArray< FVehicleParameters > &OutVehicleParamsArray)
TArray< FVehicleParameters > VehiclesParams
TArray< FVehicleParameters > MineVehiclesParams
TArray< FActorDefinition > Definitions
virtual void ReleaseContentPack(const FString &MountPoint) override
Drop every cached definition, parameter and loaded asset that refers to content under MountPoint ("/<...
A definition of a Carla Actor with all the variation and attributes.
A description of a Carla Actor with all its variation.
Result of an actor spawn function.