From 2c3ed322226d8e017e427cff4e45efd3272f4426 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Wed, 9 Oct 2024 19:11:03 +0800 Subject: [PATCH] vault backup: 2024-10-09 19:11:03 --- .../导出PSK_PSA脚本 & 部分UModel AES Key.md | 111 +++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/06-DCC/Blender/导出PSK_PSA脚本 & 部分UModel AES Key.md b/06-DCC/Blender/导出PSK_PSA脚本 & 部分UModel AES Key.md index df044a3..5fcfe3c 100644 --- a/06-DCC/Blender/导出PSK_PSA脚本 & 部分UModel AES Key.md +++ b/06-DCC/Blender/导出PSK_PSA脚本 & 部分UModel AES Key.md @@ -629,7 +629,14 @@ else ``` ### ExportAnimation -***核心逻辑*** +***核心逻辑***: +BtnExport遍历AdditiveAnim,并调用CalculateAddRotation。 +追要参数为: +- XMap +- YMap +- ZMap +- AixMap +- boneNum(是否包含pelvis骨骼) ```c++ on BtnExport pressed do ( @@ -651,4 +658,106 @@ on BtnExport pressed do ) ) ) +``` + +CalculateAddRotation: +```c++ +fn CalculateAddRotation index = +( + //导入AdditiveAnim + importFile Anims[index].Address #noPrompt using:Wavefront_Object + local bones = FindAllBones() + BoneRotationArray = #() + + //遍历骨骼,从第二根骨骼,也就是Pelvis开始。(仅仅针对UE骨骼,Bip得重新考虑) + for j=1 to bones.count do + ( + if j>boneNum then + ( + //计算当前骨骼相对父骨骼的相对旋转。 + local Value_X = ((at time 0 bones[j].rotInParent).x - (at time 0 bones[j].parent.rotInParent).x) + local Value_Y = ((at time 0 bones[j].rotInParent).y - (at time 0 bones[j].parent.rotInParent).y) + local Value_Z = ((at time 0 bones[j].rotInParent).z - (at time 0 bones[j].parent.rotInParent).z) + //针对XYZ抖动情况的不同传入不同的形参并调用BoneRotationArray。 + if (abs Value_X) > 0.05 then + ( + if (abs Value_Y) > 0.05 then + ( + if (abs Value_Z) > 0.05 then + ( + append BoneRotationArray (SaveValue j bones[j].name Value_X Value_Y Value_Z) + ) + else + ( + append BoneRotationArray (SaveValue j bones[j].name Value_X Value_Y 0) + ) + ) + else + ( + if (abs Value_Z) > 0.05 then + ( + append BoneRotationArray (SaveValue j bones[j].name Value_X 0 Value_Z) + ) + else + ( + append BoneRotationArray (SaveValue j bones[j].name Value_X 0 0) + ) + ) + ) + else + ( + if (abs Value_Y) > 0.05 then + ( + if (abs Value_Z) > 0.05 then + ( + append BoneRotationArray (SaveValue j bones[j].name 0 Value_Y Value_Z) + ) + else + ( + append BoneRotationArray (SaveValue j bones[j].name 0 Value_Y 0) + ) + ) + else + ( + if (abs Value_Z) > 0.05 then + ( + append BoneRotationArray (SaveValue j bones[j].name 0 0 Value_Z) + ) + ) + ) + ) + ) + --Set Base Animation Rotation + //导入BaseAnim + if DoesFileExist BaseAnimFileName then + ( + importFile BaseAnimFileName #noPrompt using:Wavefront_Object + local BaseAnimBones = FindAllBones() + scale BaseAnimBones[1] [(50.0/127.0),(50.0/127.0),(50.0/127.0)] + //调用RotationBone()来设置新的旋转数值 + case AixMap of + ( + 1:( RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones + RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones + RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones) + 2:( RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones + RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones + RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones) + 3:( RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones + RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones + RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones) + 4:( RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones + RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones + RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones) + 5:( RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones + RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones + RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones) + 6:( RotationBone 0 0 1 BoneRotationArray ZMap BaseAnimBones + RotationBone 0 1 0 BoneRotationArray YMap BaseAnimBones + RotationBone 1 0 0 BoneRotationArray XMap BaseAnimBones) + ) + + ExportAnim Anims[index].Address + ) +) ``` \ No newline at end of file