HAxis sos
This commit is contained in:
		| @@ -0,0 +1,149 @@ | ||||
| // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. | ||||
|  | ||||
| #include "PolishBuildingsPrivatePCH.h" | ||||
| #include "PolishBuildingsTool.h" | ||||
| #include "SPolishBuildingsDialog.h" | ||||
| #include "PropertyEditorModule.h" | ||||
| #include "Engine/TextureLODSettings.h" | ||||
| #include "RawMesh.h" | ||||
| #include "Engine/StaticMeshActor.h" | ||||
| #include "Engine/StaticMesh.h" | ||||
| #include "Engine/Selection.h" | ||||
| #include "SystemSettings.h" | ||||
| #include "Engine/TextureLODSettings.h" | ||||
| #include "ContentBrowserModule.h" | ||||
| #include "AssetRegistryModule.h" | ||||
| #include "ScopedTransaction.h" | ||||
|  | ||||
| #define LOCTEXT_NAMESPACE "PolishBuildingsTool" | ||||
|  | ||||
|  | ||||
| FPolishBuildingsTool::FPolishBuildingsTool() | ||||
| 	: bReplaceSourceActors(false) | ||||
| 	, bExportSpecificLOD(false) | ||||
| 	, ExportLODIndex(0) | ||||
| {} | ||||
|  | ||||
|  | ||||
| TSharedRef<SWidget> FPolishBuildingsTool::GetWidget() | ||||
| { | ||||
| 	return SNew(SPolishBuildingsDialog, this); | ||||
| } | ||||
|  | ||||
|  | ||||
| FText FPolishBuildingsTool::GetTooltipText() const | ||||
| { | ||||
| 	return LOCTEXT("PolishBuildingsToolTooltip", "Harvest geometry from selected actors and merge grouping them by materials."); | ||||
| } | ||||
|  | ||||
|  | ||||
| FString FPolishBuildingsTool::GetDefaultPackageName() const | ||||
| { | ||||
| 	FString PackageName = FPackageName::FilenameToLongPackageName(FPaths::GameContentDir() + TEXT("SM_MERGED")); | ||||
|  | ||||
| 	USelection* SelectedActors = GEditor->GetSelectedActors(); | ||||
| 	// Iterate through selected actors and find first static mesh asset | ||||
| 	// Use this static mesh path as destination package name for a merged mesh | ||||
| 	for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter) | ||||
| 	{ | ||||
| 		AActor* Actor = Cast<AActor>(*Iter); | ||||
| 		if (Actor) | ||||
| 		{ | ||||
| 			FString ActorName = Actor->GetName(); | ||||
| 			PackageName = FString::Printf(TEXT("%s_%s"), *PackageName, *ActorName); | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if (PackageName.IsEmpty()) | ||||
| 	{ | ||||
| 		PackageName = MakeUniqueObjectName(NULL, UPackage::StaticClass(), *PackageName).ToString(); | ||||
| 	} | ||||
|  | ||||
| 	return PackageName; | ||||
| } | ||||
|  | ||||
|  | ||||
| bool FPolishBuildingsTool::RunMerge(const FString& PackageName) | ||||
| { | ||||
| 	IMeshUtilities& MeshUtilities = FModuleManager::Get().LoadModuleChecked<IMeshUtilities>("MeshUtilities"); | ||||
| 	USelection* SelectedActors = GEditor->GetSelectedActors(); | ||||
| 	TArray<AActor*> Actors; | ||||
| 	TArray<ULevel*> UniqueLevels; | ||||
| 	for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter) | ||||
| 	{ | ||||
| 		AActor* Actor = Cast<AActor>(*Iter); | ||||
| 		if (Actor) | ||||
| 		{ | ||||
| 			Actors.Add(Actor); | ||||
| 			UniqueLevels.AddUnique(Actor->GetLevel()); | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// This restriction is only for replacement of selected actors with merged mesh actor | ||||
| 	if (UniqueLevels.Num() > 1 && bReplaceSourceActors) | ||||
| 	{ | ||||
| 		FText Message = NSLOCTEXT("UnrealEd", "FailedToPolishBuildingsSublevels_Msg", "The selected actors should be in the same level"); | ||||
| 		OpenMsgDlgInt(EAppMsgType::Ok, Message, NSLOCTEXT("UnrealEd", "FailedToPolishBuildings_Title", "Unable to merge actors")); | ||||
| 		return false; | ||||
| 	} | ||||
|  | ||||
| 	int32 TargetMeshLOD = bExportSpecificLOD ? ExportLODIndex : INDEX_NONE; | ||||
| 	FVector MergedActorLocation; | ||||
| 	TArray<UObject*> AssetsToSync; | ||||
| 	// Merge... | ||||
| 	{ | ||||
| 		FScopedSlowTask SlowTask(0, LOCTEXT("MergingActorsSlowTask", "Merging actors...")); | ||||
| 		SlowTask.MakeDialog(); | ||||
| 		 | ||||
| 		MeshUtilities.MergeActors(Actors, MergingSettings, NULL, PackageName, TargetMeshLOD, AssetsToSync, MergedActorLocation); | ||||
| 	} | ||||
|  | ||||
| 	if (AssetsToSync.Num()) | ||||
| 	{ | ||||
| 		FAssetRegistryModule& AssetRegistry = FModuleManager::Get().LoadModuleChecked<FAssetRegistryModule>("AssetRegistry"); | ||||
| 		int32 AssetCount = AssetsToSync.Num(); | ||||
| 		for (int32 AssetIndex = 0; AssetIndex < AssetCount; AssetIndex++) | ||||
| 		{ | ||||
| 			AssetRegistry.AssetCreated(AssetsToSync[AssetIndex]); | ||||
| 			GEditor->BroadcastObjectReimported(AssetsToSync[AssetIndex]); | ||||
| 		} | ||||
|  | ||||
| 		//Also notify the content browser that the new assets exists | ||||
| 		FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser"); | ||||
| 		ContentBrowserModule.Get().SyncBrowserToAssets(AssetsToSync, true); | ||||
|  | ||||
| 		// Place new mesh in the world | ||||
| 		if (bReplaceSourceActors) | ||||
| 		{ | ||||
| 			UStaticMesh* MergedMesh = nullptr; | ||||
| 			if (AssetsToSync.FindItemByClass(&MergedMesh)) | ||||
| 			{ | ||||
| 				const FScopedTransaction Transaction(LOCTEXT("PlaceMergedActor", "Place Merged Actor")); | ||||
| 				UniqueLevels[0]->Modify(); | ||||
|  | ||||
| 				UWorld* World = UniqueLevels[0]->OwningWorld; | ||||
| 				FActorSpawnParameters Params; | ||||
| 				Params.OverrideLevel = UniqueLevels[0]; | ||||
| 				FRotator MergedActorRotation(ForceInit); | ||||
| 								 | ||||
| 				AStaticMeshActor* MergedActor = World->SpawnActor<AStaticMeshActor>(MergedActorLocation, MergedActorRotation, Params); | ||||
| 				MergedActor->GetStaticMeshComponent()->StaticMesh = MergedMesh; | ||||
| 				MergedActor->SetActorLabel(AssetsToSync[0]->GetName()); | ||||
|  | ||||
| 				// Remove source actors | ||||
| 				/* | ||||
| 				for (AActor* Actor : Actors) | ||||
| 				{ | ||||
| 					Actor->Destroy(); | ||||
| 				} | ||||
| 				*/ | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|  | ||||
| #undef LOCTEXT_NAMESPACE | ||||
| @@ -0,0 +1,35 @@ | ||||
| // Copyright 1998-2014 Epic Games, Inc. All Rights Reserved. | ||||
| #pragma once | ||||
|  | ||||
| #include "IPolishBuildingsTool.h" | ||||
| #include "MeshUtilities.h" | ||||
|  | ||||
| /** | ||||
|  * Mesh Merging Tool | ||||
|  */ | ||||
| class FPolishBuildingsTool : public IPolishBuildingsTool | ||||
| { | ||||
| 	friend class SPolishBuildingsDialog; | ||||
|  | ||||
| public: | ||||
|  | ||||
| 	FPolishBuildingsTool(); | ||||
|  | ||||
| 	// IPolishBuildingsTool interface | ||||
| 	virtual TSharedRef<SWidget> GetWidget() override; | ||||
| 	virtual FName GetIconName() const override { return "PolishBuildings.PolishBuildingsTool"; } | ||||
| 	virtual FText GetTooltipText() const override; | ||||
| 	virtual FString GetDefaultPackageName() const override; | ||||
| 	virtual bool RunMerge(const FString& PackageName) override; | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	/** Current mesh merging settings */ | ||||
| 	FMeshMergingSettings MergingSettings; | ||||
|  | ||||
| 	/** Whether to replace source actors with a merged actor in the world */ | ||||
| 	bool bReplaceSourceActors; | ||||
|  | ||||
| 	bool bExportSpecificLOD; | ||||
| 	int32 ExportLODIndex; | ||||
| }; | ||||
| @@ -0,0 +1,520 @@ | ||||
| // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. | ||||
|  | ||||
| #include "PolishBuildingsPrivatePCH.h" | ||||
| #include "SPolishBuildingsDialog.h" | ||||
| #include "Dialogs/DlgPickAssetPath.h" | ||||
| #include "STextComboBox.h" | ||||
| #include "RawMesh.h" | ||||
| #include "PolishBuildingsTool/PolishBuildingsTool.h" | ||||
|  | ||||
| #define LOCTEXT_NAMESPACE "SPolishBuildingsDialog" | ||||
|  | ||||
| ////////////////////////////////////////////////////////////////////////// | ||||
| // SPolishBuildingsDialog | ||||
|  | ||||
| SPolishBuildingsDialog::SPolishBuildingsDialog() | ||||
| { | ||||
| } | ||||
|  | ||||
| BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION | ||||
| void SPolishBuildingsDialog::Construct(const FArguments& InArgs, FPolishBuildingsTool* InTool) | ||||
| { | ||||
| 	Tool = InTool; | ||||
| 	check(Tool != nullptr); | ||||
|  | ||||
| 	// Setup available resolutions for lightmap and merged materials | ||||
| 	const int32 MinTexResolution = 1 << FTextureLODGroup().MinLODMipCount; | ||||
| 	const int32 MaxTexResolution = 1 << FTextureLODGroup().MaxLODMipCount; | ||||
| 	for (int32 TexRes = MinTexResolution; TexRes <= MaxTexResolution; TexRes*=2) | ||||
| 	{ | ||||
| 		LightMapResolutionOptions.Add(MakeShareable(new FString(TTypeToString<int32>::ToString(TexRes)))); | ||||
| 		MergedMaterialResolutionOptions.Add(MakeShareable(new FString(TTypeToString<int32>::ToString(TexRes)))); | ||||
| 	} | ||||
|  | ||||
| 	Tool->MergingSettings.TargetLightMapResolution = FMath::Clamp(Tool->MergingSettings.TargetLightMapResolution, MinTexResolution, MaxTexResolution); | ||||
| 	Tool->MergingSettings.MaterialSettings.TextureSize.X = FMath::Clamp( Tool->MergingSettings.MaterialSettings.TextureSize.X, MinTexResolution, MaxTexResolution ); | ||||
| 	Tool->MergingSettings.MaterialSettings.TextureSize.Y = FMath::Clamp( Tool->MergingSettings.MaterialSettings.TextureSize.Y, MinTexResolution, MaxTexResolution ); | ||||
|  | ||||
| 	// Setup available UV channels for an atlased lightmap | ||||
| 	for (int32 Index = 0; Index < MAX_MESH_TEXTURE_COORDS; Index++) | ||||
| 	{ | ||||
| 		LightMapChannelOptions.Add(MakeShareable(new FString(TTypeToString<int32>::ToString(Index)))); | ||||
| 	} | ||||
|  | ||||
| 	for (int32 Index = 0; Index < MAX_STATIC_MESH_LODS; Index++) | ||||
| 	{ | ||||
| 		ExportLODOptions.Add(MakeShareable(new FString(TTypeToString<int32>::ToString(Index)))); | ||||
| 	} | ||||
|  | ||||
| 	// Create widget layout | ||||
| 	this->ChildSlot | ||||
| 	[ | ||||
| 		SNew(SVerticalBox) | ||||
|  | ||||
| 		+SVerticalBox::Slot() | ||||
| 		.AutoHeight() | ||||
| 		.Padding(0,2,0,0) | ||||
| 		[ | ||||
| 			// Lightmap settings | ||||
| 			SNew(SBorder) | ||||
| 			.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) | ||||
| 			[ | ||||
| 				SNew(SVerticalBox) | ||||
| 									 | ||||
| 				// Enable atlasing | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetGenerateLightmapUV) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetGenerateLightmapUV) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("AtlasLightmapUVLabel", "Generate Lightmap UVs")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 					 | ||||
| 				// Target lightmap channel / Max lightmap resolution | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SHorizontalBox) | ||||
|  | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.IsEnabled(this, &SPolishBuildingsDialog::IsLightmapChannelEnabled) | ||||
| 						.Text(LOCTEXT("TargetLightMapChannelLabel", "Target Channel:")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
|  | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					.Padding(4,0,4,0) | ||||
| 					[ | ||||
| 						SNew(STextComboBox) | ||||
| 						.IsEnabled( this, &SPolishBuildingsDialog::IsLightmapChannelEnabled ) | ||||
| 						.OptionsSource(&LightMapChannelOptions) | ||||
| 						.InitiallySelectedItem(LightMapChannelOptions[Tool->MergingSettings.TargetLightMapUVChannel]) | ||||
| 						.OnSelectionChanged(this, &SPolishBuildingsDialog::SetTargetLightMapChannel) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
|  | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.IsEnabled(this, &SPolishBuildingsDialog::IsLightmapChannelEnabled) | ||||
| 						.Text(LOCTEXT("TargetLightMapResolutionLabel", "Target Resolution:")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 												 | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					.Padding(4,0,4,0) | ||||
| 					[ | ||||
| 						SNew(STextComboBox) | ||||
| 						.IsEnabled( this, &SPolishBuildingsDialog::IsLightmapChannelEnabled ) | ||||
| 						.OptionsSource(&LightMapResolutionOptions) | ||||
| 						.InitiallySelectedItem(LightMapResolutionOptions[FMath::FloorLog2(Tool->MergingSettings.TargetLightMapResolution)]) | ||||
| 						.OnSelectionChanged(this, &SPolishBuildingsDialog::SetTargetLightMapResolution) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 			] | ||||
| 		] | ||||
|  | ||||
| 		// Other merging settings | ||||
| 		+SVerticalBox::Slot() | ||||
| 		.AutoHeight() | ||||
| 		.Padding(0,2,0,0) | ||||
| 		[ | ||||
| 			SNew(SBorder) | ||||
| 			.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder")) | ||||
| 			[ | ||||
| 				SNew(SVerticalBox) | ||||
|  | ||||
| 				// LOD to export | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SHorizontalBox) | ||||
|  | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					[ | ||||
| 						SNew(SCheckBox) | ||||
| 						.Type(ESlateCheckBoxType::CheckBox) | ||||
| 						.IsChecked(this, &SPolishBuildingsDialog::GetExportSpecificLODEnabled) | ||||
| 						.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetExportSpecificLODEnabled) | ||||
| 						.Content() | ||||
| 						[ | ||||
| 							SNew(STextBlock) | ||||
| 							.IsEnabled(this, &SPolishBuildingsDialog::IsExportSpecificLODEnabled) | ||||
| 							.Text(LOCTEXT("TargetMeshLODIndexLabel", "Export specific LOD:")) | ||||
| 							.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 						] | ||||
| 					] | ||||
| 					 | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					.Padding(4,0,4,0) | ||||
| 					[ | ||||
| 						SNew(STextComboBox) | ||||
| 						.IsEnabled(this, &SPolishBuildingsDialog::IsExportSpecificLODEnabled) | ||||
| 						.OptionsSource(&ExportLODOptions) | ||||
| 						.InitiallySelectedItem(ExportLODOptions[Tool->ExportLODIndex]) | ||||
| 						.OnSelectionChanged(this, &SPolishBuildingsDialog::SetExportSpecificLODIndex) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 					 | ||||
| 				// Vertex colors | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetImportVertexColors) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetImportVertexColors) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ImportVertexColorsLabel", "Import Vertex Colors")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
|  | ||||
| 				// Pivot at zero | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetPivotPointAtZero) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetPivotPointAtZero) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("PivotPointAtZeroLabel", "Pivot Point At (0,0,0)")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
|  | ||||
| 				// Replace source actors | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetReplaceSourceActors) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetReplaceSourceActors) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ReplaceSourceActorsLabel", "Replace Source Actors")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				 | ||||
| 				// Merge physics data | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetMergePhyisicData) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetMergePhyisicData) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("MergePhysicsDataLabel", "Merge Physics Data")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
|  | ||||
| 				// Merge materials | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetMergeMaterials) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetMergeMaterials) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("MergeMaterialsLabel", "Merge Materials")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				// Export normal map | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetExportNormalMap) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetExportNormalMap) | ||||
| 					.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ExportNormalMapLabel", "Export Normal Map")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				// Export metallic map | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetExportMetallicMap) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetExportMetallicMap) | ||||
| 					.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ExportMetallicMapLabel", "Export Metallic Map")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				// Export roughness map | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetExportRoughnessMap) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetExportRoughnessMap) | ||||
| 					.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ExportRoughnessMapLabel", "Export Roughness Map")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				// Export specular map | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SCheckBox) | ||||
| 					.Type(ESlateCheckBoxType::CheckBox) | ||||
| 					.IsChecked(this, &SPolishBuildingsDialog::GetExportSpecularMap) | ||||
| 					.OnCheckStateChanged(this, &SPolishBuildingsDialog::SetExportSpecularMap) | ||||
| 					.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 					.Content() | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.Text(LOCTEXT("ExportSpecularMapLabel", "Export Specular Map")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				] | ||||
| 				 | ||||
| 				// Merged texture size | ||||
| 				+SVerticalBox::Slot() | ||||
| 				.AutoHeight() | ||||
| 				.Padding(FEditorStyle::GetMargin("StandardDialog.ContentPadding")) | ||||
| 				[ | ||||
| 					SNew(SHorizontalBox) | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					[ | ||||
| 						SNew(STextBlock) | ||||
| 						.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 						.Text(LOCTEXT("MergedMaterialAtlasResolutionLabel", "Merged Material Atlas Resolution:")) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 												 | ||||
| 					+SHorizontalBox::Slot() | ||||
| 					.AutoWidth() | ||||
| 					.VAlign(VAlign_Center) | ||||
| 					.Padding(4,0,4,0) | ||||
| 					[ | ||||
| 						SNew(STextComboBox) | ||||
| 						.IsEnabled(this, &SPolishBuildingsDialog::IsMaterialMergingEnabled) | ||||
| 						.OptionsSource(&MergedMaterialResolutionOptions) | ||||
| 						.InitiallySelectedItem( MergedMaterialResolutionOptions[FMath::FloorLog2( Tool->MergingSettings.MaterialSettings.TextureSize.X )] ) | ||||
| 						.OnSelectionChanged(this, &SPolishBuildingsDialog::SetMergedMaterialAtlasResolution) | ||||
| 						.Font(FEditorStyle::GetFontStyle("StandardDialog.SmallFont")) | ||||
| 					] | ||||
| 				]														 | ||||
| 			] | ||||
| 		] | ||||
| 	]; | ||||
| } | ||||
| END_SLATE_FUNCTION_BUILD_OPTIMIZATION | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetGenerateLightmapUV() const | ||||
| { | ||||
| 	return (Tool->MergingSettings.bGenerateLightMapUV ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetGenerateLightmapUV(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.bGenerateLightMapUV = (ECheckBoxState::Checked == NewValue); | ||||
| } | ||||
|  | ||||
| bool SPolishBuildingsDialog::IsLightmapChannelEnabled() const | ||||
| { | ||||
| 	return Tool->MergingSettings.bGenerateLightMapUV; | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetTargetLightMapChannel(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo) | ||||
| { | ||||
| 	TTypeFromString<int32>::FromString(Tool->MergingSettings.TargetLightMapUVChannel, **NewSelection); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetTargetLightMapResolution(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo) | ||||
| { | ||||
| 	TTypeFromString<int32>::FromString(Tool->MergingSettings.TargetLightMapResolution, **NewSelection); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetExportSpecificLODEnabled() const | ||||
| { | ||||
| 	return (Tool->bExportSpecificLOD ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportSpecificLODEnabled(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->bExportSpecificLOD = (NewValue == ECheckBoxState::Checked); | ||||
| } | ||||
|  | ||||
| bool SPolishBuildingsDialog::IsExportSpecificLODEnabled() const | ||||
| { | ||||
| 	return Tool->bExportSpecificLOD; | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportSpecificLODIndex(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo) | ||||
| { | ||||
| 	TTypeFromString<int32>::FromString(Tool->ExportLODIndex, **NewSelection); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetImportVertexColors() const | ||||
| { | ||||
| 	return ( Tool->MergingSettings.bBakeVertexData ? ECheckBoxState::Checked : ECheckBoxState::Unchecked ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetImportVertexColors(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.bBakeVertexData = ( ECheckBoxState::Checked == NewValue ); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetPivotPointAtZero() const | ||||
| { | ||||
| 	return (Tool->MergingSettings.bPivotPointAtZero ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetPivotPointAtZero(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.bPivotPointAtZero = (ECheckBoxState::Checked == NewValue); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetReplaceSourceActors() const | ||||
| { | ||||
| 	return (Tool->bReplaceSourceActors ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetReplaceSourceActors(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->bReplaceSourceActors = (ECheckBoxState::Checked == NewValue); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetMergePhyisicData() const | ||||
| { | ||||
| 	return (Tool->MergingSettings.bMergePhysicsData ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetMergePhyisicData(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.bMergePhysicsData = (ECheckBoxState::Checked == NewValue); | ||||
| } | ||||
|  | ||||
| bool SPolishBuildingsDialog::IsMaterialMergingEnabled() const | ||||
| { | ||||
| 	return Tool->MergingSettings.bMergeMaterials; | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetMergeMaterials() const | ||||
| { | ||||
| 	return (Tool->MergingSettings.bMergeMaterials ? ECheckBoxState::Checked : ECheckBoxState::Unchecked); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetMergeMaterials(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.bMergeMaterials = (ECheckBoxState::Checked == NewValue); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetExportNormalMap() const | ||||
| { | ||||
| 	return ( Tool->MergingSettings.MaterialSettings.bNormalMap ? ECheckBoxState::Checked : ECheckBoxState::Unchecked ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportNormalMap(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.MaterialSettings.bNormalMap = ( ECheckBoxState::Checked == NewValue ); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetExportMetallicMap() const | ||||
| { | ||||
| 	return ( Tool->MergingSettings.MaterialSettings.bMetallicMap ? ECheckBoxState::Checked : ECheckBoxState::Unchecked ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportMetallicMap(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.MaterialSettings.bMetallicMap = ( ECheckBoxState::Checked == NewValue ); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetExportRoughnessMap() const | ||||
| { | ||||
| 	return ( Tool->MergingSettings.MaterialSettings.bRoughnessMap ? ECheckBoxState::Checked : ECheckBoxState::Unchecked ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportRoughnessMap(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.MaterialSettings.bRoughnessMap = ( ECheckBoxState::Checked == NewValue ); | ||||
| } | ||||
|  | ||||
| ECheckBoxState SPolishBuildingsDialog::GetExportSpecularMap() const | ||||
| { | ||||
| 	return ( Tool->MergingSettings.MaterialSettings.bSpecularMap ? ECheckBoxState::Checked : ECheckBoxState::Unchecked ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetExportSpecularMap(ECheckBoxState NewValue) | ||||
| { | ||||
| 	Tool->MergingSettings.MaterialSettings.bSpecularMap = ( ECheckBoxState::Checked == NewValue ); | ||||
| } | ||||
|  | ||||
| void SPolishBuildingsDialog::SetMergedMaterialAtlasResolution(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo) | ||||
| { | ||||
| 	TTypeFromString<int32>::FromString( Tool->MergingSettings.MaterialSettings.TextureSize.X, **NewSelection ); | ||||
| 	TTypeFromString<int32>::FromString( Tool->MergingSettings.MaterialSettings.TextureSize.Y, **NewSelection ); | ||||
| } | ||||
|  | ||||
|  | ||||
| #undef LOCTEXT_NAMESPACE | ||||
| @@ -0,0 +1,86 @@ | ||||
| // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. | ||||
| #pragma once | ||||
|  | ||||
| class FPolishBuildingsTool; | ||||
|  | ||||
| /*----------------------------------------------------------------------------- | ||||
|    SPolishBuildingsDialog | ||||
| -----------------------------------------------------------------------------*/ | ||||
| class SPolishBuildingsDialog : public SCompoundWidget | ||||
| { | ||||
| public: | ||||
| 	SLATE_BEGIN_ARGS(SPolishBuildingsDialog) | ||||
| 	{ | ||||
| 	} | ||||
|  | ||||
| 	SLATE_END_ARGS() | ||||
|  | ||||
| public: | ||||
| 	/** **/ | ||||
| 	SPolishBuildingsDialog(); | ||||
|  | ||||
| 	/** SWidget functions */ | ||||
| 	void Construct(const FArguments& InArgs, FPolishBuildingsTool* InTool); | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	/** Called when the Merge button is clicked */ | ||||
| 	FReply OnMergeClicked(); | ||||
|  | ||||
| 	/**  */ | ||||
| 	ECheckBoxState GetGenerateLightmapUV() const; | ||||
| 	void SetGenerateLightmapUV(ECheckBoxState NewValue); | ||||
|  | ||||
| 	/** Target lightmap channel */ | ||||
| 	bool IsLightmapChannelEnabled() const; | ||||
| 	void SetTargetLightMapChannel(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo); | ||||
| 	void SetTargetLightMapResolution(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo); | ||||
|  | ||||
| 	/**  */ | ||||
| 	ECheckBoxState GetExportSpecificLODEnabled() const; | ||||
| 	void SetExportSpecificLODEnabled(ECheckBoxState NewValue); | ||||
| 	bool IsExportSpecificLODEnabled() const; | ||||
| 	void SetExportSpecificLODIndex(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo); | ||||
| 		 | ||||
| 	/**  */ | ||||
| 	ECheckBoxState GetImportVertexColors() const; | ||||
| 	void SetImportVertexColors(ECheckBoxState NewValue); | ||||
|  | ||||
| 	/**  */ | ||||
| 	ECheckBoxState GetPivotPointAtZero() const; | ||||
| 	void SetPivotPointAtZero(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetReplaceSourceActors() const; | ||||
| 	void SetReplaceSourceActors(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetMergePhyisicData() const; | ||||
| 	void SetMergePhyisicData(ECheckBoxState NewValue); | ||||
| 	 | ||||
| 	/** Material merging */ | ||||
| 	bool IsMaterialMergingEnabled() const; | ||||
| 	ECheckBoxState GetMergeMaterials() const; | ||||
| 	void SetMergeMaterials(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetExportNormalMap() const; | ||||
| 	void SetExportNormalMap(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetExportMetallicMap() const; | ||||
| 	void SetExportMetallicMap(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetExportRoughnessMap() const; | ||||
| 	void SetExportRoughnessMap(ECheckBoxState NewValue); | ||||
|  | ||||
| 	ECheckBoxState GetExportSpecularMap() const; | ||||
| 	void SetExportSpecularMap(ECheckBoxState NewValue); | ||||
|  | ||||
| 	void SetMergedMaterialAtlasResolution(TSharedPtr<FString> NewSelection, ESelectInfo::Type SelectInfo); | ||||
| 	 | ||||
| private: | ||||
|  | ||||
| 	FPolishBuildingsTool* Tool; | ||||
|  | ||||
| 	TArray<TSharedPtr<FString>>	ExportLODOptions; | ||||
| 	TArray<TSharedPtr<FString>>	LightMapResolutionOptions; | ||||
| 	TArray<TSharedPtr<FString>>	LightMapChannelOptions; | ||||
| 	TArray<TSharedPtr<FString>>	MergedMaterialResolutionOptions; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user