diff --git a/moves.py b/moves.py index bdf496f..fc4510b 100644 --- a/moves.py +++ b/moves.py @@ -180,7 +180,7 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = # raio: "grande" raio = 1.5, velocidade: "rapido" periodo = 45 # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55 # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65 -def circular(js_movement, current_frame, frame_jump, is_right_hand): +def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular=False): dict_ray = { "pequeno": 0.5, "normal": 1.0, @@ -196,48 +196,82 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand): "normal": 0, "grande": 10 } + # dict_axis[x, y, z, opposite_side, reverse_way] dict_axis = { - "baixo-direita" : [1, 0, 2, True, False], - "baixo-esquerda" : [1, 0, 2, True, True], - "baixo-frente" : [1, 2, 0, True, True], - "baixo-tras" : [1, 2, 0, True, False], - "cima-direita" : [1, 0, 2, False, True], - "cima-esquerda" : [1, 0, 2, False, False], - "cima-frente" : [1, 2, 0, False, False], - "cima-tras" : [1, 2, 0, False, True], - "direita-baixo" : [0, 1, 2, True, False], - "direita-cima" : [0, 1, 2, True, True], - "direita-frente" : [0, 2, 1, True, True], - "direita-tras" : [0, 2, 1, True, False], - "esquerda-baixo" : [0, 1, 2, False, True], - "esquerda-cima" : [0, 1, 2, False, False], - "esquerda-frente": [0, 2, 1, False, False], - "esquerda-tras" : [0, 2, 1, False, True], - "frente-baixo" : [2, 1, 0, False, True], - "frente-cima" : [2, 1, 0, False, False], - "frente-direita" : [2, 0, 1, False, True], - "frente-esquerda": [2, 0, 1, False, False], - "tras-baixo" : [2, 1, 0, True, False], - "tras-cima" : [2, 1, 0, True, True], - "tras-direita" : [2, 0, 1, True, False], - "tras-esquerda" : [2, 0, 1, True, True] + "baixo-direita" : [1, 0, 2, True, False], # a + "baixo-esquerda" : [1, 0, 2, True, True], # h + "baixo-frente" : [1, 2, 0, True, True], # a + "baixo-tras" : [1, 2, 0, True, False], # h + "cima-direita" : [1, 0, 2, False, True], # h + "cima-esquerda" : [1, 0, 2, False, False], # a + "cima-frente" : [1, 2, 0, False, False], # h + "cima-tras" : [1, 2, 0, False, True], # a + "direita-baixo" : [0, 1, 2, True, False], # h + "direita-cima" : [0, 1, 2, True, True], # a + "direita-frente" : [0, 2, 1, True, True], # a + "direita-tras" : [0, 2, 1, True, False], # h + "esquerda-baixo" : [0, 1, 2, False, True], # a + "esquerda-cima" : [0, 1, 2, False, False], # h + "esquerda-frente": [0, 2, 1, False, False], # h + "esquerda-tras" : [0, 2, 1, False, True], # a + "frente-baixo" : [2, 1, 0, False, True], # h + "frente-cima" : [2, 1, 0, False, False], # a + "frente-direita" : [2, 0, 1, False, True], # h + "frente-esquerda": [2, 0, 1, False, False], # h + "tras-baixo" : [2, 1, 0, True, False], # a + "tras-cima" : [2, 1, 0, True, True], # h + "tras-direita" : [2, 0, 1, True, False], # h + "tras-esquerda" : [2, 0, 1, True, True] # h } + if (is_semicircular): + dict_axis["baixo-esquerda"] = [1, 0, 2, False, True] + dict_axis["baixo-frente"] = [1, 2, 0, False, True] + dict_axis["cima-direita"] = [1, 0, 2, True, True] + dict_axis["cima-tras"] = [1, 2, 0, True, True] + dict_axis["direita-cima"] = [0, 1, 2, False, True] + dict_axis["direita-frente"] = [0, 2, 1, False, True] + dict_axis["esquerda-baixo"] = [0, 1, 2, True, True] + dict_axis["esquerda-tras"] = [0, 2, 1, True, True] + dict_axis["frente-baixo"] = [2, 1, 0, True, True] + dict_axis["frente-direita"] = [2, 0, 1, True, True] + dict_axis["tras-cima"] = [2, 1, 0, False, True] + dict_axis["tras-esquerda"] = [2, 0, 1, False, True] + plan = js_movement["plano"] + if ("sentido_inverso" in js_movement.keys()): + reverse_way = js_movement["sentido_inverso"] + if (reverse_way): + if ("-baixo" in plan): + plan = plan.replace("-baixo", "-cima", 1) + elif("-cima" in plan): + plan = plan.replace("-cima", "-baixo", 1) + elif("-direita" in plan): + plan = plan.replace("-direita", "-esquerda", 1) + elif ("-esquerda" in plan): + plan = plan.replace("-esquerda", "-direita", 1) + elif("-frente" in plan): + plan = plan.replace("-frente", "-tras", 1) + elif("-tras" in plan): + plan = plan.replace("-tras", "-frente", 1) actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf hand_param = read_hand_param(js_movement) ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] ray = dict_ray[js_movement["raio"]] - x = dict_axis[js_movement["plano"]][0] - y = dict_axis[js_movement["plano"]][1] - #z = dict_axis[js_movement["plano"]][2] - k = round(period / 2) if (dict_axis[js_movement["plano"]][3]) else 0 + x = dict_axis[plan][0] + y = dict_axis[plan][1] + #z = dict_axis[plan]][2] + opposite_side = dict_axis[plan][3] + reverse_way = dict_axis[plan][4] + k = round(period / 2) if (opposite_side) else 0 util.setPose(actions, hand_param, [current_frame], bones, False) util.keyframe_insert(bones, "location", current_frame, False, False) ik_loc = [ik.location[0], ik.location[1], ik.location[2]] limit = period + k + if (is_semicircular): + limit = round(period / 2) + k iterator = None - if (dict_axis[js_movement["plano"]][4]): + if (reverse_way): iterator = reversed(range(k, limit + 1)) else: iterator = range(k, limit + 1) @@ -349,78 +383,7 @@ def retilineo(js_movement, current_frame, frame_jump, is_right_hand): return current_frame def semicircular(js_movement, current_frame, frame_jump, is_right_hand): - dict_ray = { - "pequeno": 0.5, - "normal": 1.0, - "grande": 1.5 - } - dict_period = { - "lento": 55, - "normal": 45, - "rapido": 35 - } - dict_calc = { - "pequeno": -10, - "normal": 0, - "grande": 10 - } - dict_axis = { - "baixo-direita" : [1, 0, 2, True, False], - "cima-direita" : [1, 0, 2, True, True], - "cima-tras" : [1, 2, 0, True, True], - "baixo-tras" : [1, 2, 0, True, False], - "baixo-esquerda" : [1, 0, 2, False, True], - "cima-esquerda" : [1, 0, 2, False, False], - "cima-frente" : [1, 2, 0, False, False], - "baixo-frente" : [1, 2, 0, False, True], - "direita-baixo" : [0, 1, 2, True, False], - "esquerda-baixo" : [0, 1, 2, True, True], - "esquerda-tras" : [0, 2, 1, True, True], - "direita-tras" : [0, 2, 1, True, False], - "direita-cima" : [0, 1, 2, False, True], - "esquerda-cima" : [0, 1, 2, False, False], - "esquerda-frente":[0, 2, 1, False, False], - "direita-frente" : [0, 2, 1, False, True], - "tras-cima" : [2, 1, 0, False, True], - "frente-cima" : [2, 1, 0, False, False], - "tras-esquerda" : [2, 0, 1, False, True], - "frente-esquerda": [2, 0, 1, False, False], - "tras-baixo" : [2, 1, 0, True, False], - "frente-baixo" : [2, 1, 0, True, True], - "tras-direita" : [2, 0, 1, True, False], - "frente-direita" : [2, 0, 1, True, True] - } - actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions - bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf - hand_param = read_hand_param(js_movement) - ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] - period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] - ray = dict_ray[js_movement["raio"]] - x = dict_axis[js_movement["plano"]][0] - y = dict_axis[js_movement["plano"]][1] - #z = dict_axis[js_movement["plano"]][2] - k = round(period / 2) if (dict_axis[js_movement["plano"]][3]) else 0 - util.setPose(actions, hand_param, [current_frame], bones, False) - util.keyframe_insert(bones, "location", current_frame, False, False) - ik_loc = [ik.location[0], ik.location[1], ik.location[2]] - limit = round(period / 2) + k - iterator = None - if (dict_axis[js_movement["plano"]][4]): - iterator = reversed(range(k, limit + 1)) - else: - iterator = range(k, limit + 1) - for i in iterator: - bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] - bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) - bpy.context.object.pose_library = None - util.keyframe_insert(bones, "location", current_frame, False) - util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) - ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) - ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) - util.keyframe_insert(ik, "location", current_frame, False) - util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) - current_frame += 1 - return current_frame + frame_jump + return circular(js_movement, current_frame, frame_jump, is_right_hand, True) def senoidal(js_movement, current_frame, frame_jump, is_right_hand): dict_wave = { -- libgit2 0.21.2