mirror of
https://github.com/4sval/FModel.git
synced 2026-09-25 18:48:50 -05:00
additive
This commit is contained in:
Submodule CUE4Parse updated: 55d34868df...c60c31e8bf
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<UAnimSequence>();
|
||||
var referenceSkeleton = reference?.Skeleton.Load<USkeleton>() ?? 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<CAnimTrack>(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);
|
||||
|
||||
Reference in New Issue
Block a user