Ace Combat 8, Dead Island 2, ArcheAge War and Sleepless Wilds support / IRMesh and HoudiniSM support
Some checks failed
FModel QA Builder / build (push) Has been cancelled

This commit is contained in:
LongerWarrior
2026-10-04 23:22:14 +03:00
committed by GitHub
18 changed files with 245 additions and 76 deletions

View File

@@ -47,14 +47,12 @@ public class BaseIcon : UCreator
{
if (isUsingDisplayAsset && Utils.TryGetDisplayAsset(Object, out var preview))
Preview = preview;
else if (Object.TryGetValue(out FPackageIndex itemDefinition, "HeroDefinition", "WeaponDefinition"))
else if (Object.TryGetValue(out ILoadableObject itemDefinition, "HeroDefinition", "WeaponDefinition"))
Preview = Utils.GetBitmap(itemDefinition);
else if (Object.TryGetValue(out FSoftObjectPath largePreview, "LargePreviewImage", "EntryListIcon", "SmallPreviewImage", "BundleImage", "ItemDisplayAsset", "LargeIcon", "ToastIcon", "SmallIcon", "CartridgeIcon", "EffectIcon"))
else if (Object.TryGetValue(out ILoadableObject largePreview, "LargePreviewImage", "EntryListIcon", "SmallPreviewImage", "BundleImage", "ItemDisplayAsset", "LargeIcon", "ToastIcon", "SmallIcon", "CartridgeIcon", "EffectIcon", "ToastIcon", "access_item"))
Preview = Utils.GetBitmap(largePreview);
else if (Object.TryGetValue(out string s, "LargePreviewImage") && !string.IsNullOrEmpty(s))
Preview = Utils.GetBitmap(s);
else if (Object.TryGetValue(out FPackageIndex otherPreview, "SmallPreviewImage", "ToastIcon", "access_item"))
Preview = Utils.GetBitmap(otherPreview);
else if (Object.TryGetValue(out UMaterialInstanceConstant materialInstancePreview, "EventCalloutImage"))
Preview = Utils.GetBitmap(materialInstancePreview);
else if (Object.TryGetValue(out FStructFallback brush, "IconBrush", "BuildingSymbolNormal") && brush.TryGetValue(out UTexture2D res, "ResourceObject"))

View File

@@ -60,11 +60,11 @@ public static class Utils
return preview != null;
}
public static SKBitmap GetBitmap(FPackageIndex packageIndex)
public static SKBitmap GetBitmap(ILoadableObject loadableObject)
{
while (true)
{
if (!TryGetPackageIndexExport(packageIndex, out UObject export)) return null;
if (!loadableObject.TryLoad(out UObject export)) return null;
switch (export)
{
case UTexture2D texture:
@@ -74,13 +74,8 @@ public static class Utils
default:
{
if (export.TryGetValue(out FInstancedStruct[] dataList, "DataList")) return GetBitmap(dataList);
if (export.TryGetValue(out FSoftObjectPath previewImage, "LargePreviewImage", "SmallPreviewImage")) return GetBitmap(previewImage);
if (export.TryGetValue(out ILoadableObject previewImage, "LargePreviewImage", "SmallPreviewImage")) return GetBitmap(previewImage);
if (export.TryGetValue(out string largePreview, "LargePreviewImage")) return GetBitmap(largePreview);
if (export.TryGetValue(out FPackageIndex smallPreview, "SmallPreviewImage"))
{
packageIndex = smallPreview;
continue;
}
return null;
}
@@ -128,7 +123,6 @@ public static class Utils
}
public static SKBitmap GetB64Bitmap(string b64) => SKBitmap.Decode(new MemoryStream(Convert.FromBase64String(b64)) { Position = 0 });
public static SKBitmap GetBitmap(FSoftObjectPath softObjectPath) => GetBitmap(softObjectPath.Load<UTexture2D>());
public static SKBitmap GetBitmap(string fullPath) => TryLoadObject(fullPath, out UTexture2D texture) ? GetBitmap(texture) : null;
public static SKBitmap GetBitmap(UTexture2D texture) => texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform).ToSkBitmap();
public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data);

View File

