From 5537b0af2ed5c13921c3030511e762ab7d74a448 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Mon, 6 Nov 2023 14:49:18 +0800 Subject: [PATCH] vault backup: 2023-11-06 14:49:18 --- .../FBX相关笔记.md} | 106 +----------------- .../Animation/UE5动画重定向核心逻辑笔记.md | 45 ++++++++ .../Animation/UE5商城动画重定向插件笔记.md | 4 +- 3 files changed, 51 insertions(+), 104 deletions(-) rename 03-UnrealEngine/Animation/{UE5动画重定向 & FBX文件格式.md => FBX相关笔记/FBX相关笔记.md} (55%) create mode 100644 03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md diff --git a/03-UnrealEngine/Animation/UE5动画重定向 & FBX文件格式.md b/03-UnrealEngine/Animation/FBX相关笔记/FBX相关笔记.md similarity index 55% rename from 03-UnrealEngine/Animation/UE5动画重定向 & FBX文件格式.md rename to 03-UnrealEngine/Animation/FBX相关笔记/FBX相关笔记.md index 1494199..8dcac43 100644 --- a/03-UnrealEngine/Animation/UE5动画重定向 & FBX文件格式.md +++ b/03-UnrealEngine/Animation/FBX相关笔记/FBX相关笔记.md @@ -1,44 +1,10 @@ --- -title: UE5动画重定向笔记 -date: 2023-08-18 18:08:12 +title: FBX相关笔记 +date: 2023-11-06 11:45:14 excerpt: tags: rating: ⭐ --- - -# ConvertAnimation() -主要逻辑位于`UAnimationEditorUtilityLibrary::ConvertAnimation()`或者`FIKRetargetBatchOperation::ConvertAnimation()`。核心重定向逻辑为`UIKRetargetProcessor::RunRetargeter()`。 - -## RunRootRetarget() -FRootRetargeter::EncodePose(): -取得输入的根骨骼Transform数据并给`FRootSource Source`赋值。 - -FRootRetargeter::DecodePose(): -```c++ -// InitialTransform 为重定向Pose计算出的数值,通过比值计算出Target的Current数值 -const FTransform InitialTransform = SourceSkeleton.RetargetGlobalPose[Source.BoneIndex]; -float InitialHeight = InitialTransform.GetTranslation().Z; -Source.InitialHeightInverse = 1.0f / InitialHeight; -Source.CurrentPositionNormalized = Source.CurrentPosition * Source.InitialHeightInverse; - -// generate basic retarget root position by scaling the normalized position by root height -const FVector RetargetedPosition = Source.CurrentPositionNormalized * Target.InitialHeight; -``` -## RunFKRetarget() -FChainEncoderFK::EncodePose(): -从骨骼链拷贝全局输入到CurrentGlobalTransforms - -FChainDecoderFK::DecodePose(): - -## RunIKRetarget() - -## RunPoleVectorMatching() - - -# UIKRetargetProcessor - - - # FBX SDK setup for Qt https://help.autodesk.com/view/FBX/2020/ENU/?guid=FBX_Developer_Help_welcome_to_the_fbx_sdk_html @@ -146,73 +112,7 @@ FBX SDK场景图是通过`FbxScene`类抽象出来的。场景被组织为节点 每个动画数据都存在对应的节点的属性中(Maya中可以给Shape的属性K帧),可以通过类似`lAnimCurve = pNode->LclTranslation.GetCurve(pAnimLayer, FBXSDK_CURVENODE_COMPONENT_Y);`的方式取得动画曲线。 UE导出的FBX相关属性为: -```json - AnimationStack: 1767515526080, "AnimStack::Unreal Take", "" { - Properties70: { - P: "Description", "KString", "", "", "Animation Take for Unreal." - P: "LocalStop", "KTime", "Time", "",183205094709 - } - } - - AnimationLayer: 1770224712128, "AnimLayer::Base Layer", "" { - } - - NodeAttribute: 1767517959504, "NodeAttribute::Root", "Root" { - TypeFlags: "Null", "Skeleton", "Root" - } - NodeAttribute: 1767517960848, "NodeAttribute::Pelvis", "LimbNode" { - TypeFlags: "Skeleton" - } - NodeAttribute: 1767517959696, "NodeAttribute::L_Hip", "LimbNode" { - TypeFlags: "Skeleton" - } - NodeAttribute: 1767517960080, "NodeAttribute::L_Knee", "LimbNode" { - TypeFlags: "Skeleton" - } - -AnimationCurve: 1770213770432, "AnimCurve::", "" { - Default: 0 - KeyVer: 4009 - KeyTime: *120 { - a: 0,1539538600,3079077200,4618615800,6158154400,7697693000,9237231600,10776770200,12316308800,13855847400,15395386000,16934924600,18474463200,20014001800,21553540400,23093079000,24632617600,26172156200,27711694800,29251233400,30790772000,32330310600,33869849200,35409387800,36948926400,38488465000,40028003600,41567542200,43107080800,44646619400,46186158000,47725696600,49265235200,50804773800,52344312400,53883851000,55423389600,56962928200,58502466800,60042005400,61581544000,63121082600,64660621200,66200159800,67739698400,69279237000,70818775600,72358314200,73897852800,75437391400,76976930000,78516468600,80056007200,81595545800,83135084400,84674623000,86214161600,87753700200,89293238800,90832777400,92372316000,93911854600,95451393200,96990931800,98530470400,100070009000,101609547600,103149086200,104688624800,106228163400,107767702000,109307240600,110846779200,112386317800,113925856400,115465395000,117004933600,118544472200,120084010800,121623549400,123163088000,124702626600,126242165200,127781703800,129321242400,130860781000,132400319600,133939858200,135479396800,137018935400,138558474000,140098012600,141637551200,143177089800,144716628400,146256167000,147795705600,149335244200,150874782800,152414321400,153953860000,155493398600,157032937200,158572475800,160112014400,161651553000,163191091600,164730630200,166270168800,167809707400,169349246000,170888784600,172428323200,173967861800,175507400400,177046939000,178586477600,180126016200,181665554800,183205093400 - } - KeyValueFloat: *120 { - a: -0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0 - } - ;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent, Constant|ConstantStandard - KeyAttrFlags: *2 { - a: 8456,8194 - } - ;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightSlope:0, NextLeftSlope:0, RightWeight:0.333333, NextLeftWeight:0.333333, RightVelocity:0, NextLeftVelocity:0 - KeyAttrDataFloat: *8 { - a: 0,0,218434821,0,0,0,218434821,0 - } - KeyAttrRefCount: *2 { - a: 119,1 - } - } - AnimationCurve: 1770213768992, "AnimCurve::", "" { - Default: 0 - KeyVer: 4009 - KeyTime: *120 { - a: 0,1539538600,3079077200,4618615800,6158154400,7697693000,9237231600,10776770200,12316308800,13855847400,15395386000,16934924600,18474463200,20014001800,21553540400,23093079000,24632617600,26172156200,27711694800,29251233400,30790772000,32330310600,33869849200,35409387800,36948926400,38488465000,40028003600,41567542200,43107080800,44646619400,46186158000,47725696600,49265235200,50804773800,52344312400,53883851000,55423389600,56962928200,58502466800,60042005400,61581544000,63121082600,64660621200,66200159800,67739698400,69279237000,70818775600,72358314200,73897852800,75437391400,76976930000,78516468600,80056007200,81595545800,83135084400,84674623000,86214161600,87753700200,89293238800,90832777400,92372316000,93911854600,95451393200,96990931800,98530470400,100070009000,101609547600,103149086200,104688624800,106228163400,107767702000,109307240600,110846779200,112386317800,113925856400,115465395000,117004933600,118544472200,120084010800,121623549400,123163088000,124702626600,126242165200,127781703800,129321242400,130860781000,132400319600,133939858200,135479396800,137018935400,138558474000,140098012600,141637551200,143177089800,144716628400,146256167000,147795705600,149335244200,150874782800,152414321400,153953860000,155493398600,157032937200,158572475800,160112014400,161651553000,163191091600,164730630200,166270168800,167809707400,169349246000,170888784600,172428323200,173967861800,175507400400,177046939000,178586477600,180126016200,181665554800,183205093400 - } - KeyValueFloat: *120 { - a: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - } - ;KeyAttrFlags: Cubic|TangeantAuto|GenericTimeIndependent, Constant|ConstantStandard - KeyAttrFlags: *2 { - a: 8456,8194 - } - ;KeyAttrDataFloat: RightAuto:0, NextLeftAuto:0; RightSlope:0, NextLeftSlope:0, RightWeight:0.333333, NextLeftWeight:0.333333, RightVelocity:0, NextLeftVelocity:0 - KeyAttrDataFloat: *8 { - a: 0,0,218434821,0,0,0,218434821,0 - } - KeyAttrRefCount: *2 { - a: 119,1 - } - } -``` + 添加动画关键帧的方式 diff --git a/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md b/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md new file mode 100644 index 0000000..e5279c3 --- /dev/null +++ b/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md @@ -0,0 +1,45 @@ +--- +title: UE5动画重定向核心逻辑笔记 +date: 2023-08-18 18:08:12 +excerpt: +tags: +rating: ⭐ +--- +# 前言 + +# ConvertAnimation() +主要逻辑位于`UAnimationEditorUtilityLibrary::ConvertAnimation()`或者`FIKRetargetBatchOperation::ConvertAnimation()`。核心重定向逻辑为`UIKRetargetProcessor::RunRetargeter()`。 + + +FRetargetSkeleton: + +## RunRootRetarget() +FRootRetargeter::EncodePose(): +取得输入的根骨骼Transform数据并给`FRootSource Source`赋值。 + +FRootRetargeter::DecodePose(): +```c++ +// InitialTransform 为重定向Pose计算出的数值,通过比值计算出Target的Current数值 +const FTransform InitialTransform = SourceSkeleton.RetargetGlobalPose[Source.BoneIndex]; +float InitialHeight = InitialTransform.GetTranslation().Z; +Source.InitialHeightInverse = 1.0f / InitialHeight; +Source.CurrentPositionNormalized = Source.CurrentPosition * Source.InitialHeightInverse; + +// generate basic retarget root position by scaling the normalized position by root height +const FVector RetargetedPosition = Source.CurrentPositionNormalized * Target.InitialHeight; +``` +## RunFKRetarget() +FChainEncoderFK::EncodePose(): +从骨骼链拷贝全局输入到CurrentGlobalTransforms + +FChainDecoderFK::DecodePose(): + +## RunIKRetarget() + +## RunPoleVectorMatching() + + +# UIKRetargetProcessor + + + diff --git a/03-UnrealEngine/Animation/UE5商城动画重定向插件笔记.md b/03-UnrealEngine/Animation/UE5商城动画重定向插件笔记.md index aae9067..237cf0e 100644 --- a/03-UnrealEngine/Animation/UE5商城动画重定向插件笔记.md +++ b/03-UnrealEngine/Animation/UE5商城动画重定向插件笔记.md @@ -197,4 +197,6 @@ static const char* const kUE4MannequinToMixamo_BoneNamesMapping[] = { "thumb_02_r", "RightHandThumb2", "thumb_03_r", "RightHandThumb3", // Un-mapped bones (at the moment). Here for reference. - //"lowerarm_twist_01_l", nullptr, //"upperarm_twist_01_l", nullptr, //"lowerarm_twist_01_r", nullptr, //"upperarm_twist_01_r", nullptr, //"calf_twist_01_l", nullptr, //"thigh_twist_01_l", nullptr, //"calf_twist_01_r", nullptr, //"thigh_twist_01_r", nullptr, //"ik_foot_root", nullptr, //"ik_foot_l", nullptr, //"ik_foot_r", nullptr, //"ik_hand_root", nullptr, //"ik_hand_gun", nullptr, //"ik_hand_l", nullptr, //"ik_hand_r", nullptr,}; \ No newline at end of file + //"lowerarm_twist_01_l", nullptr, //"upperarm_twist_01_l", nullptr, //"lowerarm_twist_01_r", nullptr, //"upperarm_twist_01_r", nullptr, //"calf_twist_01_l", nullptr, //"thigh_twist_01_l", nullptr, //"calf_twist_01_r", nullptr, //"thigh_twist_01_r", nullptr, //"ik_foot_root", nullptr, //"ik_foot_l", nullptr, //"ik_foot_r", nullptr, //"ik_hand_root", nullptr, //"ik_hand_gun", nullptr, //"ik_hand_l", nullptr, //"ik_hand_r", nullptr,}; + +# EasyPose