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
30 virtual FActorSpawnResult SpawnActor(
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)
56 TArray<FActorDefinition> Definitions;
57 UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient)
58 TArray<FVehicleParameters> VehiclesParams;
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient)
60 TArray<FVehicleParameters> MineVehiclesParams;
61};
Base class for Carla actor factories.
Factory in charge of spawning static meshes.
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.