@@ -169,6 +169,7 @@ public enum EAssetCategory : uint
LegoBatman = GameSpecific + 5,
ArcSys = GameSpecific + 6,
GothamKnights = GameSpecific + 7,
Nascar = GameSpecific + 8,
}
public enum EAssetFamily
@@ -177,6 +178,7 @@ public enum EAssetFamily
Criware,
Wwise,
FMod,
Houdini,
}
public enum EUnluacMode

View File

@@ -4,7 +4,7 @@ namespace FModel.Extensions;
public static class ListBoxExtensions
{
public static ListBoxItem RevealItem(this ListBox list, object item, bool alignToTop = false)
public static ListBoxItem RevealItem(this ListBox list, object item)
{
var index = list.Items.IndexOf(item);
if (index < 0)
@@ -12,12 +12,6 @@ public static class ListBoxExtensions
list.ApplyTemplate();
list.UpdateLayout();
if (alignToTop && list.FindVisualChild<ScrollViewer>() is { } scroll)
{
scroll.ScrollToVerticalOffset(index);
list.UpdateLayout();
}
if (list.FindVisualChild<VirtualizingPanel>() is { } panel)
{
panel.BringIndexIntoViewPublic(index);

View File

@@ -382,6 +382,7 @@
<Separator Grid.Row="1" Style="{StaticResource CustomSeparator}" Margin="0" />
<controls:FolderTree Grid.Row="2" x:Name="AssetsFolderName"
Style="{StaticResource AssetsFolderListBox}"
IsTextSearchEnabled="False"
Folders="{Binding CUE4Parse.AssetsFolder}"
ItemsSource="{Binding CUE4Parse.AssetsFolder.VisibleFolders}"
SelectedItem="{Binding CUE4Parse.AssetsFolder.SelectedFolder, Mode=TwoWay}"

View File

@@ -165,7 +165,7 @@ public partial class MainWindow
_applicationView.CUE4Parse.TabControl.SelectedTab.GoNextImage();
else if (_applicationView.Status.IsReady && _applicationView.IsAssetsExplorerVisible && Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
{
CategoriesSelector.SelectedIndex = e.SystemKey switch
var categoryIndex = e.SystemKey switch
{
Key.D0 or Key.NumPad0 => 0,
Key.D1 or Key.NumPad1 => 1,
@@ -177,8 +177,13 @@ public partial class MainWindow
Key.D7 or Key.NumPad7 => 7,
Key.D8 or Key.NumPad8 => 8,
Key.D9 or Key.NumPad9 => 9,
_ => CategoriesSelector.SelectedIndex
_ => -1
};
if (categoryIndex < 0)
return;
CategoriesSelector.SelectedIndex = categoryIndex;
}
else if (_applicationView.Status.IsReady && UserSettings.Default.ExportData.IsTriggered(e.Key))
OnExportHotkey("Save_Data");
@@ -210,6 +215,10 @@ public partial class MainWindow
_applicationView.SelectedLeftTabIndex--;
else if (UserSettings.Default.DirRightTab.IsTriggered(e.Key) && _applicationView.SelectedLeftTabIndex < LeftTabControl.Items.Count - 1)
_applicationView.SelectedLeftTabIndex++;
else
return;
e.Handled = true;
}
private void OnSearchViewClick(object sender, RoutedEventArgs e)

View File

@@ -19,6 +19,8 @@ using CUE4Parse.Encryption.Aes;
using CUE4Parse.FileProvider;
using CUE4Parse.FileProvider.Objects;
using CUE4Parse.FileProvider.Vfs;
using CUE4Parse.GameTypes.ACE8.Assets.Exports;
using CUE4Parse.GameTypes.ACE8.Encryption;
using CUE4Parse.GameTypes.Aion2.Objects;
using CUE4Parse.GameTypes.AoC.Objects;
using CUE4Parse.GameTypes.AshEchoes.FileProvider;
@@ -30,6 +32,7 @@ using CUE4Parse.GameTypes.DFHO.Assets.Objects;
using CUE4Parse.GameTypes.HonorOfKings.FileProvider;
using CUE4Parse.GameTypes.KRD.Assets.Exports;
using CUE4Parse.GameTypes.LegoBatman.Assets;
using CUE4Parse.GameTypes.Nascar.Assets.Exports;
using CUE4Parse.GameTypes.LordOfMysteries.FileProvider;
using CUE4Parse.GameTypes.Tencent.RocoKingdomWorld.Assets.Objects;
using CUE4Parse.GameTypes.SMG.UE4.Assets.Exports.Wwise;
@@ -47,6 +50,7 @@ using CUE4Parse.UE4.Assets.Exports.Criware;
using CUE4Parse.UE4.Assets.Exports.Engine;
using CUE4Parse.UE4.Assets.Exports.Fmod;
using CUE4Parse.UE4.Assets.Exports.GeometryCollection;
using CUE4Parse.UE4.Assets.Exports.Houdini;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.Sound;
using CUE4Parse.UE4.Assets.Exports.StaticMesh;
@@ -721,12 +725,15 @@ public class CUE4ParseViewModel : ViewModel
break;
}
var showSnooper = false;
for (var i = result.InclusiveStart; i < result.ExclusiveEnd; i++)
{
if (CheckExport(cancellationToken, result.Package, i, bulk))
if (CheckExport(cancellationToken, result.Package, i, ref showSnooper, bulk))
break;
}
if (showSnooper) SnooperViewer.Run();
break;
}
case "ini" when entry.Name.Contains("BinaryConfig"):
@@ -744,6 +751,11 @@ public class CUE4ParseViewModel : ViewModel
ProcessAion2DatFile(entry, updateUi, saveProperties);
break;
}
case "dat" when Provider.Versions.Game is GAME_AceCombat8WingsofTheve:
{
ProcessACE8DatFile(entry, updateUi, saveProperties);
break;
}
case "bytes" when Provider.Versions.Game is GAME_RocoKingdomWorld:
{
ProcessRocoBinFile(entry, updateUi, saveProperties);
@@ -1062,6 +1074,7 @@ public class CUE4ParseViewModel : ViewModel
}
case "res": // just skip
case "bytes": // wuthering waves
case "ffxanim": // dead island 2
break;
default:
{
@@ -1185,6 +1198,43 @@ public class CUE4ParseViewModel : ViewModel
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(dbc, Formatting.Indented), saveProperties, updateUi);
}
// Ace Combat 8
void ProcessACE8DatFile(GameFile entry, bool updateUi, bool saveProperties)
{
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("json");
if (entry.NameWithoutExtension.EndsWith("_Cmn"))
{
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ACE8LocDecrypt.ReadKeysDatFile(entry), Formatting.Indented), saveProperties, updateUi);
}
else
{
if (Provider.TryGetGameFile(entry.PathWithoutExtension[..^1] + "Cmn." + entry.Extension, out var keysDatFile))
{
var keys = ACE8LocDecrypt.ReadKeysDatFile(keysDatFile);
var values = ACE8LocDecrypt.ReadDatFile(entry);
var locTable = new Dictionary<string, string>(Math.Max(keys.Count, values.Length));
var k = 0;
for (var i = 0; i < values.Length; i++)
{
if (keys.TryGetValue(i, out var key))
{
locTable[key] = values[i];
}
else
{
locTable[$"UnknownKey_{k++}"] = values[i];
}
}
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(locTable, Formatting.Indented), saveProperties, updateUi);
}
else
{
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ACE8LocDecrypt.ReadDatFile(entry), Formatting.Indented), saveProperties, updateUi);
}
}
}
}
private byte[] ProcessLuaFile(byte[] data)
@@ -1248,14 +1298,17 @@ public class CUE4ParseViewModel : ViewModel
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector(""); // json
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(result.GetDisplayData(), Formatting.Indented), false, false);
var showSnooper = false;
for (var i = result.InclusiveStart; i < result.ExclusiveEnd; i++)
{
if (CheckExport(cancellationToken, result.Package, i))
if (CheckExport(cancellationToken, result.Package, i, ref showSnooper))
break;
}
if (showSnooper) SnooperViewer.Run();
}
private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, EBulkType bulk = EBulkType.None) // return true once you want to stop searching for exports
private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, ref bool showSnooper, EBulkType bulk = EBulkType.None) // return true once you want to stop searching for exports
{
var isNone = bulk == EBulkType.None;
var updateUi = !HasFlag(bulk, EBulkType.Auto);
@@ -1270,11 +1323,21 @@ public class CUE4ParseViewModel : ViewModel
{
case UVerseDigest when isNone && pointer.Object.Value is UVerseDigest verseDigest:
{
if (!TabControl.CanAddTabs) return false;
if (verseDigest.ReadableCode is null || !TabControl.CanAddTabs) return false;
TabControl.AddTab($"{verseDigest.Name}.verse");
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("verse");
TabControl.SelectedTab.SetDocumentText(verseDigest.ReadableCode, false, false);
TabControl.SelectedTab.SetDocumentText(Encoding.UTF8.GetString(verseDigest.ReadableCode), false, false);
return true;
}
// Ace Combat 8
case ULuaScript when isNone && pointer.Object.Value is ULuaScript luaScript:
{
if (!TabControl.CanAddTabs) return false;
TabControl.AddTab($"{luaScript.Name}.lua");
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("lua");
TabControl.SelectedTab.SetDocumentText(luaScript.Code, false, false);
return true;
}
case UTexture when (isNone || saveTextures) && pointer.Object.Value is UTexture texture:
@@ -1594,6 +1657,8 @@ public class CUE4ParseViewModel : ViewModel
// }:
case UPaperSprite when isNone && UserSettings.Default.PreviewMaterials:
case UStaticMesh when isNone && UserSettings.Default.PreviewStaticMeshes:
case UIRMesh when isNone && UserSettings.Default.PreviewStaticMeshes:
case UHoudiniStaticMesh when isNone && UserSettings.Default.PreviewStaticMeshes:
case UGeometryCollection when isNone && UserSettings.Default.PreviewStaticMeshes:
case USkinnedAsset when isNone && UserSettings.Default.PreviewSkeletalMeshes:
case USkeleton when isNone && UserSettings.Default.SaveSkeletonAsMesh:
@@ -1604,23 +1669,32 @@ public class CUE4ParseViewModel : ViewModel
pkg.Name.Contains("/MI_BPTile/", StringComparison.OrdinalIgnoreCase))):
{
if (SnooperViewer.TryLoadExport(cancellationToken, dummy, pointer.Object))
SnooperViewer.Run();
showSnooper = true;
return true;
}
case UIRMeshComponent when isNone && UserSettings.Default.PreviewStaticMeshes:
{
if (SnooperViewer.TryLoadExport(cancellationToken, dummy, pointer.Object))
showSnooper = true;
return false;
}
case UMaterialInstance when isNone && ModelIsOverwritingMaterial && pointer.Object.Value is UMaterialInstance m:
{
SnooperViewer.Renderer.Swap(m);
SnooperViewer.Run();
showSnooper = true;
return true;
}
case UAnimSequenceBase when isNone && UserSettings.Default.PreviewAnimations || ModelIsWaitingAnimation:
{
// animate all animations using their specified skeleton or when we explicitly asked for a loaded model to be animated (ignoring whether we wanted to preview animations)
SnooperViewer.Renderer.Animate(pointer.Object.Value);
SnooperViewer.Run();
showSnooper = true;
return true;
}
case UStaticMesh when HasFlag(bulk, EBulkType.Meshes):
case UIRMesh when HasFlag(bulk, EBulkType.Meshes):
case UHoudiniAsset when HasFlag(bulk, EBulkType.Meshes):
case UHoudiniStaticMesh when HasFlag(bulk, EBulkType.Meshes):
case UGeometryCollection when HasFlag(bulk, EBulkType.Meshes):
case USkinnedAsset when HasFlag(bulk, EBulkType.Meshes):
case USkeleton when UserSettings.Default.SaveSkeletonAsMesh && HasFlag(bulk, EBulkType.Meshes):

