Commit bafb8e39b979dd7c89c3ef201e0ca578e9d81769

Authored by Adabriand Furtado
1 parent a0026fb0
Exists in master

Correção da checagem do tipo de movimento e adicionada a pose default no início e fim da animação

Showing 2 changed files with 27 additions and 14 deletions   Show diff stats
libras.py
... ... @@ -32,8 +32,11 @@ util.outconf()
32 32 act = bpy.context.scene.animation_data_create()
33 33  
34 34 # Função responsável por setar pose padrão
35   -def poseDefault(positionFrames, bones):
36   - util.setPose([0], [0], positionFrames, bones)
  35 +def poseDefault(positionFrames, collisionFlag = False):
  36 + handDefaultParam = [0, 0, 0]
  37 + util.setPose(util.right_hand_actions, handDefaultParam, positionFrames, util.rightBonesConf, collisionFlag)
  38 + util.setPose(util.left_hand_actions, handDefaultParam, positionFrames, util.leftBonesConf, collisionFlag)
  39 + # Setar a expressão facial padrão
37 40  
38 41 # Função responsável por setar as configurações das mãos
39 42 def setHandConfiguration(actions, handParam, positionFrames, bones):
... ... @@ -55,7 +58,7 @@ def configureHands():
55 58 iks = ["ik_FK.R", "ik_FK.L"]
56 59 bones_ = [util.rightBonesConf, util.leftBonesConf]
57 60 #Array com as actions FAKES que seram selecionadas no Blender para cada lado do corpo
58   - actions = [[0, 2, 4], [1, 3, 5]]
  61 + actions = [util.right_hand_actions, util.left_hand_actions]
59 62 global endFrame
60 63 for i in range(len(hands)):
61 64 if(json_input[hands[i]] != []):
... ... @@ -63,7 +66,7 @@ def configureHands():
63 66 pose = util.armature.pose.bones[iks[i]]
64 67 handParam = json_input[hands[i]][-3:]
65 68  
66   - if(move in ["pontual, circular, semicircular, retilineo, senoidal"]):
  69 + if(move in ["pontual", "circular", "semicircular", "retilineo", "senoidal"]):
67 70 setHandConfiguration(actions[i], handParam, util.hands_default_frames, bones_[i])
68 71  
69 72 if(move in ["circular", "semicircular"]):
... ... @@ -87,10 +90,10 @@ def configureFace():
87 90 # Set face
88 91 setFaceConfiguration(json_input["facialExp"], [endFrame/4], util.faceBonesConf)
89 92  
  93 +poseDefault([1])
90 94 configureHands()
91 95 configureFace()
92   -
93   -poseDefault([1, endFrame + 15], util.allBones)
  96 +poseDefault([endFrame + 15])
94 97  
95 98 # Default Pose
96 99 print("Total frames: %.3i" % (endFrame))
... ...
util.py
... ... @@ -2,6 +2,8 @@
2 2  
3 3 import bpy
4 4 import math
  5 +#from bmesh_collision import bmesh_check_intersect_objects
  6 +#from pyutil import log
5 7  
6 8 armature = bpy.context.scene.objects.get('Armature.001')
7 9  
... ... @@ -28,22 +30,30 @@ cocar_mao_aberta_index = 56
28 30 cocar_mao_fechada_index = 24
29 31 cocar_orientation_index = 20
30 32  
  33 +# Actions mão direita
  34 +right_hand_actions = [0, 2, 4]
  35 +
  36 +# Actions mão esquerda
  37 +left_hand_actions = [1, 3, 5]
  38 +
  39 +last_keyframe_dict = {}
  40 +
31 41 # Função responsável por selecionar as pose-libs e setar os frames
32   -def setPose(actions, parametesConf, positionFrames, bones):
  42 +def setPose(actions, parametesConf, positionFrames, bones, collisionFlag = True):
33 43 bpy.ops.object.mode_set(mode = 'OBJECT')
34 44 bpy.ops.object.select_all(action="DESELECT")
35 45 bpy.ops.object.mode_set(mode = 'POSE')
36   - for l in range(len(actions)):
37   - armature.pose_library = bpy.data.actions[actions[l]]
38   - for x in range(len(positionFrames)):
  46 +
  47 + for x in range(len(positionFrames)):
  48 + for l in range(len(actions)):
  49 + armature.pose_library = bpy.data.actions[actions[l]]
39 50 bpy.ops.poselib.apply_pose(pose_index = parametesConf[l])
40 51 for i in range(0, (len(bones))):
41   - keyframe_insert(armature.pose.bones[bones[i]], 'location', positionFrames[x])
42   - keyframe_insert(armature.pose.bones[bones[i]], 'rotation_quaternion', positionFrames[x])
  52 + keyframe_insert(armature.pose.bones[bones[i]], 'location', positionFrames[x], collisionFlag)
  53 + keyframe_insert(armature.pose.bones[bones[i]], 'rotation_quaternion', positionFrames[x], collisionFlag)
43 54  
44   -def keyframe_insert(bone, path, positionFrame):
  55 +def keyframe_insert(bone, path, positionFrame, collisionFlag = True):
45 56 bone.keyframe_insert(data_path = path, index = -1, frame = positionFrame)
46   - # collision
47 57  
48 58 # Função que limpa todos os keyframes e define a quantidade de frames
49 59 def erase_all_keyframes():
... ...