Commit 80c3096e85ba68267e7947c7883936ed26117443
1 parent
b0712cb6
Exists in
master
Remove parâmetros extras dos movimentos circular e semicircular
Showing
3 changed files
with
110 additions
and
20 deletions
Show diff stats
.gitignore
__init__.py
moves.py
@@ -57,6 +57,7 @@ def read_hand_param(mov_param): | @@ -57,6 +57,7 @@ def read_hand_param(mov_param): | ||
57 | return [conf_param, artic_param, orient_param] | 57 | return [conf_param, artic_param, orient_param] |
58 | 58 | ||
59 | def contato(action, contact_type, mov_param, bones, is_right_hand, initialFrame = 18, frameJump = 10): | 59 | def contato(action, contact_type, mov_param, bones, is_right_hand, initialFrame = 18, frameJump = 10): |
60 | + currentFrame = initialFrame | ||
60 | if (contact_type == "alisar"): | 61 | if (contact_type == "alisar"): |
61 | currentFrame = alisar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) | 62 | currentFrame = alisar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) |
62 | elif (contact_type == "cocar"): | 63 | elif (contact_type == "cocar"): |
@@ -179,7 +180,7 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | @@ -179,7 +180,7 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | ||
179 | # raio: "grande" raio = 1.5, velocidade: "rapido" periodo = 45 | 180 | # raio: "grande" raio = 1.5, velocidade: "rapido" periodo = 45 |
180 | # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55 | 181 | # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55 |
181 | # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65 | 182 | # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65 |
182 | -def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular = False): | 183 | +def circular(js_movement, current_frame, frame_jump, is_right_hand): |
183 | dict_ray = { | 184 | dict_ray = { |
184 | "pequeno": 0.5, | 185 | "pequeno": 0.5, |
185 | "normal": 1.0, | 186 | "normal": 1.0, |
@@ -196,31 +197,51 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | @@ -196,31 +197,51 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | ||
196 | "grande": 10 | 197 | "grande": 10 |
197 | } | 198 | } |
198 | dict_axis = { | 199 | dict_axis = { |
199 | - "frente-esquerda": [2, 0, 1], | ||
200 | - "frente-cima": [2, 1, 0], | ||
201 | - "esquerda-cima": [0, 1, 2] | 200 | + "baixo-direita" : [1, 0, 2, True, False], |
201 | + "baixo-esquerda" : [1, 0, 2, True, True], | ||
202 | + "baixo-frente" : [1, 2, 0, True, True], | ||
203 | + "baixo-tras" : [1, 2, 0, True, False], | ||
204 | + "cima-direita" : [1, 0, 2, False, True], | ||
205 | + "cima-esquerda" : [1, 0, 2, False, False], | ||
206 | + "cima-frente" : [1, 2, 0, False, False], | ||
207 | + "cima-tras" : [1, 2, 0, False, True], | ||
208 | + "direita-baixo" : [0, 1, 2, True, False], | ||
209 | + "direita-cima" : [0, 1, 2, True, True], | ||
210 | + "direita-frente" : [0, 2, 1, True, True], | ||
211 | + "direita-tras" : [0, 2, 1, True, False], | ||
212 | + "esquerda-baixo" : [0, 1, 2, False, True], | ||
213 | + "esquerda-cima" : [0, 1, 2, False, False], | ||
214 | + "esquerda-frente": [0, 2, 1, False, False], | ||
215 | + "esquerda-tras" : [0, 2, 1, False, True], | ||
216 | + "frente-baixo" : [2, 1, 0, False, True], | ||
217 | + "frente-cima" : [2, 1, 0, False, False], | ||
218 | + "frente-direita" : [2, 0, 1, False, True], | ||
219 | + "frente-esquerda": [2, 0, 1, False, False], | ||
220 | + "tras-baixo" : [2, 1, 0, True, False], | ||
221 | + "tras-cima" : [2, 1, 0, True, True], | ||
222 | + "tras-direita" : [2, 0, 1, True, False], | ||
223 | + "tras-esquerda" : [2, 0, 1, True, True] | ||
202 | } | 224 | } |
203 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions | 225 | actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions |
204 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf | 226 | bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf |
205 | hand_param = read_hand_param(js_movement) | 227 | hand_param = read_hand_param(js_movement) |
206 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] | 228 | ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] |
207 | - opposite_side = js_movement["lado_oposto"] | ||
208 | period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] | 229 | period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] |
209 | ray = dict_ray[js_movement["raio"]] | 230 | ray = dict_ray[js_movement["raio"]] |
210 | - reverse_way = js_movement["sentido_inverso"] | ||
211 | x = dict_axis[js_movement["plano"]][0] | 231 | x = dict_axis[js_movement["plano"]][0] |
212 | y = dict_axis[js_movement["plano"]][1] | 232 | y = dict_axis[js_movement["plano"]][1] |
213 | #z = dict_axis[js_movement["plano"]][2] | 233 | #z = dict_axis[js_movement["plano"]][2] |
214 | - k = round(period / 2) if (opposite_side) else 0 | ||
215 | - if (reverse_way): | ||
216 | - tmp = x | ||
217 | - x = y | ||
218 | - y = tmp | 234 | + k = round(period / 2) if (dict_axis[js_movement["plano"]][3]) else 0 |
219 | util.setPose(actions, hand_param, [current_frame], bones, False) | 235 | util.setPose(actions, hand_param, [current_frame], bones, False) |
220 | util.keyframe_insert(bones, "location", current_frame, False, False) | 236 | util.keyframe_insert(bones, "location", current_frame, False, False) |
221 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] | 237 | ik_loc = [ik.location[0], ik.location[1], ik.location[2]] |
222 | - limit = round(period / 2) + k if (is_semicircular) else period + k | ||
223 | - for i in range(k, limit + 1): | 238 | + limit = period + k |
239 | + iterator = None | ||
240 | + if (dict_axis[js_movement["plano"]][4]): | ||
241 | + iterator = reversed(range(k, limit + 1)) | ||
242 | + else: | ||
243 | + iterator = range(k, limit + 1) | ||
244 | + for i in iterator: | ||
224 | bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] | 245 | 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]) | 246 | bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) |
226 | bpy.context.object.pose_library = None | 247 | bpy.context.object.pose_library = None |
@@ -233,9 +254,6 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | @@ -233,9 +254,6 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircu | ||
233 | current_frame += 1 | 254 | current_frame += 1 |
234 | return current_frame + frame_jump | 255 | return current_frame + frame_jump |
235 | 256 | ||
236 | -# 'lado_oposto' true inverte o sentido do vetor direcional | ||
237 | -# 'sentido_inverso' true inverte o sentido do plano | ||
238 | - | ||
239 | # helicoidal | 257 | # helicoidal |
240 | # raio: "pequeno" raio = 0.2, velocidade: "rapido" periodo = 25 | 258 | # raio: "pequeno" raio = 0.2, velocidade: "rapido" periodo = 25 |
241 | # raio: "pequeno" raio = 0.2, velocidade: "normal" periodo = 35 | 259 | # raio: "pequeno" raio = 0.2, velocidade: "normal" periodo = 35 |
@@ -331,7 +349,78 @@ def retilineo(js_movement, current_frame, frame_jump, is_right_hand): | @@ -331,7 +349,78 @@ def retilineo(js_movement, current_frame, frame_jump, is_right_hand): | ||
331 | return current_frame | 349 | return current_frame |
332 | 350 | ||
333 | def semicircular(js_movement, current_frame, frame_jump, is_right_hand): | 351 | def semicircular(js_movement, current_frame, frame_jump, is_right_hand): |
334 | - return circular(js_movement, current_frame, frame_jump, is_right_hand, True) | 352 | + dict_ray = { |
353 | + "pequeno": 0.5, | ||
354 | + "normal": 1.0, | ||
355 | + "grande": 1.5 | ||
356 | + } | ||
357 | + dict_period = { | ||
358 | + "lento": 55, | ||
359 | + "normal": 45, | ||
360 | + "rapido": 35 | ||
361 | + } | ||
362 | + dict_calc = { | ||
363 | + "pequeno": -10, | ||
364 | + "normal": 0, | ||
365 | + "grande": 10 | ||
366 | + } | ||
367 | + dict_axis = { | ||
368 | + "baixo-direita" : [1, 0, 2, True, False], | ||
369 | + "cima-direita" : [1, 0, 2, True, True], | ||
370 | + "cima-tras" : [1, 2, 0, True, True], | ||
371 | + "baixo-tras" : [1, 2, 0, True, False], | ||
372 | + "baixo-esquerda" : [1, 0, 2, False, True], | ||
373 | + "cima-esquerda" : [1, 0, 2, False, False], | ||
374 | + "cima-frente" : [1, 2, 0, False, False], | ||
375 | + "baixo-frente" : [1, 2, 0, False, True], | ||
376 | + "direita-baixo" : [0, 1, 2, True, False], | ||
377 | + "esquerda-baixo" : [0, 1, 2, True, True], | ||
378 | + "esquerda-tras" : [0, 2, 1, True, True], | ||
379 | + "direita-tras" : [0, 2, 1, True, False], | ||
380 | + "direita-cima" : [0, 1, 2, False, True], | ||
381 | + "esquerda-cima" : [0, 1, 2, False, False], | ||
382 | + "esquerda-frente":[0, 2, 1, False, False], | ||
383 | + "direita-frente" : [0, 2, 1, False, True], | ||
384 | + "tras-cima" : [2, 1, 0, False, True], | ||
385 | + "frente-cima" : [2, 1, 0, False, False], | ||
386 | + "tras-esquerda" : [2, 0, 1, False, True], | ||
387 | + "frente-esquerda": [2, 0, 1, False, False], | ||
388 | + "tras-baixo" : [2, 1, 0, True, False], | ||
389 | + "frente-baixo" : [2, 1, 0, True, True], | ||
390 | + "tras-direita" : [2, 0, 1, True, False], | ||
391 | + "frente-direita" : [2, 0, 1, True, True] | ||
392 | + } | ||
393 | + actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions | ||
394 | + bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf | ||
395 | + hand_param = read_hand_param(js_movement) | ||
396 | + ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"] | ||
397 | + period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]] | ||
398 | + ray = dict_ray[js_movement["raio"]] | ||
399 | + x = dict_axis[js_movement["plano"]][0] | ||
400 | + y = dict_axis[js_movement["plano"]][1] | ||
401 | + #z = dict_axis[js_movement["plano"]][2] | ||
402 | + k = round(period / 2) if (dict_axis[js_movement["plano"]][3]) else 0 | ||
403 | + util.setPose(actions, hand_param, [current_frame], bones, False) | ||
404 | + util.keyframe_insert(bones, "location", current_frame, False, False) | ||
405 | + ik_loc = [ik.location[0], ik.location[1], ik.location[2]] | ||
406 | + limit = round(period / 2) + k | ||
407 | + iterator = None | ||
408 | + if (dict_axis[js_movement["plano"]][4]): | ||
409 | + iterator = reversed(range(k, limit + 1)) | ||
410 | + else: | ||
411 | + iterator = range(k, limit + 1) | ||
412 | + for i in iterator: | ||
413 | + bpy.context.object.pose_library = bpy.data.actions[util.conf_direita_id if (is_right_hand) else util.conf_esquerda_id] | ||
414 | + bpy.ops.poselib.apply_pose(pose_index = hand_param[0]) | ||
415 | + bpy.context.object.pose_library = None | ||
416 | + util.keyframe_insert(bones, "location", current_frame, False) | ||
417 | + util.keyframe_insert(bones, "rotation_quaternion", current_frame, False) | ||
418 | + ik.location[x] = ik_loc[x] + (ray * math.cos(i / period * (2 * math.pi))) | ||
419 | + ik.location[y] = ik_loc[y] + (ray * math.sin(i / period * (2 * math.pi))) | ||
420 | + util.keyframe_insert(ik, "location", current_frame, False) | ||
421 | + util.keyframe_insert(ik, "rotation_quaternion", current_frame, False) | ||
422 | + current_frame += 1 | ||
423 | + return current_frame + frame_jump | ||
335 | 424 | ||
336 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): | 425 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): |
337 | dict_wave = { | 426 | dict_wave = { |