diff --git a/.gitignore b/.gitignore index ffcb62d..088ad4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,16 @@ -!/.gitignore .* +!*.gitignore *~ + *.avi *.blend1 *.log *.mp4 +*.webm *.pyc *.swp + textures/ __pycache__ -extra/ Libs/ users/ diff --git a/__init__.py b/__init__.py index c831da7..628dd24 100644 --- a/__init__.py +++ b/__init__.py @@ -3,7 +3,6 @@ __all__ = ( "bmesh_collision" "controller", "decode", - "facial", "libras", "moves", "pyutil", diff --git a/moves.py b/moves.py index 767763b..bdf496f 100644 --- a/moves.py +++ b/moves.py @@ -57,6 +57,7 @@ def read_hand_param(mov_param): return [conf_param, artic_param, orient_param] def contato(action, contact_type, mov_param, bones, is_right_hand, initialFrame = 18, frameJump = 10): + currentFrame = initialFrame if (contact_type == "alisar"): currentFrame = alisar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) elif (contact_type == "cocar"): @@ -179,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, is_semicircular = False): +def circular(js_movement, current_frame, frame_jump, is_right_hand): dict_ray = { "pequeno": 0.5, "normal": 1.0, @@ -196,31 +197,51 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu "grande": 10 } dict_axis = { - "frente-esquerda": [2, 0, 1], - "frente-cima": [2, 1, 0], - "esquerda-cima": [0, 1, 2] + "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] } 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"] - opposite_side = js_movement["lado_oposto"] period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] ray = dict_ray[js_movement["raio"]] - reverse_way = js_movement["sentido_inverso"] 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 (opposite_side) else 0 - if (reverse_way): - tmp = x - x = y - y = tmp + 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 if (is_semicircular) else period + k - for i in range(k, limit + 1): + limit = period + 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 @@ -233,9 +254,6 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu current_frame += 1 return current_frame + frame_jump -# 'lado_oposto' true inverte o sentido do vetor direcional -# 'sentido_inverso' true inverte o sentido do plano - # helicoidal # raio: "pequeno" raio = 0.2, velocidade: "rapido" periodo = 25 # raio: "pequeno" raio = 0.2, velocidade: "normal" periodo = 35 @@ -331,7 +349,78 @@ 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): - return circular(js_movement, current_frame, frame_jump, is_right_hand, True) + 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 def senoidal(js_movement, current_frame, frame_jump, is_right_hand): dict_wave = { -- libgit2 0.21.2