diff --git a/CUE4Parse b/CUE4Parse index 55d34868..c60c31e8 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 55d34868df2cd33aa4daf6815076f36921492471 +Subproject commit c60c31e8bf01b8af56b741b11922e8630b67980e diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index eec22ac6..7b847587 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -76,19 +76,19 @@ public partial class MainWindow _discordHandler.Initialize(_applicationView.CUE4Parse.Provider.GameName); #if DEBUG - // await _threadWorkerView.Begin(cancellationToken => - // _applicationView.CUE4Parse.Extract(cancellationToken, - // "ShooterGame/Content/Characters/_Core/3P/Models/TP_Core_NewMale_Skelmesh.uasset")); - // await _threadWorkerView.Begin(cancellationToken => - // _applicationView.CUE4Parse.Extract(cancellationToken, - // "Game/Characters/_Core/3P/Anims/TP_Core_SprintAddN_UB.uasset")); + await _threadWorkerView.Begin(cancellationToken => + _applicationView.CUE4Parse.Extract(cancellationToken, + "ShooterGame/Content/Characters/_Core/3P/Models/TP_Core_NewMale_Skelmesh.uasset")); + await _threadWorkerView.Begin(cancellationToken => + _applicationView.CUE4Parse.Extract(cancellationToken, + "Game/Characters/_Core/3P/Anims/TP_Core_SprintAddN_UB.uasset")); - // await _threadWorkerView.Begin(cancellationToken => - // _applicationView.CUE4Parse.Extract(cancellationToken, - // "ShooterGame/Content/Characters/Guide/S0/1P/Models/FP_Guide_S0_Skelmesh.uasset")); - // await _threadWorkerView.Begin(cancellationToken => - // _applicationView.CUE4Parse.Extract(cancellationToken, - // "/Game/Equippables/Guns/SniperRifles/Boltsniper/S0/1P/Anims/FP_Core_Boltsniper_S0_Fire.uasset")); + await _threadWorkerView.Begin(cancellationToken => + _applicationView.CUE4Parse.Extract(cancellationToken, + "ShooterGame/Content/Characters/Guide/S0/1P/Models/FP_Guide_S0_Skelmesh.uasset")); + await _threadWorkerView.Begin(cancellationToken => + _applicationView.CUE4Parse.Extract(cancellationToken, + "/Game/Equippables/Guns/SniperRifles/Boltsniper/S0/1P/Anims/FP_Core_Boltsniper_S0_Fire.uasset")); #endif } diff --git a/FModel/Views/Snooper/Animations/Animation.cs b/FModel/Views/Snooper/Animations/Animation.cs index d87d7fe1..af4e7d0c 100644 --- a/FModel/Views/Snooper/Animations/Animation.cs +++ b/FModel/Views/Snooper/Animations/Animation.cs @@ -44,7 +44,7 @@ public class Animation : IDisposable public Animation(UObject export, CAnimSet animSet) : this(export) { _animSet = animSet; - TargetSkeleton = _animSet.OriginalAnim.Name; + TargetSkeleton = _animSet.Skeleton.Name; Sequences = new Sequence[_animSet.Sequences.Count]; for (int i = 0; i < Sequences.Length; i++) diff --git a/FModel/Views/Snooper/Animations/Sequence.cs b/FModel/Views/Snooper/Animations/Sequence.cs index b0668be5..d6457e24 100644 --- a/FModel/Views/Snooper/Animations/Sequence.cs +++ b/FModel/Views/Snooper/Animations/Sequence.cs @@ -19,13 +19,13 @@ public class Sequence public Sequence(CAnimSequence sequence) { Name = sequence.Name; - TimePerFrame = 1.0f / sequence.Rate; + TimePerFrame = 1.0f / sequence.FramesPerSecond; StartTime = sequence.StartPos; Duration = sequence.AnimEndTime; EndTime = StartTime + Duration; EndFrame = (Duration / TimePerFrame).FloorToInt() - 1; LoopingCount = sequence.LoopingCount; - IsAdditive = sequence.bAdditive; + IsAdditive = sequence.IsAdditive; } public void DrawSequence(ImDrawListPtr drawList, ImFontPtr fontPtr, float x, Vector2 p2, Vector2 timeStep, Vector2 timeRatio, float t, bool animSelected) diff --git a/FModel/Views/Snooper/Animations/Skeleton.cs b/FModel/Views/Snooper/Animations/Skeleton.cs index a5263eed..29d75f52 100644 --- a/FModel/Views/Snooper/Animations/Skeleton.cs +++ b/FModel/Views/Snooper/Animations/Skeleton.cs @@ -110,11 +110,11 @@ public class Skeleton : IDisposable sequence.Tracks[trackedBoneIndex].GetBoneTransform(frame, sequence.NumFrames, ref boneOrientation, ref bonePosition, ref boneScale); - switch (anim.BoneModes[trackedBoneIndex]) + switch (anim.Skeleton.BoneTree[trackedBoneIndex]) { case EBoneTranslationRetargetingMode.Skeleton when !rotationOnly: { - var targetTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.BonePositions[trackedBoneIndex]; + var targetTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.Skeleton.ReferenceSkeleton.FinalRefBonePose[trackedBoneIndex]; bonePosition = targetTransform.Translation; break; } @@ -123,7 +123,7 @@ public class Skeleton : IDisposable var sourceTranslationLength = (originalTransform.Position / Constants.SCALE_DOWN_RATIO).Size(); if (sourceTranslationLength > UnrealMath.KindaSmallNumber) { - var targetTranslationLength = sequence.RetargetBasePose?[trackedBoneIndex].Translation.Size() ?? anim.BonePositions[trackedBoneIndex].Translation.Size(); + var targetTranslationLength = sequence.RetargetBasePose?[trackedBoneIndex].Translation.Size() ?? anim.Skeleton.ReferenceSkeleton.FinalRefBonePose[trackedBoneIndex].Translation.Size(); bonePosition.Scale(targetTranslationLength / sourceTranslationLength); } break; @@ -132,7 +132,7 @@ public class Skeleton : IDisposable { // can't tell if it's working or not var sourceSkelTrans = originalTransform.Position / Constants.SCALE_DOWN_RATIO; - var refPoseTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.BonePositions[trackedBoneIndex]; + var refPoseTransform = sequence.RetargetBasePose?[trackedBoneIndex] ?? anim.Skeleton.ReferenceSkeleton.FinalRefBonePose[trackedBoneIndex]; boneOrientation = boneOrientation * FQuat.Conjugate(originalTransform.Rotation) * refPoseTransform.Rotation; bonePosition += refPoseTransform.Translation - sourceSkelTrans; @@ -143,7 +143,7 @@ public class Skeleton : IDisposable case EBoneTranslationRetargetingMode.OrientAndScale when !rotationOnly: { var sourceSkelTrans = originalTransform.Position / Constants.SCALE_DOWN_RATIO; - var targetSkelTrans = sequence.RetargetBasePose?[trackedBoneIndex].Translation ?? anim.BonePositions[trackedBoneIndex].Translation; + var targetSkelTrans = sequence.RetargetBasePose?[trackedBoneIndex].Translation ?? anim.Skeleton.ReferenceSkeleton.FinalRefBonePose[trackedBoneIndex].Translation; if (!sourceSkelTrans.Equals(targetSkelTrans)) { @@ -168,7 +168,7 @@ public class Skeleton : IDisposable Relation = boneIndices.IsParentTracked ? _animatedBonesTransform[s][boneIndices.TrackedParentBoneIndex][frame].Matrix : originalTransform.Relation, Rotation = boneOrientation, Position = rotationOnly ? originalTransform.Position : bonePosition * Constants.SCALE_DOWN_RATIO, - Scale = sequence.bAdditive ? FVector.OneVector : boneScale + Scale = boneScale }; } } @@ -181,9 +181,9 @@ public class Skeleton : IDisposable ResetAnimatedData(); // tracked bones - for (int trackIndex = 0; trackIndex < anim.TrackBonesInfo.Length; trackIndex++) + for (int trackIndex = 0; trackIndex < anim.Skeleton.BoneCount; trackIndex++) { - var info = anim.TrackBonesInfo[trackIndex]; + var info = anim.Skeleton.ReferenceSkeleton.FinalRefBoneInfo[trackIndex]; if (!BonesIndicesByLoweredName.TryGetValue(info.Name.Text.ToLower(), out var boneIndices)) continue; @@ -193,7 +193,7 @@ public class Skeleton : IDisposable do { if (parentTrackIndex < 0) break; - info = anim.TrackBonesInfo[parentTrackIndex]; + info = anim.Skeleton.ReferenceSkeleton.FinalRefBoneInfo[parentTrackIndex]; if (boneIndices.LoweredParentBoneName.Equals(info.Name.Text, StringComparison.OrdinalIgnoreCase) && // same parent (name based) BonesIndicesByLoweredName.TryGetValue(info.Name.Text.ToLower(), out var parentBoneIndices) && parentBoneIndices.IsTracked) boneIndices.TrackedParentBoneIndex = parentBoneIndices.BoneIndex; diff --git a/FModel/Views/Snooper/Renderer.cs b/FModel/Views/Snooper/Renderer.cs index d6319af2..4a401e7f 100644 --- a/FModel/Views/Snooper/Renderer.cs +++ b/FModel/Views/Snooper/Renderer.cs @@ -1,11 +1,9 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Threading; using System.Windows; using CUE4Parse_Conversion.Animations; -using CUE4Parse_Conversion.Animations.PSA; using CUE4Parse_Conversion.Meshes; using CUE4Parse.UE4.Assets.Exports; using CUE4Parse.UE4.Assets.Exports.Animation; @@ -111,7 +109,7 @@ public class Renderer : IDisposable float maxElapsedTime; switch (anim) { - case UAnimSequence animSequence when !animSequence.IsValidAdditive() && animSequence.Skeleton.TryLoad(out USkeleton skeleton): + case UAnimSequence animSequence when animSequence.Skeleton.TryLoad(out USkeleton skeleton): { var animSet = skeleton.ConvertAnims(animSequence); var animation = new Animation(animSequence, animSet, guid); @@ -120,56 +118,6 @@ public class Renderer : IDisposable Options.AddAnimation(animation); break; } - case UAnimSequence additiveAnimSequence when additiveAnimSequence.IsValidAdditive() && additiveAnimSequence.Skeleton.TryLoad(out USkeleton additiveSkeleton): - { - var reference = additiveAnimSequence.RefPoseSeq?.Load(); - var referenceSkeleton = reference?.Skeleton.Load() ?? additiveSkeleton; - - var additiveAnimSet = additiveSkeleton.ConvertAnims(additiveAnimSequence); - var referenceAnimSet = referenceSkeleton.ConvertAnims(reference); - - FCompactPose[] additivePoses = FAnimationRuntime.LoadAsPoses(additiveAnimSet); - FCompactPose[] referencePoses = additiveAnimSequence.RefPoseType switch - { - EAdditiveBasePoseType.ABPT_RefPose => FAnimationRuntime.LoadRestAsPoses(additiveAnimSet), - // EAdditiveBasePoseType.ABPT_AnimScaled => FAnimationRuntime.LoadAsPoses(referenceAnimSet), - EAdditiveBasePoseType.ABPT_AnimFrame => FAnimationRuntime.LoadAsPoses(referenceAnimSet, additiveAnimSequence.RefFrameIndex), - EAdditiveBasePoseType.ABPT_LocalAnimFrame => FAnimationRuntime.LoadAsPoses(additiveAnimSet, additiveAnimSequence.RefFrameIndex), - _ => throw new NotImplementedException() - }; - - var animSeq = additiveAnimSet.Sequences[0]; - if (reference != null) animSeq.OriginalSequence = referenceAnimSet.Sequences[0].OriginalSequence; - animSeq.Tracks = new List(additivePoses[0].Bones.Length); - for (int i = 0; i < additivePoses[0].Bones.Length; i++) - { - animSeq.Tracks.Add(new CAnimTrack(additivePoses.Length)); - } - - //loop trough each Pose/Frame and add the output to the empty tracks - for (var frameIndex = 0; frameIndex < additivePoses.Length; frameIndex++) - { - var addPose = additivePoses[frameIndex]; - var refPose = (FCompactPose)referencePoses[additiveAnimSequence.RefFrameIndex].Clone(); - switch (additiveAnimSequence.AdditiveAnimType) - { - case EAdditiveAnimationType.AAT_LocalSpaceBase: - FAnimationRuntime.AccumulateLocalSpaceAdditivePoseInternal(refPose, addPose, 1); - break; - case EAdditiveAnimationType.AAT_RotationOffsetMeshSpace: - FAnimationRuntime.AccumulateMeshSpaceRotationAdditiveToLocalPoseInternal(refPose, addPose, 1); - break; - } - - refPose.AddToTracks(animSeq.Tracks, frameIndex); - } - - var animation = new Animation(additiveAnimSequence, additiveAnimSet, guid); - maxElapsedTime = animation.TotalElapsedTime; - model.Skeleton.Animate(additiveAnimSet, AnimateWithRotationOnly); - Options.AddAnimation(animation); - break; - } case UAnimMontage animMontage when animMontage.Skeleton.TryLoad(out USkeleton skeleton): { var animSet = skeleton.ConvertAnims(animMontage);