diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index 83d6d72d..f54a1c92 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -327,22 +327,27 @@ namespace FModel.ViewModels } public async Task LoadLocalizedResources() + { + await LoadGameLocalizedResources(); + await LoadHotfixedLocalizedResources(); + if (LocalizedResourcesCount > 0) + { + FLogger.AppendInformation(); + FLogger.AppendText($"{LocalizedResourcesCount} localized resources loaded for '{UserSettings.Default.AssetLanguage.GetDescription()}'", Constants.WHITE, true); + } + else + { + FLogger.AppendWarning(); + FLogger.AppendText($"Could not load localized resources in '{UserSettings.Default.AssetLanguage.GetDescription()}', language may not exist", Constants.WHITE, true); + } + } + + private async Task LoadGameLocalizedResources() { if (LocalizedResourcesCount > 0) return; await _threadWorkerView.Begin(cancellationToken => { LocalizedResourcesCount = Provider.LoadLocalization(UserSettings.Default.AssetLanguage, cancellationToken); - if (LocalizedResourcesCount > 0) - { - FLogger.AppendInformation(); - FLogger.AppendText($"{LocalizedResourcesCount} localized resources loaded for '{UserSettings.Default.AssetLanguage.GetDescription()}'", Constants.WHITE, true); - } - else - { - FLogger.AppendWarning(); - FLogger.AppendText($"Could not load localized resources in '{UserSettings.Default.AssetLanguage.GetDescription()}', language may not exist", Constants.WHITE, true); - } - Utils.Typefaces = new Typefaces(this); }); } @@ -350,8 +355,8 @@ namespace FModel.ViewModels /// /// Load hotfixed localized resources /// - /// Functions only when LoadLocalizedResources is used prior to this. - public async Task LoadHotfixedLocalizedResources() + /// Functions only when LoadLocalizedResources is used prior to this (Asval: Why?). + private async Task LoadHotfixedLocalizedResources() { if (Game != FGame.FortniteGame) return; diff --git a/FModel/ViewModels/Commands/LoadCommand.cs b/FModel/ViewModels/Commands/LoadCommand.cs index 40429b8d..6577c37e 100644 --- a/FModel/ViewModels/Commands/LoadCommand.cs +++ b/FModel/ViewModels/Commands/LoadCommand.cs @@ -61,7 +61,6 @@ namespace FModel.ViewModels.Commands MainWindow.YesWeCats.LeftTabControl.SelectedIndex = 1; // folders tab await _applicationView.CUE4Parse.LoadLocalizedResources(); // load locres if not already loaded - await _applicationView.CUE4Parse.LoadHotfixedLocalizedResources(); // load hofixed locres await _applicationView.CUE4Parse.LoadVirtualPaths(); // load virtual paths if not already loaded Helper.CloseWindow("Search View"); // close search window if opened @@ -226,4 +225,4 @@ namespace FModel.ViewModels.Commands _applicationView.CUE4Parse.AssetsFolder.BulkPopulate(entries); } } -} \ No newline at end of file +} diff --git a/FModel/ViewModels/ModelViewerViewModel.cs b/FModel/ViewModels/ModelViewerViewModel.cs index 32d6de81..b329a54e 100644 --- a/FModel/ViewModels/ModelViewerViewModel.cs +++ b/FModel/ViewModels/ModelViewerViewModel.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using CUE4Parse.UE4.Assets.Exports; using CUE4Parse.UE4.Assets.Exports.Material; using CUE4Parse.UE4.Assets.Exports.SkeletalMesh; @@ -10,8 +11,10 @@ using CUE4Parse_Conversion.Meshes.PSK; using CUE4Parse_Conversion.Textures; using FModel.Framework; using HelixToolkit.SharpDX.Core; +using HelixToolkit.SharpDX.Core.Model; using HelixToolkit.Wpf.SharpDX; using SharpDX; +using SharpDX.DXGI; using Camera = HelixToolkit.Wpf.SharpDX.Camera; using Geometry3D = HelixToolkit.SharpDX.Core.Geometry3D; using PerspectiveCamera = HelixToolkit.Wpf.SharpDX.PerspectiveCamera; @@ -80,7 +83,7 @@ namespace FModel.ViewModels public void LoadExport(UObject export) { - Group3d.Clear(); + Clear(); switch (export) { case UStaticMesh st: @@ -151,19 +154,35 @@ namespace FModel.ViewModels if (section.Material == null || !section.Material.TryLoad(out var unrealMaterial)) continue; + var m = new PhongMaterial { RenderShadowMap = true, EnableAutoTangent = true }; var parameters = new CMaterialParams(); unrealMaterial.GetParams(parameters); - if (parameters.Diffuse is not UTexture2D diffuse) - continue; + + var isRendering = !parameters.IsNull; + if (isRendering) + { + if (parameters.Diffuse is UTexture2D diffuse) + m.DiffuseMap = new TextureModel(diffuse.Decode()?.Encode().AsStream()); + if (parameters.Normal is UTexture2D normal) + m.NormalMap = new TextureModel(normal.Decode()?.Encode().AsStream()); + // if (parameters.Specular is UTexture2D specular) + // m.SpecularColorMap = new TextureModel(specular.Decode()?.Encode().AsStream()); + // if (parameters.UseMobileSpecular) + // m.SpecularShininess = parameters.MobileSpecularPower; + // if (parameters.Emissive is UTexture2D emissive) + // m.EmissiveMap = new TextureModel(emissive.Decode()?.Encode().AsStream()); + } + else + { + m = PhongMaterials.Red; + } Group3d.Add(new MeshGeometryModel3D { Name = unrealMaterial.Name, Geometry = builder.ToMeshGeometry3D(), - Material = new DiffuseMaterial - { - DiffuseMap = new TextureModel(diffuse.Decode()?.Encode().AsStream()) - } + Material = m, + IsRendering = isRendering }); } } @@ -186,5 +205,14 @@ namespace FModel.ViewModels lineBuilder.AddLine(new Vector3(0, 0, 0), new Vector3(0, 0, max.Z)); ZAxis = lineBuilder.ToLineGeometry3D(); } + + private void Clear() + { + foreach (var g in Group3d.ToList()) + { + g.Dispose(); + Group3d.Remove(g); + } + } } } diff --git a/FModel/Views/ModelViewer.xaml b/FModel/Views/ModelViewer.xaml index 1e20f174..d1c1c1e1 100644 --- a/FModel/Views/ModelViewer.xaml +++ b/FModel/Views/ModelViewer.xaml @@ -2,12 +2,13 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:converters="clr-namespace:FModel.Views.Resources.Converters" + xmlns:adonisUi="clr-namespace:AdonisUI;assembly=AdonisUI" xmlns:adonisControls="clr-namespace:AdonisUI.Controls;assembly=AdonisUI" xmlns:helix="http://helix-toolkit.org/wpf/SharpDX" WindowStartupLocation="CenterScreen" ResizeMode="CanResize" IconVisibility="Collapsed" Background="#262630" PreviewKeyDown="OnWindowKeyDown" Closing="OnClosing" Height="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenHeight}, Converter={converters:RatioConverter}, ConverterParameter='0.60'}" - Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.50'}"> + Width="{Binding Source={x:Static SystemParameters.MaximizedPrimaryScreenWidth}, Converter={converters:RatioConverter}, ConverterParameter='0.60'}"> - + - + + + + + + + + + + + + + + + + + + + - + - + - + - + - @@ -1372,7 +1439,7 @@ - + @@ -1397,13 +1464,13 @@ - + - + - + - + - + - + - + - - \ No newline at end of file + + diff --git a/FModel/Views/SettingsView.xaml.cs b/FModel/Views/SettingsView.xaml.cs index 67f21f6d..2a7ca7e0 100644 --- a/FModel/Views/SettingsView.xaml.cs +++ b/FModel/Views/SettingsView.xaml.cs @@ -45,7 +45,6 @@ namespace FModel.Views { _applicationView.CUE4Parse.LocalizedResourcesCount = 0; await _applicationView.CUE4Parse.LoadLocalizedResources(); - await _applicationView.CUE4Parse.LoadHotfixedLocalizedResources(); } } @@ -119,8 +118,8 @@ namespace FModel.Views var result = dictionary.ShowDialog(); if (!result.HasValue || !result.Value) return; - + _applicationView.SettingsView.SelectedOptions = dictionary.Options; } } -} \ No newline at end of file +}