美文网首页
UE4_Bip-RootMotion制作方案分享

UE4_Bip-RootMotion制作方案分享

作者: TAZORN | 来源:发表于2018-02-22 22:10 被阅读0次
    • 关于RootMotion
    • 简单说RootMotion就是使用动画位移来驱动角色胶囊体位移的技术
      • Unity3d 4.0以上版本,自带的MecAnim功能,能够自动计算RootMotion,甚至可以直接导入动扑数据,然后可以在UnityEditor中调整成为最终可用的动画数据
      • UE4也有根位移的做法,但是没有像Unity那么方便的工具,官文只说明了基本的RootMotion应用,没有涉及具体制作,以及使用Biped骨骼要如何制作的方法
        https://docs.unrealengine.com/latest/INT/Engine/Animation/RootMotion/index.html

    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的位移

    • 创建一个虚拟物体(或其他的任何节点),不需要任何层级结构,单独放在场景中就行,主要用于手动制作Root动画,我这里命名这个虚拟物体为RootLeader
    • 手动K制作RootLeader位移的目的在于,能够自主的控制根位移节奏,可以做很多自由的根位移动画
    制作了RootLeader的动画

    Step3,烘焙Root动画

    • 将手动K的RootLeader位移烘焙到Root上,并且保持原有Biped的动画不变
    • 我这里使用的方法其实很简单,分成3次遍历
      • 3.1 遍历所有帧,记录bip01 (Biped的根物体) 的位移以及旋转信息
      • 3.2 遍历所有帧,将Root位移匹配到RootLeader,记录Root动画帧
      • 3.3 创建一个BipedLayer层,遍历所有帧,使用上面记录的数据将其还原bip01的位置与旋转

    烘焙的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效果
    • 如有其它的好办法或想法,欢迎一起来讨论

    相关文章

      网友评论

          本文标题:UE4_Bip-RootMotion制作方案分享

          本文链接:https://www.haomeiwen.com/subject/sfdatftx.html