Commit a576064fc515f6e6b0256520b870850b4fd8a139

Authored by André Araújo
1 parent 80c3096e
Exists in master

Adiciona flag sentido_inverso na função movimento circular e semicircular

Showing 1 changed file with 65 additions and 102 deletions   Show diff stats
moves.py
... ... @@ -180,7 +180,7 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump =
180 180 # raio: "grande" raio = 1.5, velocidade: "rapido" periodo = 45
181 181 # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55
182 182 # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65
183   -def circular(js_movement, current_frame, frame_jump, is_right_hand):
  183 +def circular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular=False):
184 184 dict_ray = {
185 185 "pequeno": 0.5,
186 186 "normal": 1.0,
... ... @@ -196,48 +196,82 @@ def circular(js_movement, current_frame, frame_jump, is_right_hand):
196 196 "normal": 0,
197 197 "grande": 10
198 198 }
  199 + # dict_axis[x, y, z, opposite_side, reverse_way]
199 200 dict_axis = {
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]
  201 + "baixo-direita" : [1, 0, 2, True, False], # a
  202 + "baixo-esquerda" : [1, 0, 2, True, True], # h
  203 + "baixo-frente" : [1, 2, 0, True, True], # a
  204 + "baixo-tras" : [1, 2, 0, True, False], # h
  205 + "cima-direita" : [1, 0, 2, False, True], # h
  206 + "cima-esquerda" : [1, 0, 2, False, False], # a
  207 + "cima-frente" : [1, 2, 0, False, False], # h
  208 + "cima-tras" : [1, 2, 0, False, True], # a
  209 + "direita-baixo" : [0, 1, 2, True, False], # h
  210 + "direita-cima" : [0, 1, 2, True, True], # a
  211 + "direita-frente" : [0, 2, 1, True, True], # a
  212 + "direita-tras" : [0, 2, 1, True, False], # h
  213 + "esquerda-baixo" : [0, 1, 2, False, True], # a
  214 + "esquerda-cima" : [0, 1, 2, False, False], # h
  215 + "esquerda-frente": [0, 2, 1, False, False], # h
  216 + "esquerda-tras" : [0, 2, 1, False, True], # a
  217 + "frente-baixo" : [2, 1, 0, False, True], # h
  218 + "frente-cima" : [2, 1, 0, False, False], # a
  219 + "frente-direita" : [2, 0, 1, False, True], # h
  220 + "frente-esquerda": [2, 0, 1, False, False], # h
  221 + "tras-baixo" : [2, 1, 0, True, False], # a
  222 + "tras-cima" : [2, 1, 0, True, True], # h
  223 + "tras-direita" : [2, 0, 1, True, False], # h
  224 + "tras-esquerda" : [2, 0, 1, True, True] # h
224 225 }
  226 + if (is_semicircular):
  227 + dict_axis["baixo-esquerda"] = [1, 0, 2, False, True]
  228 + dict_axis["baixo-frente"] = [1, 2, 0, False, True]
  229 + dict_axis["cima-direita"] = [1, 0, 2, True, True]
  230 + dict_axis["cima-tras"] = [1, 2, 0, True, True]
  231 + dict_axis["direita-cima"] = [0, 1, 2, False, True]
  232 + dict_axis["direita-frente"] = [0, 2, 1, False, True]
  233 + dict_axis["esquerda-baixo"] = [0, 1, 2, True, True]
  234 + dict_axis["esquerda-tras"] = [0, 2, 1, True, True]
  235 + dict_axis["frente-baixo"] = [2, 1, 0, True, True]
  236 + dict_axis["frente-direita"] = [2, 0, 1, True, True]
  237 + dict_axis["tras-cima"] = [2, 1, 0, False, True]
  238 + dict_axis["tras-esquerda"] = [2, 0, 1, False, True]
  239 + plan = js_movement["plano"]
  240 + if ("sentido_inverso" in js_movement.keys()):
  241 + reverse_way = js_movement["sentido_inverso"]
  242 + if (reverse_way):
  243 + if ("-baixo" in plan):
  244 + plan = plan.replace("-baixo", "-cima", 1)
  245 + elif("-cima" in plan):
  246 + plan = plan.replace("-cima", "-baixo", 1)
  247 + elif("-direita" in plan):
  248 + plan = plan.replace("-direita", "-esquerda", 1)
  249 + elif ("-esquerda" in plan):
  250 + plan = plan.replace("-esquerda", "-direita", 1)
  251 + elif("-frente" in plan):
  252 + plan = plan.replace("-frente", "-tras", 1)
  253 + elif("-tras" in plan):
  254 + plan = plan.replace("-tras", "-frente", 1)
225 255 actions = util.right_hand_actions if (is_right_hand) else util.left_hand_actions
226 256 bones = util.right_bones_conf if (is_right_hand) else util.left_bones_conf
227 257 hand_param = read_hand_param(js_movement)
228 258 ik = bpy.context.object.pose.bones["ik_FK.R" if (is_right_hand) else "ik_FK.L"]
229 259 period = dict_period[js_movement["velocidade"]] + dict_calc[js_movement["raio"]]
230 260 ray = dict_ray[js_movement["raio"]]
231   - x = dict_axis[js_movement["plano"]][0]
232   - y = dict_axis[js_movement["plano"]][1]
233   - #z = dict_axis[js_movement["plano"]][2]
234   - k = round(period / 2) if (dict_axis[js_movement["plano"]][3]) else 0
  261 + x = dict_axis[plan][0]
  262 + y = dict_axis[plan][1]
  263 + #z = dict_axis[plan]][2]
  264 + opposite_side = dict_axis[plan][3]
  265 + reverse_way = dict_axis[plan][4]
  266 + k = round(period / 2) if (opposite_side) else 0
235 267 util.setPose(actions, hand_param, [current_frame], bones, False)
236 268 util.keyframe_insert(bones, "location", current_frame, False, False)
237 269 ik_loc = [ik.location[0], ik.location[1], ik.location[2]]
238 270 limit = period + k
  271 + if (is_semicircular):
  272 + limit = round(period / 2) + k
239 273 iterator = None
240   - if (dict_axis[js_movement["plano"]][4]):
  274 + if (reverse_way):
241 275 iterator = reversed(range(k, limit + 1))
242 276 else:
243 277 iterator = range(k, limit + 1)
... ... @@ -349,78 +383,7 @@ def retilineo(js_movement, current_frame, frame_jump, is_right_hand):
349 383 return current_frame
350 384  
351 385 def semicircular(js_movement, current_frame, frame_jump, is_right_hand):
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
  386 + return circular(js_movement, current_frame, frame_jump, is_right_hand, True)
424 387  
425 388 def senoidal(js_movement, current_frame, frame_jump, is_right_hand):
426 389 dict_wave = {
... ...