BlueRoseNote/03-UnrealEngine/Animation/UE5动画重定向笔记.md

3.7 KiB
Raw Blame History

title, date, excerpt, tags, rating
title date excerpt tags rating
UE5动画重定向笔记 2023-08-18 18:08:12

ConvertAnimation()

主要逻辑位于UAnimationEditorUtilityLibrary::ConvertAnimation()或者FIKRetargetBatchOperation::ConvertAnimation()。核心重定向逻辑为UIKRetargetProcessor::RunRetargeter()

RunRootRetarget()

FRootRetargeter::EncodePose(): 取得输入的根骨骼Transform数据并给FRootSource Source赋值。

FRootRetargeter::DecodePose():

// 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

使用之前建议仔细查看文档。FBX Sdk有三种库分别为动态链接库(dll + lib)、静态链接库(/MD)、静态链接库(/MT)。

  • 动态链接库使用Qt的导入库功能导入动态库之后只需要再添加一行DEFINES += FBXSDK_SHARED即可。例如:
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

win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../LIBRARYNAME/Lib/ -lLIBRARY /NODEFAULTLIB:library

FBX结构

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

动画