From ab13eff15169c1ec024ac8de56d05c678ead88dd Mon Sep 17 00:00:00 2001 From: 4sval Date: Sun, 26 Feb 2023 06:14:05 +0100 Subject: [PATCH] animation relative retargeting? + covering fmodel's ass --- FModel/MainWindow.xaml.cs | 7 ++----- FModel/Views/Snooper/Animations/Skeleton.cs | 12 ++++++++++-- FModel/Views/Snooper/SnimGui.cs | 4 ++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index 3eff847c..ef2bc7f9 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -78,13 +78,10 @@ public partial class MainWindow #if DEBUG // await _threadWorkerView.Begin(cancellationToken => // _applicationView.CUE4Parse.Extract(cancellationToken, - // "fortnitegame/Content/Characters/Player/Female/Medium/Bodies/F_MED_Prime/Meshes/F_MED_Prime.uasset")); + // "Phoenix/Content/RiggedObjects/Characters/Creatures/Elves/OneOff/HouseElf_F_T3/SK_HouseElf_F_T3_Master.uasset")); // await _threadWorkerView.Begin(cancellationToken => // _applicationView.CUE4Parse.Extract(cancellationToken, - // "fortnitegame/Content/Animation/Game/MainPlayer/Emotes/Annual/Emote_Annual_CMM_BODY.uasset")); - // await _threadWorkerView.Begin(cancellationToken => - // _applicationView.CUE4Parse.Extract(cancellationToken, - // "fortnitegame/Content/Animation/Game/MainPlayer/Emotes/Annual/Emote_Annual_CMF_BODY.uasset")); + // "Phoenix/Content/Animation/Creatures/Elves/ELF_Rct_Mandrake_Loop_anm.uasset")); #endif } diff --git a/FModel/Views/Snooper/Animations/Skeleton.cs b/FModel/Views/Snooper/Animations/Skeleton.cs index 5f9286c7..d04df4b1 100644 --- a/FModel/Views/Snooper/Animations/Skeleton.cs +++ b/FModel/Views/Snooper/Animations/Skeleton.cs @@ -94,7 +94,9 @@ public class Skeleton : IDisposable { _animatedBonesTransform[s][boneIndices.BoneIndex][frame] = new Transform { - Relation = originalTransform.LocalMatrix * _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix + Relation = boneIndices.HasParentTrack ? + originalTransform.LocalMatrix * _animatedBonesTransform[s][boneIndices.ParentTrackIndex][frame].Matrix : + originalTransform.Relation }; } } @@ -131,8 +133,14 @@ public class Skeleton : IDisposable } case EBoneTranslationRetargetingMode.AnimationRelative when !rotationOnly: { - // https://github.com/EpicGames/UnrealEngine/blob/cdaec5b33ea5d332e51eee4e4866495c90442122/Engine/Source/Runtime/Engine/Private/Animation/AnimationRuntime.cpp#L2586 + // can't tell if it's working or not + var sourceSkelTrans = originalTransform.Position / Constants.SCALE_DOWN_RATIO; var refPoseTransform = sequence.RetargetBasePose?[trackIndex] ?? anim.BonePositions[trackIndex]; + + boneOrientation = boneOrientation * FQuat.Conjugate(originalTransform.Rotation) * refPoseTransform.Rotation; + bonePosition += refPoseTransform.Translation - sourceSkelTrans; + boneScale *= refPoseTransform.Scale3D * originalTransform.Scale; + boneOrientation.Normalize(); break; } case EBoneTranslationRetargetingMode.OrientAndScale when !rotationOnly: diff --git a/FModel/Views/Snooper/SnimGui.cs b/FModel/Views/Snooper/SnimGui.cs index bcaa8750..09d09e60 100644 --- a/FModel/Views/Snooper/SnimGui.cs +++ b/FModel/Views/Snooper/SnimGui.cs @@ -751,6 +751,10 @@ Snooper aims to give an accurate preview of models, materials, skeletal animatio float framerate = ImGui.GetIO().Framerate; ImGui.SetCursorPos(size with { X = 7.5f }); ImGui.Text($"FPS: {framerate:0} ({1000.0f / framerate:0.##} ms)"); + + const string label = "Previewed content may differ from final version saved or used in-game."; + ImGui.SetCursorPos(size with { X = size.X - ImGui.CalcTextSize(label).X - 7.5f }); + ImGui.TextColored(new Vector4(0.50f, 0.50f, 0.50f, 1.00f), label); }, false); ImGui.PopStyleVar(); }