mirror of
https://github.com/4sval/FModel.git
synced 2026-03-22 01:34:37 -05:00
preview skeletons + save mesh materials switch
This commit is contained in:
parent
4c5f5a213b
commit
73e027c867
|
|
@ -1 +1 @@
|
|||
Subproject commit 08709aeedf2a1c0cada10f58a5aabb36cf89785e
|
||||
Subproject commit d816fe61ac8e5798d1584ea2f9871acfca0ca429
|
||||
|
|
@ -424,6 +424,13 @@ namespace FModel.Settings
|
|||
set => SetProperty(ref _saveMorphTargets, value);
|
||||
}
|
||||
|
||||
private bool _saveMeshMaterials = true;
|
||||
public bool SaveMeshMaterials
|
||||
{
|
||||
get => _saveMeshMaterials;
|
||||
set => SetProperty(ref _saveMeshMaterials, value);
|
||||
}
|
||||
|
||||
private bool _saveSkeletonAsMesh;
|
||||
public bool SaveSkeletonAsMesh
|
||||
{
|
||||
|
|
|
|||
|
|
@ -896,6 +896,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
case UWorld when isNone && UserSettings.Default.PreviewWorlds:
|
||||
case UStaticMesh when isNone && UserSettings.Default.PreviewStaticMeshes:
|
||||
case USkeletalMesh when isNone && UserSettings.Default.PreviewSkeletalMeshes:
|
||||
case USkeleton when isNone && UserSettings.Default.SaveSkeletonAsMesh:
|
||||
case UMaterialInstance when isNone && UserSettings.Default.PreviewMaterials && !ModelIsOverwritingMaterial &&
|
||||
!(Provider.InternalGameName.Equals("FortniteGame", StringComparison.OrdinalIgnoreCase) && export.Owner != null &&
|
||||
(export.Owner.Name.EndsWith($"/MI_OfferImages/{export.Name}", StringComparison.OrdinalIgnoreCase) ||
|
||||
|
|
@ -984,7 +985,8 @@ public class CUE4ParseViewModel : ViewModel
|
|||
TextureFormat = UserSettings.Default.TextureExportFormat,
|
||||
SocketFormat = UserSettings.Default.SocketExportFormat,
|
||||
Platform = UserSettings.Default.CurrentDir.TexturePlatform,
|
||||
ExportMorphTargets = UserSettings.Default.SaveMorphTargets
|
||||
ExportMorphTargets = UserSettings.Default.SaveMorphTargets,
|
||||
ExportMaterials = UserSettings.Default.SaveMeshMaterials
|
||||
};
|
||||
var toSave = new Exporter(export, exportOptions);
|
||||
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
|
@ -386,20 +387,25 @@
|
|||
IsChecked="{Binding PreviewWorlds, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Text="Save Morph Targets in Meshes" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<TextBlock Grid.Row="10" Grid.Column="0" Text="Save Materials in Meshes" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="10" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding SaveMeshMaterials, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
|
||||
<TextBlock Grid.Row="11" Grid.Column="0" Text="Save Morph Targets in Meshes" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<CheckBox Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding SaveMorphTargets, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 5"/>
|
||||
|
||||
<TextBlock Grid.Row="11" Grid.Column="0" Text="Handle Skeletons as Empty Meshes" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
<TextBlock Grid.Row="12" Grid.Column="0" Text="Handle Skeletons as Empty Meshes" VerticalAlignment="Center" />
|
||||
<CheckBox Grid.Row="12" Grid.Column="2" Grid.ColumnSpan="3" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
|
||||
IsChecked="{Binding SaveSkeletonAsMesh, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"
|
||||
Style="{DynamicResource {x:Static adonisUi:Styles.ToggleSwitch}}" Margin="0 5 0 0"/>
|
||||
|
||||
<Separator Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" />
|
||||
<Separator Grid.Row="13" Grid.Column="0" Grid.ColumnSpan="5" Style="{StaticResource CustomSeparator}" />
|
||||
|
||||
<TextBlock Grid.Row="13" Grid.Column="0" Text="Material Format" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<ComboBox Grid.Row="13" Grid.Column="2" Grid.ColumnSpan="3" ItemsSource="{Binding SettingsView.MaterialExportFormats}" SelectedItem="{Binding SettingsView.SelectedMaterialExportFormat, Mode=TwoWay}"
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="Material Format" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<ComboBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="3" ItemsSource="{Binding SettingsView.MaterialExportFormats}" SelectedItem="{Binding SettingsView.SelectedMaterialExportFormat, Mode=TwoWay}"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" Margin="0 0 0 5">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
|
@ -408,8 +414,8 @@
|
|||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
<TextBlock Grid.Row="14" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<ComboBox Grid.Row="14" Grid.Column="2" Grid.ColumnSpan="3" ItemsSource="{Binding SettingsView.TextureExportFormats}" SelectedItem="{Binding SettingsView.SelectedTextureExportFormat, Mode=TwoWay}"
|
||||
<TextBlock Grid.Row="15" Grid.Column="0" Text="Texture Format" VerticalAlignment="Center" Margin="0 0 0 5" />
|
||||
<ComboBox Grid.Row="15" Grid.Column="2" Grid.ColumnSpan="3" ItemsSource="{Binding SettingsView.TextureExportFormats}" SelectedItem="{Binding SettingsView.SelectedTextureExportFormat, Mode=TwoWay}"
|
||||
DataContext="{Binding DataContext, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:Views.SettingsView}}}" Margin="0 0 0 5">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CUE4Parse_Conversion.Meshes.PSK;
|
||||
using CUE4Parse.UE4.Assets.Exports.Animation;
|
||||
using CUE4Parse.UE4.Assets.Exports.SkeletalMesh;
|
||||
using CUE4Parse.UE4.Objects.Core.Math;
|
||||
using CUE4Parse.UE4.Objects.UObject;
|
||||
using FModel.Views.Snooper.Animations;
|
||||
using FModel.Views.Snooper.Buffers;
|
||||
|
|
@ -53,6 +55,26 @@ public class SkeletalModel : UModel
|
|||
}
|
||||
}
|
||||
|
||||
public SkeletalModel(USkeleton export, FBox box) : base(export)
|
||||
{
|
||||
Indices = Array.Empty<uint>();
|
||||
Materials = Array.Empty<Material>();
|
||||
Vertices = Array.Empty<float>();
|
||||
Sections = Array.Empty<Section>();
|
||||
AddInstance(Transform.Identity);
|
||||
|
||||
Box = box * Constants.SCALE_DOWN_RATIO;
|
||||
Morphs = new List<Morph>();
|
||||
Skeleton = new Skeleton(export.ReferenceSkeleton);
|
||||
Skeleton.Name = export.Name;
|
||||
|
||||
for (int i = 0; i < export.Sockets.Length; i++)
|
||||
{
|
||||
if (export.Sockets[i].Load<USkeletalMeshSocket>() is not { } socket) continue;
|
||||
Sockets.Add(new Socket(socket));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Setup(Options options)
|
||||
{
|
||||
base.Setup(options);
|
||||
|
|
|
|||
|
|
@ -365,7 +365,8 @@ public abstract class UModel : IRenderableModel
|
|||
TextureFormat = UserSettings.Default.TextureExportFormat,
|
||||
SocketFormat = UserSettings.Default.SocketExportFormat,
|
||||
Platform = UserSettings.Default.CurrentDir.TexturePlatform,
|
||||
ExportMorphTargets = UserSettings.Default.SaveMorphTargets
|
||||
ExportMorphTargets = UserSettings.Default.SaveMorphTargets,
|
||||
ExportMaterials = UserSettings.Default.SaveMeshMaterials
|
||||
};
|
||||
var toSave = new Exporter(_export, exportOptions);
|
||||
return toSave.TryWriteToDir(new DirectoryInfo(UserSettings.Default.ModelDirectory), out label, out savedFilePath);
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ public class Renderer : IDisposable
|
|||
case USkeletalMesh sk:
|
||||
LoadSkeletalMesh(sk);
|
||||
break;
|
||||
case USkeleton skel:
|
||||
LoadSkeleton(skel);
|
||||
break;
|
||||
case UMaterialInstance mi:
|
||||
LoadMaterialInstance(mi);
|
||||
break;
|
||||
|
|
@ -349,6 +352,17 @@ public class Renderer : IDisposable
|
|||
Options.SelectModel(guid);
|
||||
}
|
||||
|
||||
private void LoadSkeleton(USkeleton original)
|
||||
{
|
||||
var guid = original.Guid;
|
||||
if (Options.Models.ContainsKey(guid) || !original.TryConvert(out _, out var box)) return;
|
||||
|
||||
var fakeSkeletalModel = new SkeletalModel(original, box);
|
||||
Options.Models[guid] = fakeSkeletalModel;
|
||||
Options.SelectModel(guid);
|
||||
IsSkeletonTreeOpen = true;
|
||||
}
|
||||
|
||||
private void LoadMaterialInstance(UMaterialInstance original)
|
||||
{
|
||||
if (!Utils.TryLoadObject("Engine/Content/BasicShapes/Cube.Cube", out UStaticMesh editorCube))
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user