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
|
2023-08-21 11:56:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-22 13:25:39 +08:00
|
|
|
|
# FBX SDK setup for Qt
|
2023-08-22 12:09:58 +08:00
|
|
|
|
https://help.autodesk.com/view/FBX/2020/ENU/?guid=FBX_Developer_Help_welcome_to_the_fbx_sdk_html
|
|
|
|
|
|
|
|
|
|
使用之前建议**仔细查看文档**。FBX Sdk有三种库,分别为动态链接库(dll + lib)、静态链接库(/MD)、静态链接库(/MT)。
|
|
|
|
|
|
|
|
|
|
- 动态链接库:使用Qt的导入库功能,导入动态库之后,只需要再添加一行`DEFINES += FBXSDK_SHARED`即可。例如:
|
|
|
|
|
```qmake
|
|
|
|
|
QT += core gui
|
|
|
|
|
|
|
|
|
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
|
|
|
|
|
|
|
|
CONFIG += c++17
|
|
|
|
|
DEFINES += FBXSDK_SHARED
|
|
|
|
|
# You can make your code fail to compile if it uses deprecated APIs.
|
|
|
|
|
# In order to do so, uncomment the following line.
|
|
|
|
|
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
|
|
|
|
|
|
|
|
|
SOURCES += \
|
|
|
|
|
Common/Common.cpp \
|
|
|
|
|
main.cpp \
|
|
|
|
|
mainwindow.cpp
|
|
|
|
|
|
|
|
|
|
HEADERS += \
|
|
|
|
|
Common/Common.h \
|
|
|
|
|
mainwindow.h
|
|
|
|
|
|
|
|
|
|
FORMS += \
|
|
|
|
|
mainwindow.ui
|
|
|
|
|
|
|
|
|
|
# Default rules for deployment.
|
|
|
|
|
qnx: target.path = /tmp/$${TARGET}/bin
|
|
|
|
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
|
|
|
|
!isEmpty(target.path): INSTALLS += target
|
|
|
|
|
|
|
|
|
|
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/FBXSdk/lib/vs2022/x64/release/ -llibfbxsdk
|
|
|
|
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/FBXSdk/lib/vs2022/x64/debug/ -llibfbxsdk
|
|
|
|
|
|
|
|
|
|
INCLUDEPATH += $$PWD/FBXSdk/lib/vs2022/x64/debug
|
|
|
|
|
DEPENDPATH += $$PWD/FBXSdk/lib/vs2022/x64/debug
|
|
|
|
|
|
|
|
|
|
INCLUDEPATH += $$PWD/FBXSdk/include
|
|
|
|
|
```
|
|
|
|
|
- 静态链接库(/MD):使用Qt的导入库功能,导入静态库之后,
|
|
|
|
|
- 静态链接库(/MT):使用Qt的导入库功能,导入静态库之后,
|
|
|
|
|
|
|
|
|
|
## Qt相关设置添加
|
|
|
|
|
https://blog.csdn.net/libaineu2004/article/details/105718847
|
|
|
|
|
Qt在pro中设置运行时库MT、MTd、MD、MDd,重点关注QMAKE_CFLAGS
|
|
|
|
|
|
|
|
|
|
多线程调试Dll (/MDd) 对应的是MD_DynamicDebug
|
|
|
|
|
多线程Dll (/MD) 对应的是MD_DynamicRelease
|
|
|
|
|
多线程(/MT) 对应的是MD_StaticRelease
|
|
|
|
|
多线程(/MTd)对应的是MD_StaticDebug
|
|
|
|
|
|
|
|
|
|
## /NODEFAULTLIB:library
|
|
|
|
|
```cpp
|
|
|
|
|
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../LIBRARYNAME/Lib/ -lLIBRARY /NODEFAULTLIB:library
|
2023-08-22 13:25:39 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# FBX结构
|
|
|
|
|

|
|
|
|
|
FBX SDK场景图是通过`FbxScene`类抽象出来的。场景被组织为节点层次结构 ( `FbxNode`)。场景的根节点通过 访问`FbxScene::GetRootNode()`。场景元素(例如网格、灯光或相机)是通过将`FbxNode`与 的子类组合来定义的`FbxNodeAttribute`。
|
|
|
|
|
|
|
|
|
|
## 动画
|