View File

@@ -11,6 +11,7 @@ using CUE4Parse.GameTypes.Borderlands3.Assets.Exports;
using CUE4Parse.GameTypes.Borderlands4.Assets.Exports;
using CUE4Parse.GameTypes.FN.Assets.Exports.DataAssets;
using CUE4Parse.GameTypes.LegoBatman.Assets;
using CUE4Parse.GameTypes.Nascar.Assets.Exports;
using CUE4Parse.GameTypes.RED.Assets.Exports;
using CUE4Parse.GameTypes.SMG.UE4.Assets.Exports.Wwise;
using CUE4Parse.GameTypes.SMG.UE4.Assets.Objects;
@@ -31,6 +32,7 @@ using CUE4Parse.UE4.Assets.Exports.Fmod;
using CUE4Parse.UE4.Assets.Exports.FMod;
using CUE4Parse.UE4.Assets.Exports.Foliage;
using CUE4Parse.UE4.Assets.Exports.GeometryCollection;
using CUE4Parse.UE4.Assets.Exports.Houdini;
using CUE4Parse.UE4.Assets.Exports.Internationalization;
using CUE4Parse.UE4.Assets.Exports.LevelSequence;
using CUE4Parse.UE4.Assets.Exports.Material;
@@ -219,6 +221,8 @@ public class GameFileViewModel(GameFile asset) : ViewModel
UFMODEvent or UFMODBank or UFMODBankLookup or UFMODBus
or UFMODSnapshot or UFMODSnapshotReverb or UFMODVCA => EAssetFamily.FMod,
UHoudiniAsset or UHoudiniStaticMesh => EAssetFamily.Houdini,
_ => EAssetFamily.None,
};
@@ -234,12 +238,15 @@ public class GameFileViewModel(GameFile asset) : ViewModel
UClassCookedMetaData or UStructCookedMetaData or UEnumCookedMetaData => (EAssetCategory.CookedMetaData, EBulkType.None),
UStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
UHoudiniStaticMesh => (EAssetCategory.StaticMesh, EBulkType.Meshes),
USkeletalMesh => (EAssetCategory.SkeletalMesh, EBulkType.Meshes),
UChaosClothAsset => (EAssetCategory.ChaosClothAsset, EBulkType.Meshes),
UCustomizableObject => (EAssetCategory.CustomizableObject, EBulkType.None),
UNaniteDisplacedMesh => (EAssetCategory.NaniteDisplacedMesh, EBulkType.None),
UGeometryCollection => (EAssetCategory.GeometryCollection, EBulkType.Meshes),
UHoudiniAsset => (EAssetCategory.Data, EBulkType.Meshes),
UTexture => (EAssetCategory.Texture, EBulkType.Textures),
UMaterialInterface => (EAssetCategory.Material, EBulkType.None),
@@ -294,6 +301,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
UWubAudioEvent or UWubDialogueEvent when GameVersion is EGame.GAME_LEGOBatmanLegacyoftheDarkKnight => (EAssetCategory.LegoBatman, EBulkType.Audio), // Lego Batman: Legacy of the Dark Knight;
UREDBinaryObject => (EAssetCategory.ArcSys, EBulkType.None), // Arc System Works games;
UOrpheusBank or UOrpheusEvent => (EAssetCategory.GothamKnights, EBulkType.Audio), // Gotham Knights;
UIRMesh => (EAssetCategory.Nascar, EBulkType.Meshes), // iRacing games;
_ => (EAssetCategory.All, EBulkType.None),
};
@@ -367,6 +375,7 @@ public class GameFileViewModel(GameFile asset) : ViewModel
"acb" or "acf" or "adx" or "awb" or "hca" or "usm" => EAssetFamily.Criware,
"bnk" or "pck" or "wem" => EAssetFamily.Wwise,
"bank" or "fsb" => EAssetFamily.FMod,
"hda" or "hip" => EAssetFamily.Houdini,
_ => EAssetFamily.None,
};

