motionbuilder 使用总结

脚本篇

安装额外的python库需要 mobupy.exe -m pip install
执行脚本的窗口在window->Python Editor

常用的记录整理

正规化动捕数据

def normalize_trans_rots(trans,rots,refid=0):
    r = sciR.from_euler("xyz", rots, degrees=True).as_matrix()
    r1 = r[refid]

    b1 = r1[0]
    b2 = np.array([0,1,0])

    b1 = b1 - (b1*b2).sum(-1) * b2
    b1 = b1 / np.linalg.norm(b1)
    b3 = np.cross(b1, b2)

    rref = np.vstack((b1, b2, b3)).T # inv
    
    r = np.einsum('cd,bda->bca', rref, r)
    trans = np.einsum('cd,bd->bc', rref, trans)
    rots = sciR.from_matrix(r).as_euler("xyz", degrees=True)
    
    basetrans = trans[refid:refid+1].copy()
    #print(  basetrans, trans[:5] )
    basetrans[:, 1] = 0
    trans = trans - basetrans
    #print(  basetrans, trans[:5] )
    print( r[refid] )
    return trans,rots

你可能感兴趣的:(3D软件脚本操作,python,motionbuilder)