Commit e3816f8975e438010030ef3baccc1a827d7966b7
1 parent
c35d34ad
Exists in
master
Adiciona movimento Retilineo
Showing
2 changed files
with
33 additions
and
28 deletions
Show diff stats
libras.py
| ... | ... | @@ -3,8 +3,6 @@ |
| 3 | 3 | # importa modulos do Python |
| 4 | 4 | import sys |
| 5 | 5 | import os |
| 6 | - | |
| 7 | - | |
| 8 | 6 | # insere o diretorio atual no path |
| 9 | 7 | # permite que o código seja executado de qualquer diretório, possibilitando acesso aos modulos locais |
| 10 | 8 | sys.path.append(os.getcwd()) |
| ... | ... | @@ -12,7 +10,6 @@ sys.path.append(os.getcwd()) |
| 12 | 10 | # importa modulos nativos do Blender e Python |
| 13 | 11 | import bpy |
| 14 | 12 | import json |
| 15 | - | |
| 16 | 13 | # importa modulos locais |
| 17 | 14 | import util |
| 18 | 15 | import moves |
| ... | ... | @@ -34,6 +31,8 @@ util.outconf() |
| 34 | 31 | |
| 35 | 32 | # define a posição dos keyframes |
| 36 | 33 | hands_default_frames = [15,18] |
| 34 | +# define a posição dos keyframes | |
| 35 | +hands_frames_retilineo = [30,33] | |
| 37 | 36 | |
| 38 | 37 | # Carrega o objeto presente no avatar |
| 39 | 38 | armature = bpy.context.scene.objects.get('Armature.001') |
| ... | ... | @@ -70,35 +69,42 @@ def faceConfiguration(handParam, positionFrames, bones): |
| 70 | 69 | def get_endFrame(): |
| 71 | 70 | endsFrame = [18] |
| 72 | 71 | if(json_input["rightHand"] != []): |
| 73 | - if(json_input["rightHand"][0] == "circular" or json_input["rightHand"][0] == "semicircular"): | |
| 74 | - endsFrame.append(int(json_input["rightHand"][4]*8*5+15)) | |
| 72 | + if(json_input["rightHand"][0] == "circular"): | |
| 73 | + endsFrame.append(int(json_input["rightHand"][4]*8*5+18)) | |
| 74 | + elif(json_input["rightHand"][0] == "semicircular"): | |
| 75 | + endsFrame.append(int(json_input["rightHand"][4]*5*5+18)) | |
| 76 | + elif(json_input["rightHand"][0] == "retilineo"): | |
| 77 | + endsFrame.append(max(hands_frames_retilineo)) | |
| 75 | 78 | if(json_input["leftHand"] != []): |
| 76 | - if(json_input["leftHand"][0] == "circular" or json_input["leftHand"][0] == "semicircular"): | |
| 77 | - endsFrame.append(int(json_input["leftHand"][4]*8*5+15)) | |
| 79 | + if(json_input["leftHand"][0] == "circular"): | |
| 80 | + endsFrame.append(int(json_input["leftHand"][4]*8*5+18)) | |
| 81 | + elif(json_input["leftHand"][0] == "semicircular"): | |
| 82 | + endsFrame.append(int(json_input["rightHand"][4]*5*5+18)) | |
| 83 | + elif(json_input["rightHand"][0] == "retilineo"): | |
| 84 | + endsFrame.append(max(hands_frames_retilineo)) | |
| 78 | 85 | return(max(endsFrame)) |
| 79 | 86 | |
| 80 | 87 | initialFrame, endFrame = 15, get_endFrame() |
| 81 | 88 | |
| 82 | -def circular_or_semiCircular(pose, orientation, direction, radius, laps, intensity = 10, initialFrame = 18): | |
| 89 | +def circular_or_semiCircular(pose, orientation, direction, radius, laps, intensity = 5, initialFrame = 18, turn = None): | |
| 83 | 90 | center = pose.location.x, pose.location.y, pose.location.z |
| 84 | 91 | if(orientation == 'perpendicular'): |
| 85 | 92 | if(direction == 'horario'): |
| 86 | - endFrame = moves.locationCircular(center, radius, 1, 0, 2, pose, 0, laps, intensity, initialFrame) | |
| 93 | + endFrame = moves.locationCircular(center, radius, 1, 0, 2, pose, 0, laps, intensity, initialFrame,turn) | |
| 87 | 94 | else: |
| 88 | - endFrame = moves.locationCircular(center, radius, 0, 1, 2, pose, 0, laps, intensity, initialFrame) | |
| 95 | + endFrame = moves.locationCircular(center, radius, 0, 1, 2, pose, 0, laps, intensity, initialFrame,turn) | |
| 89 | 96 | elif(orientation == 'paralelo'): |
| 90 | 97 | if(direction == 'horario'): |
| 91 | - endFrame = moves.locationCircular(center, radius, 1, 2, 0, pose, 0, laps, intensity, initialFrame) | |
| 98 | + endFrame = moves.locationCircular(center, radius, 1, 2, 0, pose, 0, laps, intensity, initialFrame,turn) | |
| 92 | 99 | else: |
| 93 | - endFrame = moves.locationCircular(center, radius, 2, 1, 0, pose, 0, laps, intensity, initialFrame) | |
| 100 | + endFrame = moves.locationCircular(center, radius, 2, 1, 0, pose, 0, laps, intensity, initialFrame,turn) | |
| 94 | 101 | elif(orientation == 'plano'): |
| 95 | 102 | if(direction == 'horario'): |
| 96 | - endFrame = moves.locationCircular(center, radius, 2, 0, 1, pose, 0, laps, intensity, initialFrame) | |
| 103 | + endFrame = moves.locationCircular(center, radius, 2, 0, 1, pose, 0, laps, intensity, initialFrame,turn) | |
| 97 | 104 | else: |
| 98 | - endFrame = moves.locationCircular(center, radius, 0, 2, 1, pose, 0, laps, intensity, initialFrame) | |
| 105 | + endFrame = moves.locationCircular(center, radius, 0, 2, 1, pose, 0, laps, intensity, initialFrame,turn) | |
| 99 | 106 | return endFrame |
| 100 | 107 | |
| 101 | - | |
| 102 | 108 | #------------------ Configurações------------------------------ |
| 103 | 109 | |
| 104 | 110 | #Função que inicia a configuração de ambas as mãos |
| ... | ... | @@ -123,8 +129,9 @@ def configureHands(): |
| 123 | 129 | endFrame = circular_or_semiCircular(pose, orientation, direction, radius, laps, 5) |
| 124 | 130 | generationConfigurations(actions[i], json_input[hands[i]][-3:], [endFrame], bones_[i]) |
| 125 | 131 | elif(json_input[hands[i]][0] == "retilineo"): |
| 126 | - pass | |
| 127 | - | |
| 132 | + generationConfigurations(actions[i], json_input[hands[i]][-6:-3], hands_default_frames, bones_[i]) | |
| 133 | + generationConfigurations(actions[i], json_input[hands[i]][-3:],hands_frames_retilineo, bones_[i]) | |
| 134 | + | |
| 128 | 135 | # Função que inicia a configuração da face |
| 129 | 136 | def configureFace(): |
| 130 | 137 | global endFrame |
| ... | ... | @@ -133,11 +140,9 @@ def configureFace(): |
| 133 | 140 | faceConfiguration(json_input["facialExp"], [endFrame/4], util.faceBonesConf) |
| 134 | 141 | |
| 135 | 142 | # Default Pose |
| 136 | - | |
| 143 | +print(endFrame) | |
| 137 | 144 | poseDefault([1, endFrame+15], util.allBones) |
| 138 | 145 | configureHands() |
| 139 | 146 | configureFace() |
| 140 | 147 | |
| 141 | - | |
| 142 | - | |
| 143 | -util.render_sign(json_input["userId"], json_input["signName"], 1, endFrame + 25) | |
| 148 | +util.render_sign(json_input["userId"], json_input["signName"], 1, endFrame + 25) | |
| 144 | 149 | \ No newline at end of file | ... | ... |
moves.py
| 1 | 1 | # -*- coding: UTF-8 -*- |
| 2 | 2 | import math |
| 3 | 3 | |
| 4 | -def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPosition, laps, frameJump = 10, initialFrame = 18, turn = None): | |
| 4 | +def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPosition, laps, frameJump = 5, initialFrame = 18, turn = None): | |
| 5 | 5 | sqrt22 = radius * (math.sqrt(2) / 2) |
| 6 | 6 | rad2 = (radius/2) |
| 7 | 7 | currentFrame = initialFrame |
| ... | ... | @@ -70,8 +70,8 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi |
| 70 | 70 | pose.location[k_axis] = center[k_axis] + rad2 |
| 71 | 71 | elif(turn == -1): |
| 72 | 72 | pose.location[i_axis] = center[i_axis] - sqrt22 |
| 73 | - pose.location[j_axis] = center[j_axis] - ray2 | |
| 74 | - pose.location[k_axis] = center[k_axis] - ray2 | |
| 73 | + pose.location[j_axis] = center[j_axis] - rad2 | |
| 74 | + pose.location[k_axis] = center[k_axis] - rad2 | |
| 75 | 75 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') |
| 76 | 76 | currentFrame += frameJump |
| 77 | 77 | |
| ... | ... | @@ -94,12 +94,12 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi |
| 94 | 94 | pose.location[k_axis] = center[k_axis] |
| 95 | 95 | if(turn == 1): |
| 96 | 96 | pose.location[i_axis] = center[i_axis] + sqrt22 |
| 97 | - pose.location[j_axis] = center[j_axis] - ray2 | |
| 98 | - pose.location[k_axis] = center[k_axis] + ray2 | |
| 97 | + pose.location[j_axis] = center[j_axis] - rad2 | |
| 98 | + pose.location[k_axis] = center[k_axis] + rad2 | |
| 99 | 99 | elif(turn == -1): |
| 100 | 100 | pose.location[i_axis] = center[i_axis] + sqrt22 |
| 101 | - pose.location[j_axis] = center[j_axis] - ray2 | |
| 102 | - pose.location[k_axis] = center[k_axis] - ray2 | |
| 101 | + pose.location[j_axis] = center[j_axis] - rad2 | |
| 102 | + pose.location[k_axis] = center[k_axis] - rad2 | |
| 103 | 103 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') |
| 104 | 104 | currentFrame += frameJump |
| 105 | 105 | currentFrame -= frameJump | ... | ... |