2023-08-18 20:11:04 +08:00
|
|
|
|
---
|
|
|
|
|
title: UE5动画重定向笔记
|
|
|
|
|
date: 2023-08-18 18:08:12
|
|
|
|
|
excerpt:
|
|
|
|
|
tags:
|
|
|
|
|
rating: ⭐
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# ConvertAnimation()
|
2023-08-21 10:12:05 +08:00
|
|
|
|
主要逻辑位于`UAnimationEditorUtilityLibrary::ConvertAnimation()`或者`FIKRetargetBatchOperation::ConvertAnimation()`。核心重定向逻辑为`UIKRetargetProcessor::RunRetargeter()`。
|
2023-08-18 20:11:04 +08:00
|
|
|
|
|
2023-08-21 10:12:05 +08:00
|
|
|
|
## RunRootRetarget()
|
|
|
|
|
FRootRetargeter::EncodePose():
|
|
|
|
|
取得输入的根骨骼Transform数据并给`FRootSource Source`赋值。
|
2023-08-18 20:11:04 +08:00
|
|
|
|
|
2023-08-21 10:12:05 +08:00
|
|
|
|
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()
|
2023-08-18 20:11:04 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# UIKRetargetProcessor
|