Commit 2b00053810cca668f8d700c947f2284cfb6a0251
1 parent
6bf2e3c2
Exists in
master
Correção do movimento pontual
Showing
3 changed files
with
34 additions
and
53 deletions
Show diff stats
decode.py
... | ... | @@ -35,9 +35,9 @@ def contato(js_movement, current_frame, frame_jump, is_right_hand): |
35 | 35 | sub_type = next(iter(js_movement.keys())) |
36 | 36 | mov_param = js_movement[sub_type] |
37 | 37 | action = util.right_hand_actions if is_right_hand else util.left_hand_actions |
38 | - bones = util.rightBonesConf if is_right_hand else util.leftBonesConf | |
38 | + bones = util.right_bones_conf if is_right_hand else util.left_bones_conf | |
39 | 39 | current_frame = current_frame + 2*frame_jump |
40 | - return moves.contato(action, sub_type, mov_param, bones, current_frame, frame_jump) | |
40 | + return moves.contato(action, sub_type, mov_param, bones, is_right_hand, current_frame, frame_jump) | |
41 | 41 | |
42 | 42 | def espiral(js_movement, current_frame, frame_jump, is_right_hand): |
43 | 43 | pass | ... | ... |
moves.py
... | ... | @@ -11,26 +11,27 @@ def read_hand_param(mov_param): |
11 | 11 | orient_param = mov_param['orientacao'] if 'orientacao' in mov_param else 0 |
12 | 12 | return [conf_param, artic_param, orient_param] |
13 | 13 | |
14 | -def contato(action, contact_type, mov_param, bones, initialFrame = 18, frameJump = 10): | |
14 | +def contato(action, contact_type, mov_param, bones, is_right_hand, initialFrame = 18, frameJump = 10): | |
15 | 15 | if (contact_type == "alisar"): |
16 | - currentFrame = alisar(action, mov_param, bones, initialFrame, frameJump) | |
16 | + currentFrame = alisar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) | |
17 | 17 | elif (contact_type == "cocar"): |
18 | 18 | currentFrame = cocar(action, mov_param, bones, initialFrame, frameJump) |
19 | 19 | elif (contact_type == "tocar"): |
20 | - currentFrame = tocar(action, mov_param, bones, initialFrame, frameJump) | |
20 | + currentFrame = tocar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) | |
21 | 21 | elif (contact_type == "riscar"): |
22 | - currentFrame = riscar(action, mov_param, bones, initialFrame, frameJump) | |
22 | + currentFrame = riscar(action, mov_param, bones, is_right_hand, initialFrame, frameJump) | |
23 | 23 | return currentFrame |
24 | 24 | |
25 | -def riscar(action, mov_param, bones, initialFrame = 25, frameJump = 10, bnAntBracoDegree = 2, bnMaoDegree = 45): | |
25 | +def riscar(action, mov_param, bones, is_right_hand, initialFrame = 25, frameJump = 10, bnAntBracoDegree = 2, bnMaoDegree = 45): | |
26 | 26 | currentFrame = initialFrame |
27 | 27 | handParam = read_hand_param(mov_param) |
28 | - lado = "R" if util.rightBonesConf == bones else "L" | |
28 | + lado = "R" if is_right_hand else "L" | |
29 | 29 | |
30 | - #bnAntBraco = bpy.context.object.pose.bones["BnAntBraco." + lado] | |
31 | - #util.apply_rotation(bnAntBraco, "Z", currentFrame, bnAntBracoDegree) | |
32 | - #currentFrame += frameJump | |
33 | - #util.apply_rotation(bnAntBraco, "Z", currentFrame, (-1)*(bnAntBracoDegree+1)) | |
30 | + bnAntBraco = bpy.context.object.pose.bones["BnAntBraco." + lado] | |
31 | + currentFrame += frameJump | |
32 | + util.apply_rotation(bnAntBraco, "Z", currentFrame, bnAntBracoDegree) | |
33 | + currentFrame += frameJump | |
34 | + util.apply_rotation(bnAntBraco, "Z", currentFrame, (-1)*(bnAntBracoDegree+1)) | |
34 | 35 | |
35 | 36 | currentFrame = initialFrame |
36 | 37 | util.setPose(action, handParam, [currentFrame], bones) |
... | ... | @@ -45,17 +46,17 @@ def riscar(action, mov_param, bones, initialFrame = 25, frameJump = 10, bnAntBra |
45 | 46 | util.setPose(action, handParam, [currentFrame], bones) |
46 | 47 | return currentFrame |
47 | 48 | |
48 | -def tocar(action, mov_param, bones, initialFrame = 25, degree = 30, frameJump = 10): | |
49 | +def tocar(action, mov_param, bones, is_right_hand, initialFrame = 25, degree = 30, frameJump = 10): | |
49 | 50 | currentFrame = initialFrame |
50 | 51 | handParam = read_hand_param(mov_param) |
51 | 52 | util.setPose(action, handParam, [initialFrame], bones) |
52 | - pose = util.armature.pose.bones["ik_FK.R" if util.rightBonesConf == bones else "ik_FK.L"] | |
53 | + pose = util.armature.pose.bones["ik_FK.R" if is_right_hand else "ik_FK.L"] | |
53 | 54 | |
54 | - lado = "BnMao.R" if util.rightBonesConf == bones else "BnMao.L" | |
55 | + lado = "BnMao.R" if is_right_hand else "BnMao.L" | |
55 | 56 | bnMao = bpy.context.object.pose.bones[lado] |
56 | 57 | currentFrame += frameJump |
57 | 58 | util.apply_rotation(bnMao, "X", currentFrame, -degree) |
58 | - pose = util.armature.pose.bones["ik_FK.R" if util.rightBonesConf == bones else "ik_FK.L"] | |
59 | + pose = util.armature.pose.bones["ik_FK.R" if is_right_hand else "ik_FK.L"] | |
59 | 60 | currentFrame += frameJump |
60 | 61 | util.apply_rotation(bnMao, "X", currentFrame, degree) |
61 | 62 | util.setPose(action[0:2], handParam[0:2], [currentFrame], bones) |
... | ... | @@ -73,13 +74,13 @@ def cocar(action, mov_param, bones, initialFrame = 18, frameJump = 10): |
73 | 74 | currentFrame += frameJump |
74 | 75 | return currentFrame |
75 | 76 | |
76 | -def alisar(action, mov_param, bones, initialFrame = 18, frameJump = 10, width = 0.25): | |
77 | +def alisar(action, mov_param, bones, is_right_hand, initialFrame = 18, frameJump = 10, width = 0.25): | |
77 | 78 | currentFrame = initialFrame |
78 | 79 | plane = mov_param['plano'] if 'plano' in mov_param else "perpendicular" |
79 | 80 | repetition = mov_param['repeticoes'] if 'repeticoes' in mov_param else 2 |
80 | 81 | handParam = read_hand_param(mov_param) |
81 | 82 | util.setPose(action, handParam, [currentFrame], bones) |
82 | - boneIK = util.armature.pose.bones["ik_FK.R" if util.rightBonesConf == bones else "ik_FK.L"] | |
83 | + boneIK = util.armature.pose.bones["ik_FK.R" if is_right_hand else "ik_FK.L"] | |
83 | 84 | |
84 | 85 | if (plane == "perpendicular"): |
85 | 86 | currentFrame = alisar_xy(boneIK, 1, repetition, currentFrame, frameJump, width) |
... | ... | @@ -182,29 +183,13 @@ def circular(obj, current_frame, raio, periodo, x = 0, y = 1, usar_lado_oposto = |
182 | 183 | return periodo - 1 |
183 | 184 | |
184 | 185 | def pontual(js_movement, current_frame, frame_jump, is_right_hand): |
185 | - #import facial | |
186 | - print(util.right_bones_conf) | |
187 | 186 | hand_param = read_hand_param(js_movement) |
188 | - bones = util.right_bones_conf if is_right_hand else util.leftBonesConf | |
189 | - #poselib = None | |
190 | - if (is_right_hand): | |
191 | - #poselib = util.pa_direita_id | |
192 | - hand_actions = util.right_hand_actions | |
193 | - else: | |
194 | - #poselib = util.pa_esquerda_id | |
195 | - hand_actions = util.left_hand_actions | |
196 | - #ik_bones = util.dict_bones[poselib] | |
197 | - #util.select_bones(ik_bones) | |
198 | - util.keyframe_insert(bones, 'location', current_frame, False) | |
199 | - #facial.keyframe_insert(current_frame, ik_bones, ['location']) | |
187 | + bones = util.right_bones_conf if is_right_hand else util.left_bones_conf | |
188 | + hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions | |
189 | + | |
190 | + util.keyframe_insert(bones, 'location', current_frame) | |
200 | 191 | current_frame += frame_jump |
201 | - #facial.apply_pose(js_movement['articulacao'], poselib) | |
202 | - pyutil.log("XXXXXXXXXXXXXXXX") | |
203 | - util.setPose(hand_actions, hand_param, [current_frame], bones, False) | |
204 | - pyutil.log("YYYYYYYYYYYYYYYY") | |
205 | - #facial.keyframe_insert(current_frame, ik_bones, ['location']) | |
192 | + util.setPose(hand_actions, hand_param, [current_frame], bones) | |
206 | 193 | current_frame += frame_jump |
207 | - #facial.keyframe_insert(current_frame, ik_bones, ['location']) | |
208 | - util.keyframe_insert(bones, 'location', current_frame, False) | |
209 | - #util.deselect_bones(ik_bones) | |
194 | + util.keyframe_insert(bones, 'location', current_frame) | |
210 | 195 | return current_frame | ... | ... |
util.py
... | ... | @@ -13,8 +13,8 @@ armature = bpy.context.scene.objects.get('Armature.001') |
13 | 13 | dict_bones = { |
14 | 14 | "01_conf_direita": ['BnDedo.1.R', 'BnDedo.1.R.006', 'BnDedo.1.R.005', 'BnDedo.1.R.001', 'BnDedo.1.R.008', 'BnDedo.1.R.007', 'BnDedo.1.R.002', 'BnDedo.1.R.010', 'BnDedo.1.R.009', 'BnDedo.1.R.003', 'BnDedo.1.R.012', 'BnDedo.1.R.011', 'BnDedo.1.R.004', 'BnDedo.1.R.014', 'BnDedo.1.R.013'], |
15 | 15 | "02_conf_esquerda": ['BnDedo.1.L', 'BnDedo.1.L.006', 'BnDedo.1.L.005', 'BnDedo.1.L.001', 'BnDedo.1.L.008', 'BnDedo.1.L.007', 'BnDedo.1.L.002', 'BnDedo.1.L.010', 'BnDedo.1.L.009', 'BnDedo.1.L.003', 'BnDedo.1.L.012', 'BnDedo.1.L.011', 'BnDedo.1.L.004', 'BnDedo.1.L.014', 'BnDedo.1.L.013'], |
16 | - "03_pa_direita": ['ik_FK.R', 'BnPolyV.R'], | |
17 | - "04_pa_esquerda": ['ik_FK.L', 'BnPolyV.L'], | |
16 | + "03_pa_direita": ['BnPolyV.R', 'ik_FK.R'], | |
17 | + "04_pa_esquerda": ['BnPolyV.L', 'ik_FK.L'], | |
18 | 18 | "05_orient_direita": ['BnMao.R'], |
19 | 19 | "06_orient_esquerda": ['BnMao.L'], |
20 | 20 | "07_facial": ['BnPescoco', 'BnCabeca', 'BnSobrancCentro.L', 'BnSobrancCentro.R', 'BnSobrancLateral.L', 'BnSobrancLateral.R', 'BnPalpebSuper.L', 'BnPalpebInfe.L', 'BnSobrancCentro', 'BnLabioCentroSuper', 'BnBochecha.L', 'BnBochecha.R', 'BnLabioCentroInfer', 'BnBocaCanto.L', 'BnBocaCanto.R', 'BnMandibula', 'BnLingua', 'BnLingua.003', 'BnLingua.001', 'BnLingua.002', 'BnPalpebSuper.R', 'BnPalpebInfe.R', 'BnOlhosMira', 'BnOlhoMira.L', 'BnOlhoMira.R', 'BnOlho.L', 'BnOlho.R'] |
... | ... | @@ -22,11 +22,13 @@ dict_bones = { |
22 | 22 | |
23 | 23 | right_bones_conf = dict_bones["01_conf_direita"] + dict_bones["03_pa_direita"] + dict_bones["05_orient_direita"] |
24 | 24 | |
25 | +left_bones_conf = dict_bones["02_conf_esquerda"] + dict_bones["04_pa_esquerda"] + dict_bones["06_orient_esquerda"] | |
26 | + | |
25 | 27 | # Vetor com indices de cada bone do lado direito |
26 | -rightBonesConf = [1, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66] | |
28 | +#rightBonesConf = [1, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66] | |
27 | 29 | |
28 | 30 | # Vetor com indices de cada bone do lado esquerdo |
29 | -leftBonesConf = [0, 43, 44, 45, 46, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82] | |
31 | +#leftBonesConf = [0, 43, 44, 45, 46, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82] | |
30 | 32 | |
31 | 33 | # Movimento coçar - Índices de poses |
32 | 34 | cocar_mao_aberta_index = 55 |
... | ... | @@ -105,8 +107,6 @@ def setPose(actions, parametesConf, positionFrames, bones, collisionFlag = True) |
105 | 107 | |
106 | 108 | def internal_keyframe_insert(bone, path, positionFrame, collisionFlag = True, rotationFlag = False): |
107 | 109 | # Limit hand depth |
108 | - if ("ik_FK.R" == bone.name): | |
109 | - print("VERDADE", bone.location, positionFrame) | |
110 | 110 | if ("ik_FK" in bone.name and bone.location.z < 1): |
111 | 111 | bone.location.z = 1 |
112 | 112 | bone.bone.select = True |
... | ... | @@ -117,7 +117,7 @@ def internal_keyframe_insert(bone, path, positionFrame, collisionFlag = True, ro |
117 | 117 | last_keyframe_dict[keyframe_id] = positionFrame |
118 | 118 | if (rotationFlag and path == "rotation_quaternion"): |
119 | 119 | checkRotation(bone, positionFrame, last_keyframe) |
120 | - if (collisionFlag): | |
120 | + if (collisionFlag and "ik_FK" in bone.name): | |
121 | 121 | checkCollision(bone, path, positionFrame, last_keyframe) |
122 | 122 | |
123 | 123 | def keyframe_insert(bones, path, positionFrame, collisionFlag = True, rotationFlag = False): |
... | ... | @@ -182,7 +182,6 @@ def check_hand_collision(initFrame, endFrame): |
182 | 182 | |
183 | 183 | def check_collision(objName, otherObjName, initFrame, endFrame): |
184 | 184 | scene = bpy.context.scene |
185 | - frame_current = scene.frame_current | |
186 | 185 | startFrame = initFrame + int(math.fabs((endFrame - initFrame)/2)) |
187 | 186 | collisionFrame = -1 |
188 | 187 | |
... | ... | @@ -191,11 +190,9 @@ def check_collision(objName, otherObjName, initFrame, endFrame): |
191 | 190 | obj = scene.objects.get(objName) |
192 | 191 | otherObj = scene.objects.get(otherObjName) |
193 | 192 | if (bmesh_check_intersect_objects(obj, otherObj)): |
194 | - pyutil.log("bla") | |
195 | - pyutil.log(i) | |
196 | 193 | collisionFrame = i |
197 | 194 | break |
198 | - scene.frame_set(frame_current) | |
195 | + scene.frame_set(endFrame) | |
199 | 196 | return collisionFrame |
200 | 197 | |
201 | 198 | def check_body_collision(isRightHand, initFrame, endFrame): |
... | ... | @@ -240,13 +237,12 @@ def validate_rotation(bone, endFrame, startFrame = 0): |
240 | 237 | return True |
241 | 238 | rotFrames = [[]] |
242 | 239 | scene = bpy.context.scene |
243 | - frame_current = scene.frame_current | |
244 | 240 | for i in range(startFrame+1, endFrame+1, 1): |
245 | 241 | scene.frame_set(i) |
246 | 242 | rotFrames[-1] = bone.rotation_quaternion.to_euler() |
247 | 243 | rotFrames.append([]) |
248 | 244 | rotFrames.remove([]) |
249 | - scene.frame_set(frame_current) | |
245 | + scene.frame_set(endFrame) | |
250 | 246 | for k in range(1, len(rotFrames), 1): |
251 | 247 | for i in range(0, 3, 1): |
252 | 248 | if (math.fabs(rotFrames[k][i] - rotFrames[k-1][i])) > math.pi/3: | ... | ... |