CARLA
Loading...
Searching...
No Matches
BlueprintActorFactory.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 "BlueprintActorFactory.generated.h"
19
20UCLASS()
22{
23 GENERATED_BODY()
24
25 /// Retrieve the definitions of the static mesh actor
26 virtual TArray<FActorDefinition> GetDefinitions() override;
27
28 virtual FActorSpawnResult SpawnActor(
29 const FTransform &SpawnAtTransform,
30 const FActorDescription &ActorDescription) override;
31
32public:
33 UFUNCTION(BlueprintCallable, Category = "BlueprintActorFactory")
34 static void SaveBlueprintParametersArrayToFile(const TArray<FBlueprintParameters> &BlueprintParamsArray, const FString &FileName);
35 UFUNCTION(BlueprintCallable, Category = "BlueprintActorFactory")
36 static void LoadBlueprintParametersArrayFromFile(const FString &FileName, TArray<FBlueprintParameters> &OutBlueprintParamsArray);
37
38 UFUNCTION(BlueprintImplementableEvent, Category = "BlueprintActorFactory")
39 bool PostProcessBlueprint(AActor* SpawnedActor, const FActorDescription& BlueprintParams);
40
41private:
42 static TSharedPtr<FJsonObject> FBlueprintParametersToJsonObject(const FBlueprintParameters& BlueprintParams);
43 static FString FBlueprintParametersArrayToJson(const TArray<FBlueprintParameters>& BlueprintParamsArray);
44 static bool JsonToFBlueprintParameters(const TSharedPtr<FJsonObject> JsonObject, FBlueprintParameters& OutBlueprintParams);
45 static bool JsonToFBlueprintParametersArray(const FString& JsonString, TArray<FBlueprintParameters>& OutBlueprintParamsArray);
46
47 virtual void ReleaseContentPack(const FString &MountPoint) override;
48
49protected:
50 // Transient: GetDefinitions() rebuilds these from the JSON catalogs every
51 // episode, and a saved copy bakes a stale catalog into the map.
52 UPROPERTY(EditAnywhere, Transient)
53 TArray<FActorDefinition> Definitions;
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, Transient)
55 TArray<FBlueprintParameters> BlueprintsParams;
56};
Base class for Carla actor factories.
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.