Commit df32bc038fc483fecba364e04a6d61937c7f335b
1 parent
e313bcb0
Exists in
master
Adiciona parâmetro -noaudio ao controller, atualiza movimento senoidal, remove funções não usadas
Showing
5 changed files
with
133 additions
and
127 deletions
Show diff stats
Makefile
@@ -26,12 +26,12 @@ JSON_CIRCULAR = \ | @@ -26,12 +26,12 @@ JSON_CIRCULAR = \ | ||
26 | "mao_direita": { \ | 26 | "mao_direita": { \ |
27 | "circular": { \ | 27 | "circular": { \ |
28 | "plano": "esquerda-cima", \ | 28 | "plano": "esquerda-cima", \ |
29 | + "sentido_inverso": false, \ | ||
29 | "raio": "pequeno", \ | 30 | "raio": "pequeno", \ |
30 | "velocidade": "normal", \ | 31 | "velocidade": "normal", \ |
31 | "lado_oposto": false, \ | 32 | "lado_oposto": false, \ |
32 | - "sentido_inverso": false, \ | ||
33 | "articulacao": 80, \ | 33 | "articulacao": 80, \ |
34 | - "configuracao": 15, \ | 34 | + "configuracao": 19, \ |
35 | "orientacao": 18 \ | 35 | "orientacao": 18 \ |
36 | } \ | 36 | } \ |
37 | } \ | 37 | } \ |
@@ -172,11 +172,11 @@ JSON_HELICOIDAL = \ | @@ -172,11 +172,11 @@ JSON_HELICOIDAL = \ | ||
172 | "mao_esquerda": {}, \ | 172 | "mao_esquerda": {}, \ |
173 | "mao_direita": { \ | 173 | "mao_direita": { \ |
174 | "helicoidal": { \ | 174 | "helicoidal": { \ |
175 | - "plano": "esquerda-cima", \ | ||
176 | - "raio": "pequeno", \ | 175 | + "plano": "frente-esquerda", \ |
176 | + "sentido_inverso": false, \ | ||
177 | + "raio": "grande", \ | ||
177 | "velocidade": "normal", \ | 178 | "velocidade": "normal", \ |
178 | "lado_oposto": false, \ | 179 | "lado_oposto": false, \ |
179 | - "sentido_inverso": true, \ | ||
180 | "articulacao": 79, \ | 180 | "articulacao": 79, \ |
181 | "configuracao": 0, \ | 181 | "configuracao": 0, \ |
182 | "orientacao": 64 \ | 182 | "orientacao": 64 \ |
@@ -241,12 +241,12 @@ JSON_SEMICIRCULAR = \ | @@ -241,12 +241,12 @@ JSON_SEMICIRCULAR = \ | ||
241 | "mao_direita": { \ | 241 | "mao_direita": { \ |
242 | "semicircular": { \ | 242 | "semicircular": { \ |
243 | "plano": "esquerda-cima", \ | 243 | "plano": "esquerda-cima", \ |
244 | + "sentido_inverso": false, \ | ||
244 | "raio": "pequeno", \ | 245 | "raio": "pequeno", \ |
245 | "velocidade": "normal", \ | 246 | "velocidade": "normal", \ |
246 | "lado_oposto": false, \ | 247 | "lado_oposto": false, \ |
247 | - "sentido_inverso": false, \ | ||
248 | "articulacao": 80, \ | 248 | "articulacao": 80, \ |
249 | - "configuracao": 15, \ | 249 | + "configuracao": 19, \ |
250 | "orientacao": 18 \ | 250 | "orientacao": 18 \ |
251 | } \ | 251 | } \ |
252 | } \ | 252 | } \ |
@@ -264,12 +264,13 @@ JSON_SENOIDAL = \ | @@ -264,12 +264,13 @@ JSON_SENOIDAL = \ | ||
264 | "facial": {}, \ | 264 | "facial": {}, \ |
265 | "mao_esquerda": {}, \ | 265 | "mao_esquerda": {}, \ |
266 | "mao_direita": { \ | 266 | "mao_direita": { \ |
267 | - "circular": { \ | ||
268 | - "plano": "esquerda-cima", \ | ||
269 | - "raio": "pequeno", \ | 267 | + "senoidal": { \ |
268 | + "direcao": "esquerda", \ | ||
269 | + "direcao_oposta": true, \ | ||
270 | + "plano_deslocamento": "cima-baixo", \ | ||
271 | + "distancia": "normal", \ | ||
270 | "velocidade": "normal", \ | 272 | "velocidade": "normal", \ |
271 | - "lado_oposto": false, \ | ||
272 | - "sentido_inverso": false, \ | 273 | + "tamanho_onda": "normal", \ |
273 | "articulacao": 79, \ | 274 | "articulacao": 79, \ |
274 | "configuracao": 0, \ | 275 | "configuracao": 0, \ |
275 | "orientacao": 64 \ | 276 | "orientacao": 64 \ |
controller.py
@@ -15,8 +15,8 @@ result = 0 | @@ -15,8 +15,8 @@ result = 0 | ||
15 | 15 | ||
16 | try: | 16 | try: |
17 | # para gravar logs do blender, usar codigo abaixo | 17 | # para gravar logs do blender, usar codigo abaixo |
18 | - # result = subprocess.call(['blender', '-b', blend_path, '-P', main_path, '--', sys.argv[1]], stdout = open('bpy.log', 'w')) | ||
19 | - result = subprocess.call(['blender', '-b', blend_path, '-P', main_path, '--', sys.argv[1]]) | 18 | + # result = subprocess.call(['blender', '-b', blend_path, '-P', main_path, '-noaudio', '--', sys.argv[1]], stdout = open('bpy.log', 'w')) |
19 | + result = subprocess.call(['blender', '-b', blend_path, '-P', main_path, '-noaudio', '--', sys.argv[1]]) | ||
20 | except: | 20 | except: |
21 | result = pyutil.print_stack_trace() | 21 | result = pyutil.print_stack_trace() |
22 | 22 |
libras.py
@@ -21,22 +21,6 @@ import moves | @@ -21,22 +21,6 @@ import moves | ||
21 | import pyutil | 21 | import pyutil |
22 | import decode | 22 | import decode |
23 | 23 | ||
24 | -def insert_keyframe_pose_default(current_frame = 0, pose_bones = bpy.context.object.pose.bones, types_keyframe = ["location", "rotation_quaternion"]): | ||
25 | - for obj in (pose_bones): | ||
26 | - obj.bone.select = True | ||
27 | - for type_keyframe in types_keyframe: | ||
28 | - util.keyframe_insert(obj, type_keyframe, current_frame, False) | ||
29 | - obj.bone.select = False | ||
30 | - return | ||
31 | - | ||
32 | -def pose_default(current_frame = 0, frame_jump = 0, actions = bpy.data.actions): | ||
33 | - for action in actions: | ||
34 | - if (action.use_fake_user): | ||
35 | - bpy.context.object.pose_library = action | ||
36 | - bpy.ops.poselib.apply_pose(pose_index = 0) | ||
37 | - insert_keyframe_pose_default(current_frame) | ||
38 | - return current_frame + frame_jump | ||
39 | - | ||
40 | def main(): | 24 | def main(): |
41 | util.set_pose_mode() | 25 | util.set_pose_mode() |
42 | util.delete_all_keyframes() | 26 | util.delete_all_keyframes() |
@@ -44,18 +28,15 @@ def main(): | @@ -44,18 +28,15 @@ def main(): | ||
44 | bpy.context.scene.animation_data_create() | 28 | bpy.context.scene.animation_data_create() |
45 | 29 | ||
46 | try: | 30 | try: |
47 | - js_input = json.loads(sys.argv[6]) | 31 | + js_input = json.loads(sys.argv[7]) |
48 | js_movimentos = js_input["movimentos"] | 32 | js_movimentos = js_input["movimentos"] |
49 | frame_jump = util.dict_interpolation[js_input["interpolacao"]] | 33 | frame_jump = util.dict_interpolation[js_input["interpolacao"]] |
50 | 34 | ||
51 | - endFrame = pose_default(0, frame_jump) | 35 | + endFrame = util.pose_default(0, frame_jump) |
52 | timeline_facial = 0 | 36 | timeline_facial = 0 |
53 | timeline_mao_esquerda = 0 | 37 | timeline_mao_esquerda = 0 |
54 | timeline_mao_direita = 0 | 38 | timeline_mao_direita = 0 |
55 | 39 | ||
56 | - # setar pose padrao inicial em todos os bones ("location" e "rotation_quaternion") | ||
57 | - endFrame += pose_default(util.dict_interpolation["inicial"]) | ||
58 | - | ||
59 | for i in range(0, len(js_movimentos)): | 40 | for i in range(0, len(js_movimentos)): |
60 | timeline_facial = endFrame | 41 | timeline_facial = endFrame |
61 | timeline_mao_esquerda = endFrame | 42 | timeline_mao_esquerda = endFrame |
@@ -100,18 +81,17 @@ def main(): | @@ -100,18 +81,17 @@ def main(): | ||
100 | endFrame += frame_jump | 81 | endFrame += frame_jump |
101 | 82 | ||
102 | # setar pose padrao final em todos os bones (location e rotation) | 83 | # setar pose padrao final em todos os bones (location e rotation) |
103 | - endFrame = pose_default(endFrame, frame_jump) | ||
104 | - endFrame += util.dict_interpolation["final"] | 84 | + endFrame = util.pose_default(endFrame, frame_jump) |
105 | 85 | ||
106 | sinal = str(js_input["sinal"]) | 86 | sinal = str(js_input["sinal"]) |
107 | user_id = str(js_input["userId"]) | 87 | user_id = str(js_input["userId"]) |
108 | directory = os.path.join(getcwd, "users", user_id) | 88 | directory = os.path.join(getcwd, "users", user_id) |
109 | 89 | ||
110 | # exporta .blend | 90 | # exporta .blend |
111 | - util.export_blend(directory, sinal + ".blend", 0, 0, endFrame) | 91 | + # util.export_blend(directory, sinal + ".blend", 0, 0, endFrame) |
112 | 92 | ||
113 | # exporta .json | 93 | # exporta .json |
114 | - util.export_json(js_input, directory, sinal + ".json") | 94 | + # util.export_json(js_input, directory, sinal + ".json") |
115 | 95 | ||
116 | # exporta .mp4 | 96 | # exporta .mp4 |
117 | util.render_sign(user_id, sinal, endFrame) | 97 | util.render_sign(user_id, sinal, endFrame) |
moves.py
@@ -168,7 +168,8 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | @@ -168,7 +168,8 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | ||
168 | # Obs.: A velocidade do movimento vai ser a relacao entre tamanho do raio e o periodo | 168 | # Obs.: A velocidade do movimento vai ser a relacao entre tamanho do raio e o periodo |
169 | # quanto maior o periodo mais keyframes | 169 | # quanto maior o periodo mais keyframes |
170 | # quanto menor o raio mais rapido | 170 | # quanto menor o raio mais rapido |
171 | -# exemplos: | 171 | + |
172 | +# circular: | ||
172 | # raio: "pequeno" raio = 0.5, velocidade: "rapido" periodo = 25 | 173 | # raio: "pequeno" raio = 0.5, velocidade: "rapido" periodo = 25 |
173 | # raio: "pequeno" raio = 0.5, velocidade: "normal" periodo = 35 | 174 | # raio: "pequeno" raio = 0.5, velocidade: "normal" periodo = 35 |
174 | # raio: "pequeno" raio = 0.5, velocidade: "lento" periodo = 45 | 175 | # raio: "pequeno" raio = 0.5, velocidade: "lento" periodo = 45 |
@@ -189,27 +190,28 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | @@ -189,27 +190,28 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | ||
189 | "normal": 45, | 190 | "normal": 45, |
190 | "rapido": 35 | 191 | "rapido": 35 |
191 | } | 192 | } |
192 | - ray = dict_ray[js_movement["raio"]] | ||
193 | - period = dict_period[js_movement["velocidade"]] | ||
194 | - opposite_side = js_movement["lado_oposto"] | ||
195 | - reverse_way = js_movement["sentido_inverso"] | 193 | + dict_calc = { |
194 | + "pequeno": -10, | ||
195 | + "normal": 0, | ||
196 | + "grande": 10 | ||
197 | + } | ||
198 | + dict_axis = { | ||
199 | + "frente-esquerda": [2, 0, 1], | ||
200 | + "frente-cima": [2, 1, 0], | ||
201 | + "esquerda-cima": [0, 1, 2] | ||
202 | + } | ||
196 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions | 203 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions |
197 | - hand_param = read_hand_param(js_movement) | ||
198 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf | 204 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf |
205 | + hand_param = read_hand_param(js_movement) | ||
199 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] | 206 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] |
200 | - if (js_movement["velocidade"] == "lento"): | ||
201 | - period += 10 | ||
202 | - elif (js_movement["velocidade"] == "rapido"): | ||
203 | - period -= 10 | ||
204 | - if (js_movement["plano"] == "frente-esquerda"): | ||
205 | - x, y = 2, 0 | ||
206 | - elif (js_movement["plano"] == "frente-cima"): | ||
207 | - x, y = 2, 1 | ||
208 | - else: | ||
209 | - x, y = 0, 1 | 207 | + opposite_side = js_movement["lado_oposto"] |
208 | + period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] | ||
209 | + ray = dict_ray[js_movement["raio"]] | ||
210 | + reverse_way = js_movement["sentido_inverso"] | ||
211 | + x = dict_axis[js_movement["plano"]][0] | ||
212 | + y = dict_axis[js_movement["plano"]][1] | ||
213 | + #z = dict_axis[js_movement["plano"]][2] | ||
210 | k = round(period / 2) if (opposite_side) else 0 | 214 | k = round(period / 2) if (opposite_side) else 0 |
211 | - x %= 3 | ||
212 | - y %= 3 | ||
213 | if (reverse_way): | 215 | if (reverse_way): |
214 | tmp = x | 216 | tmp = x |
215 | x = y | 217 | x = y |
@@ -217,9 +219,7 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | @@ -217,9 +219,7 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | ||
217 | util.setPose(actions, hand_param, [current_frame], bones, False) | 219 | util.setPose(actions, hand_param, [current_frame], bones, False) |
218 | util.keyframe_insert(bones, "location", current_frame, False, False) | 220 | util.keyframe_insert(bones, "location", current_frame, False, False) |
219 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] | 221 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] |
220 | - limit = period + k - 1 | ||
221 | - if (is_semicircular): | ||
222 | - limit = round(period / 2) + k | 222 | + limit = round(period / 2) + k if (is_semicircular) else period + k |
223 | for i in range(k, limit + 1): | 223 | for i in range(k, limit + 1): |
224 | bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] | 224 | bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] |
225 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) | 225 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) |
@@ -228,43 +228,59 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | @@ -228,43 +228,59 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | ||
228 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) | 228 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) |
229 | ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) | 229 | ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) |
230 | ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) | 230 | ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) |
231 | - util.keyframe_insert(ik, "location", current_frame) | 231 | + util.keyframe_insert(ik, "location", current_frame, False) |
232 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) | 232 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) |
233 | current_frame += 1 | 233 | current_frame += 1 |
234 | - return current_frame | 234 | + return current_frame + frame_jump |
235 | + | ||
236 | +# 'lado_oposto' true inverte o sentido do vetor direcional | ||
237 | +# 'sentido_inverso' true inverte o sentido do plano | ||
235 | 238 | ||
239 | +# helicoidal | ||
240 | +# raio: "pequeno" raio = 0.2, velocidade: "rapido" periodo = 25 | ||
241 | +# raio: "pequeno" raio = 0.2, velocidade: "normal" periodo = 35 | ||
242 | +# raio: "pequeno" raio = 0.2, velocidade: "lento" periodo = 45 | ||
243 | +# raio: "normal" raio = 0.6, velocidade: "rapido" periodo = 35 | ||
244 | +# raio: "normal" raio = 0.6, velocidade: "normal" periodo = 45 | ||
245 | +# raio: "normal" raio = 0.6, velocidade: "lento" periodo = 55 | ||
246 | +# raio: "grande" raio = 0.8, velocidade: "rapido" periodo = 45 | ||
247 | +# raio: "grande" raio = 0.8, velocidade: "normal" periodo = 55 | ||
248 | +# raio: "grande" raio = 0.8, velocidade: "lento" periodo = 65 | ||
236 | def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): | 249 | def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): |
237 | dict_ray = { | 250 | dict_ray = { |
238 | - "pequeno": 0.5, | ||
239 | - "normal": 1.0, | ||
240 | - "grande": 1.5 | 251 | + "pequeno": 0.2, |
252 | + "normal": 0.6, | ||
253 | + "grande": 0.8 | ||
241 | } | 254 | } |
242 | dict_period = { | 255 | dict_period = { |
243 | "lento": 55, | 256 | "lento": 55, |
244 | "normal": 45, | 257 | "normal": 45, |
245 | "rapido": 35 | 258 | "rapido": 35 |
246 | } | 259 | } |
247 | - ray = dict_ray[js_movement["raio"]] | ||
248 | - period = dict_period[js_movement["velocidade"]] | ||
249 | - opposite_side = js_movement["lado_oposto"] | ||
250 | - reverse_way = js_movement["sentido_inverso"] | 260 | + dict_calc = { |
261 | + "pequeno": -10, | ||
262 | + "normal": 0, | ||
263 | + "grande": 10 | ||
264 | + } | ||
265 | + dict_axis = { | ||
266 | + "frente-esquerda": [2, 0, 1], | ||
267 | + "frente-cima": [2, 1, 0], | ||
268 | + "esquerda-cima": [0, 1, 2] | ||
269 | + } | ||
251 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions | 270 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions |
252 | - hand_param = read_hand_param(js_movement) | ||
253 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf | 271 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf |
272 | + hand_param = read_hand_param(js_movement) | ||
254 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] | 273 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] |
255 | - if (js_movement["velocidade"] == "lento"): | ||
256 | - period += 10 | ||
257 | - elif (js_movement["velocidade"] == "rapido"): | ||
258 | - period -= 10 | ||
259 | - if (js_movement["plano"] == "frente-esquerda"): | ||
260 | - x, y, z = 2, 0, 1 | ||
261 | - elif (js_movement["plano"] == "frente-cima"): | ||
262 | - x, y, z = 2, 1, 0 | ||
263 | - else: | ||
264 | - x, y, z = 0, 1, 2 | ||
265 | - k = round(period / 2) if (opposite_side) else 0 | ||
266 | - x %= 3 | ||
267 | - y %= 3 | 274 | + opposite_side = js_movement["lado_oposto"] |
275 | + period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] | ||
276 | + ray = dict_ray[js_movement["raio"]] | ||
277 | + reverse_way = js_movement["sentido_inverso"] | ||
278 | + # print('raio: "%s" raio = %.1f, velocidade: "%s" periodo = %d' % (js_movement["raio"], ray, js_movement["velocidade"], period)) | ||
279 | + x = dict_axis[js_movement["plano"]][0] | ||
280 | + y = dict_axis[js_movement["plano"]][1] | ||
281 | + z = dict_axis[js_movement["plano"]][2] | ||
282 | + # print("x = %.1f y = %.1f z = %.1f" % (x, y, z)) | ||
283 | + k = 0 | ||
268 | if (reverse_way): | 284 | if (reverse_way): |
269 | tmp = x | 285 | tmp = x |
270 | x = y | 286 | x = y |
@@ -272,7 +288,7 @@ def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): | @@ -272,7 +288,7 @@ def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): | ||
272 | util.setPose(actions, hand_param, [current_frame], bones, False) | 288 | util.setPose(actions, hand_param, [current_frame], bones, False) |
273 | util.keyframe_insert(bones, "location", current_frame, False, False) | 289 | util.keyframe_insert(bones, "location", current_frame, False, False) |
274 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] | 290 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] |
275 | - limit = period + k - 1 | 291 | + limit = period + k |
276 | for i in range(k, 2 * (limit + 1)): | 292 | for i in range(k, 2 * (limit + 1)): |
277 | bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] | 293 | bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] |
278 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) | 294 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) |
@@ -281,11 +297,14 @@ def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): | @@ -281,11 +297,14 @@ def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): | ||
281 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) | 297 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) |
282 | ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) | 298 | ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) |
283 | ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) | 299 | ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) |
284 | - ik.location[z] = ik_loc[z] + (i / period) - ray | ||
285 | - util.keyframe_insert(ik, "location", current_frame) | 300 | + distance_inc = (i / period) - ray |
301 | + if (opposite_side): | ||
302 | + distance_inc = -distance_inc | ||
303 | + ik.location[z] = ik_loc[z] + distance_inc | ||
304 | + util.keyframe_insert(ik, "location", current_frame, False) | ||
286 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) | 305 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) |
287 | current_frame += 1 | 306 | current_frame += 1 |
288 | - return current_frame | 307 | + return current_frame + frame_jump |
289 | 308 | ||
290 | def pontual(js_movement, current_frame, frame_jump, is_right_hand): | 309 | def pontual(js_movement, current_frame, frame_jump, is_right_hand): |
291 | hand_param = read_hand_param(js_movement) | 310 | hand_param = read_hand_param(js_movement) |
@@ -315,55 +334,59 @@ def semicircular(js_movement, current_frame, frame_jump, is_right_hand): | @@ -315,55 +334,59 @@ def semicircular(js_movement, current_frame, frame_jump, is_right_hand): | ||
315 | return circular(js_movement, current_frame, frame_jump, is_right_hand, True) | 334 | return circular(js_movement, current_frame, frame_jump, is_right_hand, True) |
316 | 335 | ||
317 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): | 336 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): |
318 | - dict_ray = { | ||
319 | - "pequeno": 0.5, | ||
320 | - "normal": 1.0, | ||
321 | - "grande": 1.5 | 337 | + dict_wave = { |
338 | + "pequeno": 0.1, | ||
339 | + "normal": 0.2, | ||
340 | + "grande": 0.3 | ||
322 | } | 341 | } |
323 | - dict_period = { | ||
324 | - "lento": 55, | ||
325 | - "normal": 45, | ||
326 | - "rapido": 35 | 342 | + dict_distance_inc = { |
343 | + "pequeno": 0.005, | ||
344 | + "normal": 0.010, | ||
345 | + "grande": 0.015 | ||
327 | } | 346 | } |
328 | - ray = dict_ray[js_movement["raio"]] | ||
329 | - period = dict_period[js_movement["velocidade"]] | ||
330 | - opposite_side = js_movement["lado_oposto"] | ||
331 | - reverse_way = js_movement["sentido_inverso"] | 347 | + dict_speed = { |
348 | + "rapido": 2, | ||
349 | + "normal": 3, | ||
350 | + "lento": 4 | ||
351 | + } | ||
352 | + dict_axis = { | ||
353 | + "esquerda": { | ||
354 | + "frente-tras": [0, 2, 1], | ||
355 | + "cima-baixo": [0, 1, 2] | ||
356 | + }, | ||
357 | + "cima": { | ||
358 | + "frente-tras": [1, 2, 0], | ||
359 | + "esquerda-direita": [1, 0, 2] | ||
360 | + }, | ||
361 | + "frente": { | ||
362 | + "esquerda-direita": [2, 0, 1], | ||
363 | + "cima-baixo": [2, 1, 0] | ||
364 | + } | ||
365 | + } | ||
366 | + axis_dir = dict_axis[js_movement["direcao"]][js_movement["plano_deslocamento"]][0] | ||
367 | + axis_sin = dict_axis[js_movement["direcao"]][js_movement["plano_deslocamento"]][1] | ||
368 | + reverse_way = js_movement["direcao_oposta"] | ||
369 | + distance_inc = dict_distance_inc[js_movement["distancia"]] | ||
370 | + # TODO adaptar velocidade | ||
371 | + # speed = dict_speed[js_movement["velocidade"]] | ||
372 | + wave_len = dict_wave[js_movement["tamanho_onda"]] | ||
332 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions | 373 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions |
333 | - hand_param = read_hand_param(js_movement) | ||
334 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf | 374 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf |
375 | + hand_param = read_hand_param(js_movement) | ||
335 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] | 376 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] |
336 | - if (js_movement["velocidade"] == "lento"): | ||
337 | - period += 10 | ||
338 | - elif (js_movement["velocidade"] == "rapido"): | ||
339 | - period -= 10 | ||
340 | - if (js_movement["plano"] == "frente-esquerda"): | ||
341 | - x, y, z = 2, 0, 1 | ||
342 | - elif (js_movement["plano"] == "frente-cima"): | ||
343 | - x, y, z = 2, 1, 0 | ||
344 | - else: | ||
345 | - x, y, z = 0, 1, 2 | ||
346 | - k = round(period / 2) if (opposite_side) else 0 | ||
347 | - x %= 3 | ||
348 | - y %= 3 | ||
349 | - if (reverse_way): | ||
350 | - tmp = x | ||
351 | - x = y | ||
352 | - y = tmp | ||
353 | util.setPose(actions, hand_param, [current_frame], bones, False) | 377 | util.setPose(actions, hand_param, [current_frame], bones, False) |
354 | util.keyframe_insert(bones, "location", current_frame, False, False) | 378 | util.keyframe_insert(bones, "location", current_frame, False, False) |
355 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] | 379 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] |
356 | - limit = period + k - 1 | ||
357 | - for i in range(k, 2 * (limit + 1)): | ||
358 | - bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] | 380 | + pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] |
381 | + for i in range(0, 100): | ||
382 | + bpy.context.object.pose_library = pose_library | ||
359 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) | 383 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) |
360 | bpy.context.object.pose_library = None | 384 | bpy.context.object.pose_library = None |
361 | util.keyframe_insert(bones, "location", current_frame, False) | 385 | util.keyframe_insert(bones, "location", current_frame, False) |
362 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) | 386 | util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) |
363 | - ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) | ||
364 | - ik.location[y] = ik_loc[y] + (ray )#* math.sin(i / period * (2 * math.pi))) | ||
365 | - #ik.location[z] = ik_loc[z] + (i / period) - ray | ||
366 | - util.keyframe_insert(ik, "location", current_frame) | 387 | + ik.location[axis_dir] += -distance_inc if (reverse_way) else distance_inc |
388 | + ik.location[axis_sin] = ik_loc[axis_sin] + math.sin(i * wave_len) | ||
389 | + util.keyframe_insert(ik, "location", current_frame, False) | ||
367 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) | 390 | util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) |
368 | current_frame += 1 | 391 | current_frame += 1 |
369 | - return current_frame | ||
370 | \ No newline at end of file | 392 | \ No newline at end of file |
393 | + return current_frame + frame_jump |
util.py
@@ -22,11 +22,9 @@ dict_bones = { | @@ -22,11 +22,9 @@ dict_bones = { | ||
22 | } | 22 | } |
23 | 23 | ||
24 | dict_interpolation = { | 24 | dict_interpolation = { |
25 | - "inicial": 20, | ||
26 | "lento": 15, | 25 | "lento": 15, |
27 | "normal": 10, | 26 | "normal": 10, |
28 | "rapido": 5, | 27 | "rapido": 5, |
29 | - "final": 20 | ||
30 | } | 28 | } |
31 | 29 | ||
32 | # Movimento coçar - Índices de poses | 30 | # Movimento coçar - Índices de poses |
@@ -60,6 +58,10 @@ left_bones_conf = dict_bones[conf_esquerda_id] + dict_bones[pa_esquerda_id] + di | @@ -60,6 +58,10 @@ left_bones_conf = dict_bones[conf_esquerda_id] + dict_bones[pa_esquerda_id] + di | ||
60 | 58 | ||
61 | last_keyframe_dict = {} | 59 | last_keyframe_dict = {} |
62 | 60 | ||
61 | +def pose_default(current_frame, frame_jump): | ||
62 | + setPose(all_actions, [0, 0, 0, 0, 0, 0, 0], [current_frame], all_bones, False) | ||
63 | + return current_frame + frame_jump | ||
64 | + | ||
63 | def select_bones(bones = bpy.context.object.pose.bones): | 65 | def select_bones(bones = bpy.context.object.pose.bones): |
64 | if (isinstance(bones, int) or isinstance(bones, str)): | 66 | if (isinstance(bones, int) or isinstance(bones, str)): |
65 | bpy.context.object.pose.bones[bones].bone.select = True | 67 | bpy.context.object.pose.bones[bones].bone.select = True |