Merge actors for building and material definition
This commit is contained in:
parent
4e070089c8
commit
7704809f43
|
@ -65,3 +65,22 @@ struct FVehicleActorDefinition
|
|||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<FColor> 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<FColor> Tints;
|
||||
};
|
||||
|
|
|
@ -88,7 +88,8 @@ public class CarlaTools : ModuleRules
|
|||
"Networking",
|
||||
"Sockets",
|
||||
"RHI",
|
||||
"RenderCore"
|
||||
"RenderCore",
|
||||
"MeshMergeUtilities"
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
|
||||
#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<UPrimitiveComponent*> Components;
|
||||
this->GetComponents(Components, false);
|
||||
|
||||
UWorld* World = this->GetWorld();
|
||||
|
||||
FMeshMergingSettings MeshMergeSettings;
|
||||
TArray<UObject*> AssetsToSync;
|
||||
|
||||
FVector NewLocation;
|
||||
const float ScreenAreaSize = TNumericLimits<float>::Max();
|
||||
|
||||
const IMeshMergeUtilities& MeshUtilities = FModuleManager::Get().LoadModuleChecked<IMeshMergeModule>("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);
|
||||
}
|
|
@ -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 <https://opensource.org/licenses/MIT>.
|
||||
|
||||
#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);
|
||||
|
||||
};
|
Loading…
Reference in New Issue