BlenderでBoneの姿勢計算が合わないときの金の針


はじめに

Blenderでbpy.struct.PoseBonematrix(ref.)に頼らずにTranslation matrixを計算していたら、全然数値が合わないので泣いた。

解決策

ググったら以下のようなツイートを見つけた。

このツイートをもとに以下のようなスクリプトを書いた。

def normalize_armature(armature: bpy.types.Object):
    bpy.context.view_layer.objects.active = armature
    bpy.ops.object.mode_set(mode='EDIT', toggle=False)
    for bone in armature.data.edit_bones:
        bone.roll = 0.0
    bpy.ops.object.mode_set(mode='OBJECT', toggle=False)

これをBlender用numpy utility libraryに組み込み、Linear Blend Skinningを適用したら頂点位置が合った。

緑色の物体はBlender上でArmature(Skeleton)を加えてテキトーにBone Animationを加えたもの。
白いキューブは自作LBSで出した頂点位置を表している。

何とか計算合った...Roll許すまじ....