From cd7ab576229f1a293857e045d2a682b8420203ea Mon Sep 17 00:00:00 2001 From: Axel Date: Thu, 2 Mar 2023 17:28:36 +0100 Subject: [PATCH] WIP Automatize prop import --- .../Source/Carla/MapGen/USDImporterActor.cpp | 22 +++++++++++++ .../Source/Carla/MapGen/USDImporterActor.h | 32 +++++++++++++++++++ .../Source/CarlaTools/CarlaTools.Build.cs | 2 ++ .../CarlaTools/Private/USDImporterWidget.cpp | 21 ++++++++++++ .../CarlaTools/Public/USDImporterWidget.h | 19 +++++++++++ 5 files changed, 96 insertions(+) create mode 100644 Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.cpp create mode 100644 Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.h create mode 100644 Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp create mode 100644 Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.cpp new file mode 100644 index 000000000..3611df6ab --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.cpp @@ -0,0 +1,22 @@ +// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#include "USDImporterActor.h" + +AUSDImporterActor::AUSDImporterActor(const FObjectInitializer &ObjectInitializer) + : Super(ObjectInitializer) +{ + PrimaryActorTick.bCanEverTick = false; + RootSceneComponent = CreateDefaultSubobject(TEXT("SceneRootComponent")); + RootComponent = RootSceneComponent; + RootComponent->SetMobility(EComponentMobility::Movable); +} + + +void AUSDImporterActor::LoadUSDFile() +{ + +} \ No newline at end of file diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.h new file mode 100644 index 000000000..875a46161 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/MapGen/USDImporterActor.h @@ -0,0 +1,32 @@ +// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma +// de Barcelona (UAB). +// +// This work is licensed under the terms of the MIT license. +// For a copy, see . + +#pragma once + +#include "GameFramework/Actor.h" + +#include "USDImporterActor.generated.h" + +UCLASS() +class CARLA_API AUSDImporterActor : public AActor +{ + GENERATED_BODY() + +public: + + AUSDImporterActor(const FObjectInitializer &ObjectInitializer); + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Carla USD Importer") + FString USDPath = ""; + + UFUNCTION(CallInEditor, BlueprintCallable, Category = "Carla USD Importer") + void LoadUSDFile(); + +private: + UPROPERTY(Category="Carla USD Importer", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) + USceneComponent* RootSceneComponent; + +}; diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs index 84f6e064a..1ac044737 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs @@ -58,6 +58,8 @@ public class CarlaTools : ModuleRules "Slate", "SlateCore", "UnrealEd", + "OmniverseUSD", + "OmniverseRuntime", "Blutility", "UMG", "EditorScriptingUtilities", diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp new file mode 100644 index 000000000..bc5728863 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/USDImporterWidget.cpp @@ -0,0 +1,21 @@ +// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see . + +#include "USDImporterWidget.h" +#include "OmniverseUSDImporter.h" + + +void UUSDImporterWidget::ImportUSDProp( + const FString& USDPath, const FString& DestinationAssetPath) +{ + FOmniverseImportSettings Settings; + Settings.bImportUnusedReferences = false; + Settings.bImportAsBlueprint = true; + FOmniverseUSDImporter::LoadUSD(USDPath, DestinationAssetPath, Settings); +} + +void UUSDImporterWidget::ImportUSDVehicle( + const FString& USDPath, const FString& DestinationAssetPath) +{ + +} + diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h new file mode 100644 index 000000000..972577b73 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/USDImporterWidget.h @@ -0,0 +1,19 @@ +// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB). This work is licensed under the terms of the MIT license. For a copy, see . + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" + +#include "USDImporterWidget.generated.h" + +UCLASS() +class CARLATOOLS_API UUSDImporterWidget : public UUserWidget +{ + GENERATED_BODY() + + public: + + void ImportUSDProp(const FString& USDPath, const FString& DestinationAssetPath); + void ImportUSDVehicle(const FString& USDPath, const FString& DestinationAssetPath); +};