def mirror_obj(obj_src, obj_dst=None): """ Method to mirror joints in behavior. This use existing joint and doesn't break the skin or the network associated with the joints. """ from omtk.animation import mirrorPose if obj_dst is None: obj_dst = mirrorPose.get_ctrl_friend(obj_src) if obj_src is obj_dst: return False tm = obj_src.getMatrix(worldSpace=True) new_tm = mirrorPose.mirror_matrix(tm, mirror_x=True, flip_rot_x=True, flip_rot_y=True, flip_rot_z=True) obj_dst.setMatrix(new_tm, worldSpace=True) return obj_dst
def mirror_jnt(obj_src, handle_joint_orient=True, create_missing=True): from omtk.animation import mirrorPose obj_dst = mirrorPose.get_ctrl_friend(obj_src) if obj_dst is None: src_name = obj_src.name() dst_name = mirrorPose.get_name_friend(src_name) if src_name == dst_name: return False obj_dst = pymel.createNode('joint') obj_dst.rename(dst_name) obj_src_parent = obj_src.getParent() if obj_src_parent: obj_dst_parent = mirrorPose.get_ctrl_friend(obj_src_parent) if obj_dst_parent: obj_dst.setParent(obj_dst_parent) mirror_obj(obj_src, obj_dst) if handle_joint_orient and isinstance(obj_src, pymel.nodetypes.Joint) and isinstance(obj_dst, pymel.nodetypes.Joint): transfer_rotation_to_joint_orient(obj_dst) obj_dst.radius.set(obj_src.radius.get()) return obj_dst