Commit 6bf2e3c28ace3a8a604de379978fad4973a15e7f
1 parent
0f2ad8a3
Exists in
master
Adiciona movimento pontual
Showing
5 changed files
with
104 additions
and
35 deletions
Show diff stats
Makefile
1 | -JSON = \ | 1 | +#JSON = $(JSON_CIRCULAR) |
2 | +JSON = $(JSON_PONTUAL) | ||
3 | + | ||
4 | +JSON_CIRCULAR = \ | ||
2 | '{ \ | 5 | '{ \ |
3 | "userId": "lavid", \ | 6 | "userId": "lavid", \ |
4 | - "sinal": "Modelo JSON", \ | 7 | + "sinal": "modelo_circular", \ |
5 | "interpolacao": "normal", \ | 8 | "interpolacao": "normal", \ |
6 | "movimentos": [ \ | 9 | "movimentos": [ \ |
7 | { \ | 10 | { \ |
@@ -17,9 +20,9 @@ JSON = \ | @@ -17,9 +20,9 @@ JSON = \ | ||
17 | "velocidade": "normal", \ | 20 | "velocidade": "normal", \ |
18 | "lado_oposto": false, \ | 21 | "lado_oposto": false, \ |
19 | "sentido_inverso": false, \ | 22 | "sentido_inverso": false, \ |
20 | - "articulacao": 124, \ | ||
21 | - "configuracao": 60, \ | ||
22 | - "orientacao": 142 \ | 23 | + "articulacao": 80, \ |
24 | + "configuracao": 10, \ | ||
25 | + "orientacao": 20 \ | ||
23 | } \ | 26 | } \ |
24 | }, \ | 27 | }, \ |
25 | "mao_direita": { \ | 28 | "mao_direita": { \ |
@@ -39,6 +42,31 @@ JSON = \ | @@ -39,6 +42,31 @@ JSON = \ | ||
39 | ] \ | 42 | ] \ |
40 | }' | 43 | }' |
41 | 44 | ||
45 | +JSON_PONTUAL = \ | ||
46 | +'{ \ | ||
47 | + "userId": "lavid", \ | ||
48 | + "sinal": "modelo_pontual", \ | ||
49 | + "interpolacao": "normal", \ | ||
50 | + "movimentos": [ \ | ||
51 | + { \ | ||
52 | + "facial": { \ | ||
53 | + "expressao": 10, \ | ||
54 | + "transicao": "normal", \ | ||
55 | + "duracao": "normal" \ | ||
56 | + }, \ | ||
57 | + "mao_direita": { \ | ||
58 | + "pontual": { \ | ||
59 | + "articulacao": 71, \ | ||
60 | + "configuracao": 19, \ | ||
61 | + "orientacao": 11 \ | ||
62 | + } \ | ||
63 | + }, \ | ||
64 | + "mao_esquerda": { \ | ||
65 | + } \ | ||
66 | + } \ | ||
67 | + ] \ | ||
68 | +}' | ||
69 | + | ||
42 | BLEND = avatar_cartoon_v2.74.blend | 70 | BLEND = avatar_cartoon_v2.74.blend |
43 | CONTROLLER = controller.py | 71 | CONTROLLER = controller.py |
44 | MAIN = libras.py | 72 | MAIN = libras.py |
decode.py
@@ -9,9 +9,6 @@ def circular_semicircular(js_movement, current_frame, frame_jump, is_right_hand, | @@ -9,9 +9,6 @@ def circular_semicircular(js_movement, current_frame, frame_jump, is_right_hand, | ||
9 | # decodificar valores | 9 | # decodificar valores |
10 | ray = dict_ray[js_movement['raio']] | 10 | ray = dict_ray[js_movement['raio']] |
11 | period = dict_period[js_movement['velocidade']] | 11 | period = dict_period[js_movement['velocidade']] |
12 | - #print('setar articulacao:', js_movement['articulacao']) | ||
13 | - #print('setar configuracao:', js_movement['configuracao']) | ||
14 | - #print('setar orientacao:', js_movement['orientacao']) | ||
15 | # diminuir a velocidade | 12 | # diminuir a velocidade |
16 | if (js_movement['velocidade'] == 'lento'): | 13 | if (js_movement['velocidade'] == 'lento'): |
17 | period += 10 | 14 | period += 10 |
@@ -49,7 +46,7 @@ def redemoinho(js_movement, current_frame, frame_jump, is_right_hand): | @@ -49,7 +46,7 @@ def redemoinho(js_movement, current_frame, frame_jump, is_right_hand): | ||
49 | pass | 46 | pass |
50 | 47 | ||
51 | def pontual(js_movement, current_frame, frame_jump, is_right_hand): | 48 | def pontual(js_movement, current_frame, frame_jump, is_right_hand): |
52 | - pass | 49 | + return moves.pontual(js_movement, current_frame, frame_jump, is_right_hand) |
53 | 50 | ||
54 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): | 51 | def senoidal(js_movement, current_frame, frame_jump, is_right_hand): |
55 | pass | 52 | pass |
facial.py
@@ -5,11 +5,11 @@ import util | @@ -5,11 +5,11 @@ import util | ||
5 | 5 | ||
6 | # duracao na posicao selecionada | 6 | # duracao na posicao selecionada |
7 | dict_duration = { | 7 | dict_duration = { |
8 | - 'inicial': 20, | 8 | + 'inicial': 10, |
9 | 'lento': 15, | 9 | 'lento': 15, |
10 | 'normal': 10, | 10 | 'normal': 10, |
11 | 'rapido': 5, | 11 | 'rapido': 5, |
12 | - 'final': 20, | 12 | + 'final': 10, |
13 | } | 13 | } |
14 | 14 | ||
15 | # tempo de entrada e saida na posicao selecionada | 15 | # tempo de entrada e saida na posicao selecionada |
@@ -86,28 +86,25 @@ def decode_expression(timeline_facial, js_facial, initial_interpolation = dict_d | @@ -86,28 +86,25 @@ def decode_expression(timeline_facial, js_facial, initial_interpolation = dict_d | ||
86 | frame_transition = dict_transition[js_facial['transicao']] | 86 | frame_transition = dict_transition[js_facial['transicao']] |
87 | # insere o primeiro keyframe | 87 | # insere o primeiro keyframe |
88 | if (timeline_facial == 0): | 88 | if (timeline_facial == 0): |
89 | - set_expression(timeline_facial, 0, initial_interpolation) | ||
90 | - set_expression(timeline_facial, index, frame_duration, frame_transition) | ||
91 | - set_expression(timeline_facial, 0, frame_duration) | 89 | + timeline_facial = set_expression(timeline_facial, 0, initial_interpolation) |
90 | + timeline_facial = set_expression(timeline_facial, index, frame_duration, frame_transition) | ||
91 | + timeline_facial = set_expression(timeline_facial, 0, frame_duration) | ||
92 | return timeline_facial | 92 | return timeline_facial |
93 | 93 | ||
94 | """ | 94 | """ |
95 | # unit test | 95 | # unit test |
96 | def main(): | 96 | def main(): |
97 | - interpolation_start = 20 | ||
98 | - interpolation_end = 20 | ||
99 | timeline_facial = 0 | 97 | timeline_facial = 0 |
100 | - pose_max_range = round(bpy.data.actions[library_name].frame_range[1]) | ||
101 | util.delete_all_keyframes() | 98 | util.delete_all_keyframes() |
102 | - apply_pose(0, util.facial_expression_id) | ||
103 | - for i in range(0, pose_max_range + 1): | 99 | + expressoes = list(range(0, round(bpy.data.actions[util.facial_expression_id].frame_range[1]) + 1)) |
100 | + expressoes = [10, 11] | ||
101 | + for i in expressoes: | ||
104 | js_facial = { | 102 | js_facial = { |
105 | - "expressao": i, # random.randint(0, pose_max_range), | ||
106 | - "transicao": 'normal', | ||
107 | - "duracao": 'normal' | 103 | + "expressao": i, |
104 | + "transicao": "normal", | ||
105 | + "duracao": "normal" | ||
108 | } | 106 | } |
109 | timeline_facial = decode_expression(timeline_facial, js_facial, dict_duration['inicial']) | 107 | timeline_facial = decode_expression(timeline_facial, js_facial, dict_duration['inicial']) |
110 | - print('facial expression %d current frame:' % (js_facial['expressao']), timeline_facial) | ||
111 | bpy.context.scene.frame_end = timeline_facial + dict_duration['final'] | 108 | bpy.context.scene.frame_end = timeline_facial + dict_duration['final'] |
112 | bpy.ops.screen.animation_play(reverse = False) | 109 | bpy.ops.screen.animation_play(reverse = False) |
113 | 110 |
moves.py
@@ -37,9 +37,9 @@ def riscar(action, mov_param, bones, initialFrame = 25, frameJump = 10, bnAntBra | @@ -37,9 +37,9 @@ def riscar(action, mov_param, bones, initialFrame = 25, frameJump = 10, bnAntBra | ||
37 | bnMao = bpy.context.object.pose.bones["BnMao." + lado] | 37 | bnMao = bpy.context.object.pose.bones["BnMao." + lado] |
38 | currentFrame += frameJump | 38 | currentFrame += frameJump |
39 | util.apply_rotation(bnMao, "Y", currentFrame, bnMaoDegree) | 39 | util.apply_rotation(bnMao, "Y", currentFrame, bnMaoDegree) |
40 | - currentFrame += int(frameJump/2) | 40 | + currentFrame += int(frameJump/2) |
41 | util.apply_rotation(bnMao, "Y", currentFrame, (-1)*bnMaoDegree) | 41 | util.apply_rotation(bnMao, "Y", currentFrame, (-1)*bnMaoDegree) |
42 | - currentFrame += int(frameJump/2) | 42 | + currentFrame += int(frameJump/2) |
43 | util.apply_rotation(bnMao, "Y", currentFrame, (-2)*bnMaoDegree) | 43 | util.apply_rotation(bnMao, "Y", currentFrame, (-2)*bnMaoDegree) |
44 | currentFrame += frameJump | 44 | currentFrame += frameJump |
45 | util.setPose(action, handParam, [currentFrame], bones) | 45 | util.setPose(action, handParam, [currentFrame], bones) |
@@ -138,14 +138,14 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | @@ -138,14 +138,14 @@ def alisar_diagonal(boneIK, to_right, repetition, initialFrame = 18, frameJump = | ||
138 | # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55 | 138 | # raio: "grande" raio = 1.5, velocidade: "normal" periodo = 55 |
139 | # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65 | 139 | # raio: "grande" raio = 1.5, velocidade: "lento" periodo = 65 |
140 | # @param obj: (objeto) bone, mesh, e.g. | 140 | # @param obj: (objeto) bone, mesh, e.g. |
141 | -# @param frame_atual: (int) posicao onde o primeiro keyframe vai ser inserido | 141 | +# @param current_frame: (int) posicao onde o primeiro keyframe vai ser inserido |
142 | # @param raio: (int) raio da circunferencia | 142 | # @param raio: (int) raio da circunferencia |
143 | # @param periodo: (int) quantidade de keyframes necessarios para completar uma volta completa | 143 | # @param periodo: (int) quantidade de keyframes necessarios para completar uma volta completa |
144 | # @param x: (int) in [0,1,2] define qual eixo vai variar no seno (0 = eixo X, 1 = eixo Y, 2 = eixo Z) | 144 | # @param x: (int) in [0,1,2] define qual eixo vai variar no seno (0 = eixo X, 1 = eixo Y, 2 = eixo Z) |
145 | # @param y: (int) in [0,1,2] define qual eixo vai variar no cosseno (0 = eixo X, 1 = eixo Y, 2 = eixo Z) | 145 | # @param y: (int) in [0,1,2] define qual eixo vai variar no cosseno (0 = eixo X, 1 = eixo Y, 2 = eixo Z) |
146 | # @param usar_lado_oposto: (bool) inverte o lado da primeira posicao (pode ser util em alguns casos para espelhar) | 146 | # @param usar_lado_oposto: (bool) inverte o lado da primeira posicao (pode ser util em alguns casos para espelhar) |
147 | # @param usar_sentido_oposto (bool) inverte o sentido do movimento (horario para anti-horario) | 147 | # @param usar_sentido_oposto (bool) inverte o sentido do movimento (horario para anti-horario) |
148 | -def circular(obj, frame_atual, raio, periodo, x = 0, y = 1, usar_lado_oposto = False, usar_sentido_oposto = False, meia_volta = False): | 148 | +def circular(obj, current_frame, raio, periodo, x = 0, y = 1, usar_lado_oposto = False, usar_sentido_oposto = False, meia_volta = False): |
149 | # limita inferiormente | 149 | # limita inferiormente |
150 | if (periodo < 16): | 150 | if (periodo < 16): |
151 | periodo = 16 | 151 | periodo = 16 |
@@ -173,10 +173,38 @@ def circular(obj, frame_atual, raio, periodo, x = 0, y = 1, usar_lado_oposto = F | @@ -173,10 +173,38 @@ def circular(obj, frame_atual, raio, periodo, x = 0, y = 1, usar_lado_oposto = F | ||
173 | limite = round(limite / 2) | 173 | limite = round(limite / 2) |
174 | for i in range(k, limite + 1): | 174 | for i in range(k, limite + 1): |
175 | # reduz a quantidade de keyframes | 175 | # reduz a quantidade de keyframes |
176 | - if (frame_atual % 2 == 0): | 176 | + if (current_frame % 2 == 0): |
177 | obj.location[x] = loc[x] + (raio * math.cos(i / periodo * (2 * math.pi))) | 177 | obj.location[x] = loc[x] + (raio * math.cos(i / periodo * (2 * math.pi))) |
178 | obj.location[y] = loc[y] + (raio * math.sin(i / periodo * (2 * math.pi))) | 178 | obj.location[y] = loc[y] + (raio * math.sin(i / periodo * (2 * math.pi))) |
179 | - util.keyframe_insert(obj, 'location', frame_atual) | ||
180 | - frame_atual += 1 | ||
181 | - util.keyframe_insert(obj, 'location', frame_atual) | ||
182 | - return periodo - 1 | ||
183 | \ No newline at end of file | 179 | \ No newline at end of file |
180 | + util.keyframe_insert(obj, 'location', current_frame) | ||
181 | + current_frame += 1 | ||
182 | + util.keyframe_insert(obj, 'location', current_frame) | ||
183 | + return periodo - 1 | ||
184 | + | ||
185 | +def pontual(js_movement, current_frame, frame_jump, is_right_hand): | ||
186 | + #import facial | ||
187 | + print(util.right_bones_conf) | ||
188 | + hand_param = read_hand_param(js_movement) | ||
189 | + bones = util.right_bones_conf if is_right_hand else util.leftBonesConf | ||
190 | + #poselib = None | ||
191 | + if (is_right_hand): | ||
192 | + #poselib = util.pa_direita_id | ||
193 | + hand_actions = util.right_hand_actions | ||
194 | + else: | ||
195 | + #poselib = util.pa_esquerda_id | ||
196 | + hand_actions = util.left_hand_actions | ||
197 | + #ik_bones = util.dict_bones[poselib] | ||
198 | + #util.select_bones(ik_bones) | ||
199 | + util.keyframe_insert(bones, 'location', current_frame, False) | ||
200 | + #facial.keyframe_insert(current_frame, ik_bones, ['location']) | ||
201 | + current_frame += frame_jump | ||
202 | + #facial.apply_pose(js_movement['articulacao'], poselib) | ||
203 | + pyutil.log("XXXXXXXXXXXXXXXX") | ||
204 | + util.setPose(hand_actions, hand_param, [current_frame], bones, False) | ||
205 | + pyutil.log("YYYYYYYYYYYYYYYY") | ||
206 | + #facial.keyframe_insert(current_frame, ik_bones, ['location']) | ||
207 | + current_frame += frame_jump | ||
208 | + #facial.keyframe_insert(current_frame, ik_bones, ['location']) | ||
209 | + util.keyframe_insert(bones, 'location', current_frame, False) | ||
210 | + #util.deselect_bones(ik_bones) | ||
211 | + return current_frame |
util.py
@@ -14,12 +14,14 @@ dict_bones = { | @@ -14,12 +14,14 @@ dict_bones = { | ||
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'], | 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 | "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'], | 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'], | 16 | "03_pa_direita": ['ik_FK.R', 'BnPolyV.R'], |
17 | - "04_pa_direita": ['ik_FK.R', 'BnPolyV.R'], | 17 | + "04_pa_esquerda": ['ik_FK.L', 'BnPolyV.L'], |
18 | "05_orient_direita": ['BnMao.R'], | 18 | "05_orient_direita": ['BnMao.R'], |
19 | "06_orient_esquerda": ['BnMao.L'], | 19 | "06_orient_esquerda": ['BnMao.L'], |
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'] | 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'] |
21 | } | 21 | } |
22 | 22 | ||
23 | +right_bones_conf = dict_bones["01_conf_direita"] + dict_bones["03_pa_direita"] + dict_bones["05_orient_direita"] | ||
24 | + | ||
23 | # Vetor com indices de cada bone do lado direito | 25 | # Vetor com indices de cada bone do lado direito |
24 | rightBonesConf = [1, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66] | 26 | rightBonesConf = [1, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66] |
25 | 27 | ||
@@ -87,22 +89,29 @@ def setPose(actions, parametesConf, positionFrames, bones, collisionFlag = True) | @@ -87,22 +89,29 @@ def setPose(actions, parametesConf, positionFrames, bones, collisionFlag = True) | ||
87 | for x in range(len(positionFrames)): | 89 | for x in range(len(positionFrames)): |
88 | for l in range(len(actions)): | 90 | for l in range(len(actions)): |
89 | action = actions[l] | 91 | action = actions[l] |
92 | + select_bones(bones) | ||
90 | armature.pose_library = bpy.data.actions[action] | 93 | armature.pose_library = bpy.data.actions[action] |
91 | bpy.ops.poselib.apply_pose(pose_index = parametesConf[l]) | 94 | bpy.ops.poselib.apply_pose(pose_index = parametesConf[l]) |
95 | + deselect_bones(bones) | ||
96 | + bpy.context.object.pose_library = None | ||
92 | for i in range(0, (len(bones))): | 97 | for i in range(0, (len(bones))): |
93 | bone = armature.pose.bones[bones[i]] | 98 | bone = armature.pose.bones[bones[i]] |
94 | validHandConf = action in [conf_direita_id, conf_esquerda_id] and "BnDedo" in bone.name | 99 | validHandConf = action in [conf_direita_id, conf_esquerda_id] and "BnDedo" in bone.name |
95 | - validPA = action in [pa_direita_id, pa_esquerda_id] and "ik_FK" in bone.name or "BnPolyV" in bone.name | 100 | + validPA = action in [pa_direita_id, pa_esquerda_id] and ("ik_FK" in bone.name or "BnPolyV" in bone.name) |
96 | validO = action in [orient_direita_id, orient_esquerda_id] and "BnMao" in bone.name | 101 | validO = action in [orient_direita_id, orient_esquerda_id] and "BnMao" in bone.name |
97 | if (validHandConf or validPA or validO): | 102 | if (validHandConf or validPA or validO): |
98 | keyframe_insert(bone, 'location', positionFrames[x], collisionFlag and validPA, validO) | 103 | keyframe_insert(bone, 'location', positionFrames[x], collisionFlag and validPA, validO) |
99 | keyframe_insert(bone, 'rotation_quaternion', positionFrames[x], collisionFlag and validPA, validO) | 104 | keyframe_insert(bone, 'rotation_quaternion', positionFrames[x], collisionFlag and validPA, validO) |
100 | 105 | ||
101 | -def keyframe_insert(bone, path, positionFrame, collisionFlag = True, rotationFlag = False): | 106 | +def internal_keyframe_insert(bone, path, positionFrame, collisionFlag = True, rotationFlag = False): |
102 | # Limit hand depth | 107 | # Limit hand depth |
108 | + if ("ik_FK.R" == bone.name): | ||
109 | + print("VERDADE", bone.location, positionFrame) | ||
103 | if ("ik_FK" in bone.name and bone.location.z < 1): | 110 | if ("ik_FK" in bone.name and bone.location.z < 1): |
104 | bone.location.z = 1 | 111 | bone.location.z = 1 |
112 | + bone.bone.select = True | ||
105 | bone.keyframe_insert(data_path = path, index = -1, frame = positionFrame) | 113 | bone.keyframe_insert(data_path = path, index = -1, frame = positionFrame) |
114 | + bone.bone.select = False | ||
106 | keyframe_id = bone.name + "_" + path | 115 | keyframe_id = bone.name + "_" + path |
107 | last_keyframe = last_keyframe_dict[keyframe_id] if keyframe_id in last_keyframe_dict else 0 | 116 | last_keyframe = last_keyframe_dict[keyframe_id] if keyframe_id in last_keyframe_dict else 0 |
108 | last_keyframe_dict[keyframe_id] = positionFrame | 117 | last_keyframe_dict[keyframe_id] = positionFrame |
@@ -111,6 +120,16 @@ def keyframe_insert(bone, path, positionFrame, collisionFlag = True, rotationFla | @@ -111,6 +120,16 @@ def keyframe_insert(bone, path, positionFrame, collisionFlag = True, rotationFla | ||
111 | if (collisionFlag): | 120 | if (collisionFlag): |
112 | checkCollision(bone, path, positionFrame, last_keyframe) | 121 | checkCollision(bone, path, positionFrame, last_keyframe) |
113 | 122 | ||
123 | +def keyframe_insert(bones, path, positionFrame, collisionFlag = True, rotationFlag = False): | ||
124 | + if (isinstance(bones, list)): | ||
125 | + for bone in bones: | ||
126 | + if (isinstance(bone, int) or isinstance(bone, str)): | ||
127 | + internal_keyframe_insert(bpy.context.object.pose.bones[bone], path, positionFrame, collisionFlag, rotationFlag) | ||
128 | + else: | ||
129 | + internal_keyframe_insert(bone, path, positionFrame, collisionFlag, rotationFlag) | ||
130 | + else: | ||
131 | + internal_keyframe_insert(bones, path, positionFrame, collisionFlag, rotationFlag) | ||
132 | + | ||
114 | def resetIKPosition(isRightHand): | 133 | def resetIKPosition(isRightHand): |
115 | armature.pose_library = bpy.data.actions[pa_direita_id if isRightHand else pa_esquerda_id] | 134 | armature.pose_library = bpy.data.actions[pa_direita_id if isRightHand else pa_esquerda_id] |
116 | bpy.ops.poselib.apply_pose(pose_index = 0) | 135 | bpy.ops.poselib.apply_pose(pose_index = 0) |