def unregister(): operators.unregister() preference.unregister() panel.unregister() core.unregister() get_logger().info("BlendMotion is successfully unregistered")
def make_bones_recursive(o, amt, with_handle=True): """ o: Object amt: Armature with_handle: bool """ get_logger().debug('make_bone_recursive: {}'.format(o.name)) link_name = o.name parent_bone = make_bone(o, amt) armature_children = [ child for child in o.children if child.type == 'ARMATURE' ] mesh_children = [child for child in o.children if child.type == 'MESH'] # rename visual meshes to the real link name for mesh in mesh_children: if mesh.phobostype == 'visual': rename_object(mesh, link_name) if len(armature_children) == 1: # Single bone child_bone = make_bones_recursive(armature_children[0], amt, with_handle) attach_bones(parent_bone, child_bone) for child in mesh_children: attach_mesh_bone(child, amt, child_bone) elif len(armature_children) == 0: # The tip child_bone = make_tip(parent_bone, o['joint/name'], amt) attach_bones(parent_bone, child_bone) for child in mesh_children: attach_mesh_bone(child, amt, child_bone) # Mark a tip bone to use them later child_bone['blendmotion_joint'] = o.name # Make a handle bone to use with IK if with_handle: handle_bone = make_handle(child_bone, amt) child_bone['blendmotion_tip'] = handle_bone.name else: child_bone['blendmotion_tip'] = True else: # Where bones are branching off for child in armature_children: child_bone = make_bones_recursive(child, amt, with_handle) attach_bones(parent_bone, child_bone) for child in mesh_children: attach_mesh_bone(child, amt, parent_bone) return parent_bone
def make_tip(bone, name, amt): """ bone: EditBone name: str amt: Armature """ get_logger().debug('make_tip: {}'.format(name)) # make a bone which has the same shape with parent bone b = amt.data.edit_bones.new(name) b.head = bone.tail b.tail = b.head + bone.vector return b
def make_bone(o, amt): """ o: Object amt: Armature """ is_parent_joint = o.parent is not None and 'joint/name' in o.parent joint_name = o.parent['joint/name'] if is_parent_joint else 'root' get_logger().debug('make_bone: {}'.format(joint_name)) b = amt.data.edit_bones.new(joint_name) if o.parent is not None: b.head = calc_pos(o.parent) b.tail = calc_pos(o) if is_parent_joint: b['blendmotion_joint'] = o.parent.name return b
def error_and_log(opr, message): get_logger().error(message) opr.report({'ERROR'}, message) return {'CANCELLED'}
def log(self): get_logger().error(self)