From 79f6187d8aba1b91f7c5a55977a5658e4c38aee6 Mon Sep 17 00:00:00 2001 From: BlueRose <378100977@qq.com> Date: Tue, 7 Nov 2023 11:33:46 +0800 Subject: [PATCH] vault backup: 2023-11-07 11:33:46 --- .../Animation/UE5动画重定向核心逻辑笔记.md | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md b/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md index ae02ac4..ce31050 100644 --- a/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md +++ b/03-UnrealEngine/Animation/UE5动画重定向核心逻辑笔记.md @@ -38,10 +38,10 @@ rating: ⭐ 重定向数据会直接修改TargetSkeleton的Pose数据。Root与FK重定向执行完之后会调用UpdateGlobalTransformsBelowBone()更新后续骨骼的WorldSpace Transform。 ## RunRootRetarget() -FRootRetargeter::EncodePose(): +FRootRetargeter::EncodePose(): 取得输入的根骨骼Transform数据并给`FRootSource Source`赋值。 -FRootRetargeter::DecodePose(): +FRootRetargeter::DecodePose(): ```c++ FVector Position; { @@ -67,30 +67,36 @@ FVector Position; FQuat Rotation; { - // calc offset between initial source/target root rotations + // 计算Source的旋转偏差值 const FQuat RotationDelta = Source.CurrentRotation * Source.InitialRotation.Inverse(); - // add retarget pose delta to the current source rotation + // 将偏移加到Target上 const FQuat RetargetedRotation = RotationDelta * Target.InitialRotation; - // add static rotation offset + // 将RetargetSetting上的旋转偏差值加上。 Rotation = RetargetedRotation * Settings.RotationOffset.Quaternion(); - // blend with alpha Rotation = FQuat::FastLerp(Target.InitialRotation, Rotation, Settings.RotationAlpha); Rotation.Normalize(); - // record the delta created by all the modifications made to the root rotation + // 记录Target的旋转偏差值 Target.RootRotationDelta = RetargetedRotation * Target.InitialRotation.Inverse(); } -// apply to target +// 将数据应用到根骨骼上 FTransform& TargetRootTransform = OutTargetGlobalPose[Target.BoneIndex]; TargetRootTransform.SetTranslation(Position); TargetRootTransform.SetRotation(Rotation); ``` ## RunFKRetarget() -FChainEncoderFK::EncodePose(): -从骨骼链拷贝全局输入到CurrentGlobalTransforms +遍历所有骨骼链,并执行FChainEncoderFK::EncodePose()与FChainDecoderFK::DecodePose()。 -FChainDecoderFK::DecodePose(): +FChainEncoderFK::EncodePose(): +1. 遍历所有骨骼链,根据骨骼链Index得到BoneIndex,之后将对应骨骼的WorldSpace Transform赋予到对应骨骼链Index的CurrentGlobalTransforms中。 +2. Resize CurrentLocalTransforms,其长度与SourceBoneIndices相同。 +3. FillTransformsWithLocalSpaceOfChain() + 1. 遍历所有骨骼链,取得对应骨骼的Index以及父骨骼Index。(跳过根骨骼) + 2. 计算相对Transform后放入对应ChainIndex的OutLocalTransforms中。 +4. 根据ChainParentBoneIndex,将父骨骼Transform赋予给ChainParentCurrentGlobalTransform。 + +FChainDecoderFK::DecodePose():