diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorDefinition.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorDefinition.h index 2c27ef5c8..8f7baf5d7 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorDefinition.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorDefinition.h @@ -65,3 +65,22 @@ struct FVehicleActorDefinition UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray colors; }; + +/// A definition of a Procedural Building Material with all the variation of colors. +USTRUCT(BlueprintType) +struct FProceduralBuildingActorDefinition +{ + GENERATED_BODY() + + /// A list of comma-separated tags. + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FString Tags; + + /// The base material + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UMaterial* Material; + + /// Colors represent the avaliable colors for each material + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TArray Tints; +}; diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs index 225c7a367..45006bde3 100644 --- a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/CarlaTools.Build.cs @@ -88,7 +88,8 @@ public class CarlaTools : ModuleRules "Networking", "Sockets", "RHI", - "RenderCore" + "RenderCore", + "MeshMergeUtilities" // ... add private dependencies that you statically link with here ... } ); diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/ProceduralBuildingUtilities.cpp b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/ProceduralBuildingUtilities.cpp new file mode 100644 index 000000000..ca2153f8f --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Private/ProceduralBuildingUtilities.cpp @@ -0,0 +1,42 @@ +// Copyright (c) 2017 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 "ProceduralBuildingUtilities.h" + +#include "AssetRegistryModule.h" +#include "FileHelpers.h" +#include "IMeshMergeUtilities.h" +#include "MeshMergeModule.h" +#include "UObject/Class.h" + +void AProceduralBuildingUtilities::GenerateImpostor() +{ + // Not implemented yet. +} + +void AProceduralBuildingUtilities::CookProceduralBuildingToMesh(const FString& DestinationPath) +{ + TArray Components; + this->GetComponents(Components, false); + + UWorld* World = this->GetWorld(); + + FMeshMergingSettings MeshMergeSettings; + TArray AssetsToSync; + + FVector NewLocation; + const float ScreenAreaSize = TNumericLimits::Max(); + + const IMeshMergeUtilities& MeshUtilities = FModuleManager::Get().LoadModuleChecked("MeshMergeUtilities").GetUtilities(); + MeshUtilities.MergeComponentsToStaticMesh(Components, World, MeshMergeSettings, nullptr, nullptr, DestinationPath, AssetsToSync, NewLocation, ScreenAreaSize, true); + + + for(UObject* ObjectToSave : AssetsToSync) + { + FAssetRegistryModule::AssetCreated(ObjectToSave); + UPackage* ObjectPackage = ObjectToSave->GetPackage(); + ObjectPackage->MarkPackageDirty(); + } + + FEditorFileUtils::SaveDirtyPackages(false, false, true, false, true, false, nullptr); +} diff --git a/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/ProceduralBuildingUtilities.h b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/ProceduralBuildingUtilities.h new file mode 100644 index 000000000..b8320ff12 --- /dev/null +++ b/Unreal/CarlaUE4/Plugins/CarlaTools/Source/CarlaTools/Public/ProceduralBuildingUtilities.h @@ -0,0 +1,26 @@ +// Copyright (c) 2017 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 "EditorUtilityActor.h" +#include "ProceduralBuildingUtilities.generated.h" + +struct FIntRect; + +/** + * + */ +UCLASS() +class CARLATOOLS_API AProceduralBuildingUtilities : public AEditorUtilityActor +{ + GENERATED_BODY() + +public: + UFUNCTION(BlueprintCallable, Category="Procedural Building Utilities") + void GenerateImpostor(); + + UFUNCTION(BlueprintCallable, Category="Procedural Building Utilities") + void CookProceduralBuildingToMesh(const FString& DestinationPath); + +};