View File

@@ -55,6 +55,7 @@ public partial class AudioPlayer
if (UserSettings.Default.AddAudio.IsTriggered(e.Key))
{
e.Handled = true;
var openFileDialog = new OpenFileDialog
{
Title = "Select an audio file",
@@ -77,6 +78,10 @@ public partial class AudioPlayer
_applicationView.AudioPlayer.Next();
else if (UserSettings.Default.RemoveAudio.IsTriggered(e.Key))
_applicationView.AudioPlayer.Remove();
else
return;
e.Handled = true;
}
private void OnAudioFileMouseDoubleClick(object sender, MouseButtonEventArgs e)

View File

@@ -58,12 +58,14 @@
<SolidColorBrush x:Key="CriwareBrush" Color="#005bab" />
<SolidColorBrush x:Key="WwiseBrush" Color="#0152a1" />
<SolidColorBrush x:Key="FModBrush" Color="#00758f" />
<SolidColorBrush x:Key="HoudiniBrush" Color="#ff6600" />
<!-- For specific games -->
<SolidColorBrush x:Key="BorderlandsBrush" Color="Yellow"></SolidColorBrush>
<SolidColorBrush x:Key="AionBrush" Color="DeepSkyBlue"></SolidColorBrush>
<SolidColorBrush x:Key="RocoKingdomWorldBrush" Color="#fecf4d"></SolidColorBrush>
<SolidColorBrush x:Key="DeltaForceBrush" Color="LightGreen"></SolidColorBrush>
<SolidColorBrush x:Key="BatmanBrush" Color="Gold"></SolidColorBrush>
<SolidColorBrush x:Key="ArcSysBrush" Color="Red"></SolidColorBrush>
<SolidColorBrush x:Key="BorderlandsBrush" Color="Yellow" />
<SolidColorBrush x:Key="AionBrush" Color="DeepSkyBlue" />
<SolidColorBrush x:Key="RocoKingdomWorldBrush" Color="#fecf4d" />
<SolidColorBrush x:Key="DeltaForceBrush" Color="LightGreen" />
<SolidColorBrush x:Key="BatmanBrush" Color="Gold" />
<SolidColorBrush x:Key="ArcSysBrush" Color="Red" />
<SolidColorBrush x:Key="NascarBrush" Color="#dd002a" />
</ResourceDictionary>

View File

@@ -23,17 +23,6 @@ public sealed class FolderTree : ListBox
public event EventHandler OpenAssets;
public FolderTree()
{
IsVisibleChanged += (_, e) =>
{
if (e.NewValue is true)
{
RevealSelection();
}
};
}
public void SelectFolder(TreeItem folder)
{
Folders.Reveal(folder);
@@ -53,14 +42,6 @@ public sealed class FolderTree : ListBox
}
}
public void RevealSelection()
{
if (SelectedItem is TreeItem folder)
{
this.RevealItem(folder, alignToTop: true);
}
}
private void ToggleFolder(TreeItem folder)
{
if (Folders == null)

View File

@@ -102,6 +102,7 @@ public class FileToGeometryConverter : IMultiValueConverter
EAssetCategory.DeltaForce => ("DeltaForceIcon", "DeltaForceBrush"),
EAssetCategory.LegoBatman or EAssetCategory.GothamKnights => ("BatmanIcon", "BatmanBrush"),
EAssetCategory.ArcSys => ("ArcSysIcon", "ArcSysBrush"),
EAssetCategory.Nascar => ("NascarIcon", "NascarBrush"),
_ => ("AssetIcon", "NeutralBrush")
};
@@ -117,6 +118,8 @@ public class FileToGeometryConverter : IMultiValueConverter
(EAssetFamily.FMod, EAssetCategory.Data) => ("FModIcon", "FModBrush"),
(EAssetFamily.FMod, _) => ("FModIcon", brush),
(EAssetFamily.Houdini, _) => ("HoudiniIcon", "HoudiniBrush"),
_ => (geometry, brush),
};

