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,8 +3,6 @@ | ||
| 3 | # importa modulos do Python | 3 | # importa modulos do Python |
| 4 | import sys | 4 | import sys |
| 5 | import os | 5 | import os |
| 6 | - | ||
| 7 | - | ||
| 8 | # insere o diretorio atual no path | 6 | # insere o diretorio atual no path |
| 9 | # permite que o código seja executado de qualquer diretório, possibilitando acesso aos modulos locais | 7 | # permite que o código seja executado de qualquer diretório, possibilitando acesso aos modulos locais |
| 10 | sys.path.append(os.getcwd()) | 8 | sys.path.append(os.getcwd()) |
| @@ -12,7 +10,6 @@ sys.path.append(os.getcwd()) | @@ -12,7 +10,6 @@ sys.path.append(os.getcwd()) | ||
| 12 | # importa modulos nativos do Blender e Python | 10 | # importa modulos nativos do Blender e Python |
| 13 | import bpy | 11 | import bpy |
| 14 | import json | 12 | import json |
| 15 | - | ||
| 16 | # importa modulos locais | 13 | # importa modulos locais |
| 17 | import util | 14 | import util |
| 18 | import moves | 15 | import moves |
| @@ -34,6 +31,8 @@ util.outconf() | @@ -34,6 +31,8 @@ util.outconf() | ||
| 34 | 31 | ||
| 35 | # define a posição dos keyframes | 32 | # define a posição dos keyframes |
| 36 | hands_default_frames = [15,18] | 33 | hands_default_frames = [15,18] |
| 34 | +# define a posição dos keyframes | ||
| 35 | +hands_frames_retilineo = [30,33] | ||
| 37 | 36 | ||
| 38 | # Carrega o objeto presente no avatar | 37 | # Carrega o objeto presente no avatar |
| 39 | armature = bpy.context.scene.objects.get('Armature.001') | 38 | armature = bpy.context.scene.objects.get('Armature.001') |
| @@ -70,35 +69,42 @@ def faceConfiguration(handParam, positionFrames, bones): | @@ -70,35 +69,42 @@ def faceConfiguration(handParam, positionFrames, bones): | ||
| 70 | def get_endFrame(): | 69 | def get_endFrame(): |
| 71 | endsFrame = [18] | 70 | endsFrame = [18] |
| 72 | if(json_input["rightHand"] != []): | 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 | if(json_input["leftHand"] != []): | 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 | return(max(endsFrame)) | 85 | return(max(endsFrame)) |
| 79 | 86 | ||
| 80 | initialFrame, endFrame = 15, get_endFrame() | 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 | center = pose.location.x, pose.location.y, pose.location.z | 90 | center = pose.location.x, pose.location.y, pose.location.z |
| 84 | if(orientation == 'perpendicular'): | 91 | if(orientation == 'perpendicular'): |
| 85 | if(direction == 'horario'): | 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 | else: | 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 | elif(orientation == 'paralelo'): | 96 | elif(orientation == 'paralelo'): |
| 90 | if(direction == 'horario'): | 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 | else: | 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 | elif(orientation == 'plano'): | 101 | elif(orientation == 'plano'): |
| 95 | if(direction == 'horario'): | 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 | else: | 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 | return endFrame | 106 | return endFrame |
| 100 | 107 | ||
| 101 | - | ||
| 102 | #------------------ Configurações------------------------------ | 108 | #------------------ Configurações------------------------------ |
| 103 | 109 | ||
| 104 | #Função que inicia a configuração de ambas as mãos | 110 | #Função que inicia a configuração de ambas as mãos |
| @@ -123,8 +129,9 @@ def configureHands(): | @@ -123,8 +129,9 @@ def configureHands(): | ||
| 123 | endFrame = circular_or_semiCircular(pose, orientation, direction, radius, laps, 5) | 129 | endFrame = circular_or_semiCircular(pose, orientation, direction, radius, laps, 5) |
| 124 | generationConfigurations(actions[i], json_input[hands[i]][-3:], [endFrame], bones_[i]) | 130 | generationConfigurations(actions[i], json_input[hands[i]][-3:], [endFrame], bones_[i]) |
| 125 | elif(json_input[hands[i]][0] == "retilineo"): | 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 | # Função que inicia a configuração da face | 135 | # Função que inicia a configuração da face |
| 129 | def configureFace(): | 136 | def configureFace(): |
| 130 | global endFrame | 137 | global endFrame |
| @@ -133,11 +140,9 @@ def configureFace(): | @@ -133,11 +140,9 @@ def configureFace(): | ||
| 133 | faceConfiguration(json_input["facialExp"], [endFrame/4], util.faceBonesConf) | 140 | faceConfiguration(json_input["facialExp"], [endFrame/4], util.faceBonesConf) |
| 134 | 141 | ||
| 135 | # Default Pose | 142 | # Default Pose |
| 136 | - | 143 | +print(endFrame) |
| 137 | poseDefault([1, endFrame+15], util.allBones) | 144 | poseDefault([1, endFrame+15], util.allBones) |
| 138 | configureHands() | 145 | configureHands() |
| 139 | configureFace() | 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 | \ No newline at end of file | 149 | \ No newline at end of file |
moves.py
| 1 | # -*- coding: UTF-8 -*- | 1 | # -*- coding: UTF-8 -*- |
| 2 | import math | 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 | sqrt22 = radius * (math.sqrt(2) / 2) | 5 | sqrt22 = radius * (math.sqrt(2) / 2) |
| 6 | rad2 = (radius/2) | 6 | rad2 = (radius/2) |
| 7 | currentFrame = initialFrame | 7 | currentFrame = initialFrame |
| @@ -70,8 +70,8 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi | @@ -70,8 +70,8 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi | ||
| 70 | pose.location[k_axis] = center[k_axis] + rad2 | 70 | pose.location[k_axis] = center[k_axis] + rad2 |
| 71 | elif(turn == -1): | 71 | elif(turn == -1): |
| 72 | pose.location[i_axis] = center[i_axis] - sqrt22 | 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 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | 75 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') |
| 76 | currentFrame += frameJump | 76 | currentFrame += frameJump |
| 77 | 77 | ||
| @@ -94,12 +94,12 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi | @@ -94,12 +94,12 @@ def locationCircular(center, radius, i_axis, j_axis, k_axis, pose, initialPositi | ||
| 94 | pose.location[k_axis] = center[k_axis] | 94 | pose.location[k_axis] = center[k_axis] |
| 95 | if(turn == 1): | 95 | if(turn == 1): |
| 96 | pose.location[i_axis] = center[i_axis] + sqrt22 | 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 | elif(turn == -1): | 99 | elif(turn == -1): |
| 100 | pose.location[i_axis] = center[i_axis] + sqrt22 | 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 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | 103 | pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') |
| 104 | currentFrame += frameJump | 104 | currentFrame += frameJump |
| 105 | currentFrame -= frameJump | 105 | currentFrame -= frameJump |