Пример #1
0
def loadBvhFile(context, filepath):
    ob = context.object
    rig = ob.parent
    scn = context.scene
    if rig and rig.type == 'ARMATURE':
        (pname, ext) = os.path.splitext(filepath)
        bvhpath = pname + ".bvh"

        bvh_nodes = import_bvh.read_bvh(context,
                                        bvhpath,
                                        rotate_mode=scn.MhImportRotateMode,
                                        global_scale=1.0)

        frame_orig = context.scene.frame_current

        bvh_name = bpy.path.display_name_from_filepath(bvhpath)

        import_bvh.bvh_node_dict2armature(
            context,
            bvh_name,
            bvh_nodes,
            rotate_mode=scn.MhImportRotateMode,
            frame_start=scn.frame_current,
            IMPORT_LOOP=False,
            global_matrix=rig.matrix_world,
        )
        context.scene.frame_set(frame_orig)

        tmp = context.object
        bpy.ops.object.mode_set(mode='POSE')
        scn.objects.active = rig
        bpy.ops.object.mode_set(mode='POSE')
        copyPose(tmp, rig)
        scn.objects.active = ob
        scn.objects.unlink(tmp)
        del tmp
        print("Loaded %s" % bvhpath)
        return True
    else:
        return False
Пример #2
0
def loadBvhFile(context, filepath):
    ob = context.object
    rig = ob.parent
    scn = context.scene
    if rig and rig.type == "ARMATURE":
        (pname, ext) = os.path.splitext(filepath)
        bvhpath = pname + ".bvh"

        bvh_nodes = import_bvh.read_bvh(context, bvhpath, rotate_mode=scn.MhImportRotateMode, global_scale=1.0)

        frame_orig = context.scene.frame_current

        bvh_name = bpy.path.display_name_from_filepath(bvhpath)

        import_bvh.bvh_node_dict2armature(
            context,
            bvh_name,
            bvh_nodes,
            rotate_mode=scn.MhImportRotateMode,
            frame_start=scn.frame_current,
            IMPORT_LOOP=False,
            global_matrix=rig.matrix_world,
        )
        context.scene.frame_set(frame_orig)

        tmp = context.object
        bpy.ops.object.mode_set(mode="POSE")
        scn.objects.active = rig
        bpy.ops.object.mode_set(mode="POSE")
        copyPose(tmp, rig)
        scn.objects.active = ob
        scn.objects.unlink(tmp)
        del tmp
        print("Loaded %s" % bvhpath)
        return True
    else:
        return False