File diff suppressed because one or more lines are too long

View File

@@ -162,7 +162,8 @@ public class Skeleton : IDisposable
{
bone.AnimatedBySequences.Add(s);
}
sequence.RetargetTracks(animation.Skeleton);
// Retargeting should not be done here (ask Asval for details).
//sequence.RetargetTracks(animation.Skeleton.ReferenceSkeleton);
}
#if DEBUG

View File

@@ -1,12 +1,14 @@
using System;
using System.Numerics;
using CUE4Parse_Conversion.Dto;
using CUE4Parse.GameTypes.Nascar.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports.GeometryCollection;
using CUE4Parse.UE4.Assets.Exports.Houdini;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.StaticMesh;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.UE4.Objects.Core.Math;
using CUE4Parse.UE4.Objects.PhysicsEngine;
using CUE4Parse_Conversion.Dto;
using FModel.Views.Snooper.Shading;
using OpenTK.Graphics.OpenGL4;
@@ -150,6 +152,19 @@ public class StaticModel : UModel<MeshVertex>
Box = staticMesh.Bounds * Constants.SCALE_DOWN_RATIO;
}
public StaticModel(UIRMesh export, StaticMeshDto mesh, int meshIndex)
: base(export, mesh.LODs[LodLevel], export.Materials, mesh.LODs[LodLevel].Vertices, mesh.LODs.Count)
{
Name = meshIndex > 0 ? $"{Name}_{meshIndex}" : Name;
Box = mesh.Bounds * Constants.SCALE_DOWN_RATIO;
}
public StaticModel(UHoudiniStaticMesh export, StaticMeshDto staticMesh, Transform transform = null)
: base(export, staticMesh.LODs[LodLevel], export.Materials, staticMesh.LODs[LodLevel].Vertices, staticMesh.LODs.Count, transform)
{
Box = staticMesh.Bounds * Constants.SCALE_DOWN_RATIO;
}
public override void RenderCollision(Shader shader)
{
base.RenderCollision(shader);

View File

@@ -46,7 +46,7 @@ public abstract class UModel<TVertex> : IRenderableModel where TVertex : struct,
public VertexArrayObject<float, uint> Vao { get; set; }
public string Path { get; }
public string Name { get; }
public string Name { get; protected set; }
public string Type { get; protected set; }
public int UvCount { get; }
public uint[] Indices { get; set; }

View File

@@ -4,15 +4,18 @@ using System.Linq;
using System.Numerics;
using System.Threading;
using System.Windows;
using CUE4Parse.GameTypes.Nascar.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports;
using CUE4Parse.UE4.Assets.Exports.Animation;
using CUE4Parse.UE4.Assets.Exports.Component.SplineMesh;
using CUE4Parse.UE4.Assets.Exports.Component.StaticMesh;
using CUE4Parse.UE4.Assets.Exports.Engine;
using CUE4Parse.UE4.Assets.Exports.GeometryCollection;
using CUE4Parse.UE4.Assets.Exports.Houdini;
using CUE4Parse.UE4.Assets.Exports.Material;
using CUE4Parse.UE4.Assets.Exports.StaticMesh;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse.GameTypes.Nascar.Assets.Exports;
using CUE4Parse.UE4.Objects.Core.Math;
using CUE4Parse.UE4.Objects.Core.Misc;
using CUE4Parse.UE4.Objects.Engine;
@@ -22,6 +25,7 @@ using CUE4Parse_Conversion.Animations;
using CUE4Parse_Conversion.Dto;
using CUE4Parse_Conversion.Meshes;
using CUE4Parse_Conversion.Options;
using CUE4Parse.UE4.Assets.Exports.Component;
using FModel.Creator;
using FModel.Settings;
using FModel.Views.Snooper.Animations;
@@ -90,6 +94,15 @@ public class Renderer : IDisposable
case UStaticMesh when export.Value is UStaticMesh st:
LoadStaticMesh(st, UserSettings.Default.NaniteMeshExportFormat);
break;
case UIRMesh when export.Value is UIRMesh irmc:
LoadIRMeshCollection(irmc);
break;
case UIRMeshComponent when export.Value is UIRMeshComponent meshcomp:
LoadIRMeshComponent(meshcomp);
break;
case UHoudiniStaticMesh when export.Value is UHoudiniStaticMesh hst:
LoadHoudiniStaticMesh(hst);
break;
case UGeometryCollection when export.Value is UGeometryCollection gc:
LoadStaticMesh(gc, UserSettings.Default.NaniteMeshExportFormat);
break;
@@ -366,13 +379,72 @@ public class Renderer : IDisposable
Options.SelectModel(guid);
}
private void LoadIRMeshCollection(UIRMesh original, FPackageIndex[]? materials = null)
{
var hash = (uint) original.GetFullName().GetHashCode();
var guid = new FGuid(hash);
if (Options.TryGetModel(guid, out var model))
return;
if (materials is not null && original.Info.MaterialCount == materials.Length)
original.SetMaterials(materials);
for (int i = 0; i < original.Info.PartCount; i++)
{
try
{
var mesh = new StaticMeshDto(original, i);
Options.Models[new FGuid(hash ^ (uint) i)] = new StaticModel(original, mesh, i) { IsVisible = true };
mesh.Dispose();
}
catch (Exception e)
{
Log.Error(e, "Failed to convert IR static mesh part {PartIndex}", i);
}
}
Options.SelectModel(guid);
}
private void LoadIRMeshComponent(UIRMeshComponent original)
{
if (original.Mesh is { IsNull: false } meshref && meshref.TryLoad(out UIRMesh mesh))
{
LoadIRMeshCollection(mesh, original.OverrideMaterials);
}
}
private void LoadHoudiniStaticMesh(UHoudiniStaticMesh original)
{
var guid = new FGuid((uint) original.GetFullName().GetHashCode());
if (Options.TryGetModel(guid, out var model))
{
model.AddInstance(Transform.Identity);
Application.Current.Dispatcher.Invoke(model.SetupInstances);
return;
}
StaticMeshDto mesh;
try
{
mesh = new StaticMeshDto(original);
}
catch (Exception e)
{
Log.Error(e, "Failed to convert houdini static mesh");
return;
}
Options.Models[guid] = new StaticModel(original, mesh);
Options.SelectModel(guid);
}
private void LoadStaticMesh(UGeometryCollection original, ENaniteMeshFormat naniteFormat = ENaniteMeshFormat.NoNanite)
{
var guid = new FGuid((uint) original.GetFullName().GetHashCode());
if (Options.TryGetModel(guid, out var model))
{
model.AddInstance(Transform.Identity);
Application.Current.Dispatcher.Invoke(() => model.SetupInstances());
Application.Current.Dispatcher.Invoke(model.SetupInstances);
return;
}
@@ -397,7 +469,7 @@ public class Renderer : IDisposable
if (Options.TryGetModel(guid, out var model))
{
model.AddInstance(Transform.Identity);
Application.Current.Dispatcher.Invoke(() => model.SetupInstances());
Application.Current.Dispatcher.Invoke(model.SetupInstances);
return;
}
@@ -408,7 +480,7 @@ public class Renderer : IDisposable
}
catch (Exception e)
{
Log.Error(e, "Failed to convert chaos cloth asset");
Log.Error(e, "Failed to convert skinned asset");
return;
}
@@ -456,7 +528,7 @@ public class Renderer : IDisposable
if (Options.TryGetModel(guid, out var model))
{
model.AddInstance(Transform.Identity);
Application.Current.Dispatcher.Invoke(() => model.SetupInstances());
Application.Current.Dispatcher.Invoke(model.SetupInstances);
return;
}
@@ -581,26 +653,33 @@ public class Renderer : IDisposable
{
foreach (var component in instanceComponents)
{
if (!component.TryLoad(out UStaticMeshComponent staticMeshComp) ||
!staticMeshComp.GetStaticMesh().TryLoad(out UStaticMesh m) || m.Materials.Length < 1)
continue;
if (!component.TryLoad(out UMeshComponent meshComponent)) continue;
var relation = CalculateTransform(staticMeshComp, transform);
if (staticMeshComp is UInstancedStaticMeshComponent { PerInstanceSMData.Length: > 0 } instancedStaticMeshComp)
if (meshComponent is UStaticMeshComponent staticMeshComp)
{
if (!staticMeshComp.GetStaticMesh().TryLoad(out UStaticMesh m) || m.Materials.Length < 1)
continue;
foreach (var perInstanceData in instancedStaticMeshComp.PerInstanceSMData)
var relation = CalculateTransform(staticMeshComp, transform);
if (staticMeshComp is UInstancedStaticMeshComponent { PerInstanceSMData.Length: > 0 } instancedStaticMeshComp)
{
ProcessMesh(actor, instancedStaticMeshComp, m, new Transform
foreach (var perInstanceData in instancedStaticMeshComp.PerInstanceSMData)
{
Relation = relation.Matrix,
Position = perInstanceData.TransformData.Translation * Constants.SCALE_DOWN_RATIO,
Rotation = perInstanceData.TransformData.Rotation,
Scale = perInstanceData.TransformData.Scale3D
});
ProcessMesh(actor, instancedStaticMeshComp, m, new Transform
{
Relation = relation.Matrix,
Position = perInstanceData.TransformData.Translation * Constants.SCALE_DOWN_RATIO,
Rotation = perInstanceData.TransformData.Rotation,
Scale = perInstanceData.TransformData.Scale3D
});
}
}
else ProcessMesh(actor, staticMeshComp, m, relation);
}
else if (meshComponent is UIRMeshComponent irMeshComponent)
{
LoadIRMeshComponent(irMeshComponent);
}
else ProcessMesh(actor, staticMeshComp, m, relation);
}
}
else if (actor.TryGetValue(out FPackageIndex componentTemplate, "ComponentTemplate") &&