UE4_Bip-RootMotion制作方案分享

2018-02-22  本文已影响0人  TAZORN

UE4的标准骨骼需要一个Root根节点

+ Root 
  + Bip01
    + Bip01_Pelvis
      + . . . 
  + IK_Foot_Root
  + . . . 

在没有任何辅助的情况下,手动制作带有根位移的动画真是麻烦大了,特别是那种带有回退,旋转,等等的根位移动画,网上关于RootMotion动画制作的相关内容真是少的可怜,有很多关于MotionBuilder,或Maya中通过HumanIK来烘焙的例子,但都不够直接的能够解决在3dsMax下使用Biped做根位移的情况

这里我分享了自己的 Biped-RootMotion方案,分成3个阶段


Step1,Root归0,只制作Biped骨骼动画

Root节点归0,只有Bip动画的阶段

Step2,单独使用辅助物体来模拟Root的位移

制作了RootLeader的动画

Step3,烘焙Root动画

烘焙的Maxscript脚本:

(
    -- 指定基本的物体引用
    local bipObj            = $Root/Bip01
    local rootObj           = $Root
    local rootLeaderObj     = $RootLeader

    -- 每一帧的Pos与Rot
    local bipPosList = #()
    local bipRotList = #()

    -- 第一次遍历,记录原始的bip在世界空间的位置与旋转信息
    for t = (animationRange.start) to (animationRange.end) do
    (
        sliderTime = t
        append bipPosList (in coordsys world Biped.getTransform bipObj #pos)
        append bipRotList (in coordsys world Biped.getTransform bipObj #rotation)
    )

    -- 第二次遍历,动画 Root匹配 RootLeader
    for t = (animationRange.start) to (animationRange.end) do
    (
        sliderTime = t
        with animate on
        (
            rootObj.transform = rootLeaderObj.transform
        )   
    )

    -- 第三次遍历,创建新的Bip层,还原bip的位置以及旋转信息
    biped.createLayer bipObj.controller 1 "RootMotionOffset"
    biped.setcurrentlayer bipObj.controller 1
    for t = (animationRange.start) to (animationRange.end) do
    (
        sliderTime = t
        local f = (t.frame as integer)+1

        -- Pos
        local bipPos = bipPosList[f]
        in coordsys world Biped.setTransform bipObj #pos bipPos true

        -- Rot
        local bipRot = bipRotList[f]
        in coordsys world Biped.setTransform bipObj #rotation bipRot true
    )
)
烘焙的结果

还原到烘焙前的操作

如果需要还原到烘焙前的状态,只需要删除烘焙时创建的Biped动画层,删除Root所有帧并且放回到0点即可


最终在UE4中的效果

导入UE4,启用RootMotion,制作了相关AnimMontage

最终在UE4的RootMotion效果
上一篇 下一篇

猜你喜欢

热点阅读