diff --git a/CUE4Parse-Conversion/Animations/AnimExporter.cs b/CUE4Parse-Conversion/Animations/AnimExporter.cs index 593b4aba8..b2c345f59 100644 --- a/CUE4Parse-Conversion/Animations/AnimExporter.cs +++ b/CUE4Parse-Conversion/Animations/AnimExporter.cs @@ -130,7 +130,7 @@ private void DoExportPsa(CAnimSet anim, int seqIdx) framesCount += sequence.NumFrames; } - var requireConfig = false; + var requireConfig = false; // TODO int keysCount = framesCount * numBones; keyHdr.DataCount = keysCount; @@ -174,9 +174,37 @@ private void DoExportPsa(CAnimSet anim, int seqIdx) // importer will always read "SCALEKEYS" chunk. if (Constants.PSA_VERSION >= 20090127) { - scaleKeysHdr.DataCount = 0; - scaleKeysHdr.DataSize = 16; // sizeof(VScaleAnimKey) = FVector + float + keysCount = framesCount * numBones; + scaleKeysHdr.DataCount = keysCount; + scaleKeysHdr.DataSize = Constants.VScaleAnimKey_SIZE; Ar.SerializeChunkHeader(scaleKeysHdr, "SCALEKEYS"); + for (i = 0; i < numAnims; i++) + { + var sequence = anim.Sequences[i]; + for (int frame = 0; frame < sequence.NumFrames; frame++) + { + for (int boneIndex = 0; boneIndex < numBones; boneIndex++) + { + var boneScale = FVector.OneVector; + + if (frame < sequence.Tracks[boneIndex].KeyScale.Length) + boneScale = sequence.Tracks[boneIndex].KeyScale[frame]; + + var key = new VScaleAnimKey + { + ScaleVector = boneScale, + Time = 1 + }; + key.Serialize(Ar); + keysCount--; + + // check for user error + if (sequence.Tracks[boneIndex].KeyScale.Length == 0) + requireConfig = true; + } + } + } + Trace.Assert(keysCount == 0); } // psa file is done diff --git a/CUE4Parse-Conversion/Animations/PSA/VScaleAnimKey.cs b/CUE4Parse-Conversion/Animations/PSA/VScaleAnimKey.cs new file mode 100644 index 000000000..0543334ab --- /dev/null +++ b/CUE4Parse-Conversion/Animations/PSA/VScaleAnimKey.cs @@ -0,0 +1,17 @@ +using CUE4Parse.UE4.Objects.Core.Math; +using CUE4Parse.UE4.Writers; + +namespace CUE4Parse_Conversion.Animations.PSA +{ + public class VScaleAnimKey + { + public FVector ScaleVector; + public float Time; + + public void Serialize(FArchiveWriter Ar) + { + ScaleVector.Serialize(Ar); + Ar.Write(Time); + } + } +} diff --git a/CUE4Parse-Conversion/Constants.cs b/CUE4Parse-Conversion/Constants.cs index 824573d89..43777185f 100644 --- a/CUE4Parse-Conversion/Constants.cs +++ b/CUE4Parse-Conversion/Constants.cs @@ -16,6 +16,7 @@ public class Constants public const int VJointPosPsk_SIZE = 4 * 4 + 3 * 4 + 4 + 3 * 4; public const int FNamedBoneBinary_SIZE = 64 + 3 * 4 + VJointPosPsk_SIZE; public const int VQuatAnimKey_SIZE = 3 * 4 + 4 * 4 + 4; + public const int VScaleAnimKey_SIZE = 3 * 4 + 4; public const int DXT_BITS_PER_PIXEL = 4;