Commit f572e5c2b12bb2f3fbffcdba76a811f2f057041f
1 parent
2a8d0fcc
Exists in
master
Modificações no Avatar e no Script
Showing
5 changed files
with
551 additions
and
1 deletions
Show diff stats
avatar_Hozana_wikiLibras.blend
No preview for this file type
libras.py
... | ... | @@ -72,7 +72,7 @@ if(json_input["leftHand"] != []): |
72 | 72 | |
73 | 73 | if(json_input["facialExp"] != []): |
74 | 74 | #confFace |
75 | - lbsObjects.Face(json_input["facialExp"], armature, endFrame) # Set face | |
75 | + lbsObjects.Face(json_input["facialExp"], armature, int(endFrame/1.5)) # Set face | |
76 | 76 | |
77 | 77 | #confPoseEnd |
78 | 78 | lbsObjects.Pose({'loc':[1,endFrame+20],'rot':[1,endFrame+20]},armature) # Set the final pose | ... | ... |
... | ... | @@ -0,0 +1,80 @@ |
1 | +# -*- coding: UTF-8 -*- | |
2 | +import sys | |
3 | +sys.path.append('/home/gtaaas/wikilibras/wikilibras-core') | |
4 | +import json | |
5 | +import objects | |
6 | +import util | |
7 | + | |
8 | + | |
9 | +def circular_or_semiCircular(hand,pose,orientation,direction,radius,laps,intensity = 5,initialFrame = 15): | |
10 | + center = pose.location.x,pose.location.y,pose.location.z | |
11 | + if(orientation == 'perpendicular'): | |
12 | + if(direction == 'horario'): | |
13 | + endFrame = hand.rotationCircular(center,radius,1,0,2,pose,0,laps,intensity,initialFrame) | |
14 | + else: | |
15 | + endFrame = hand.rotationCircular(center,radius,0,1,2,pose,0,laps,intensity,initialFrame) | |
16 | + elif(orientation == 'paralelo'): | |
17 | + if(direction == 'horario'): | |
18 | + endFrame = hand.rotationCircular(center,radius,1,2,0,pose,0,laps,intensity,initialFrame) | |
19 | + else: | |
20 | + endFrame = hand.rotationCircular(center,radius,2,1,0,pose,0,laps,intensity,initialFrame) | |
21 | + return endFrame | |
22 | + | |
23 | +def get_endFrame(json_input): | |
24 | + endsFrame = [] | |
25 | + if(json_input["rightHand"][0] == "circular" or json_input["rightHand"][0] == "semicircular"): | |
26 | + endsFrame.append(int(json_input["rightHand"][4]*8*5+15)) | |
27 | + if(json_input["leftHand"][0] == "circular" or json_input["leftHand"][0] == "semicircular"): | |
28 | + endsFrame.append(int(json_input["leftHand"][4]*8*5+15)) | |
29 | + return(max(endsFrame)) | |
30 | + | |
31 | +#Configurações gerais | |
32 | +json_input = json.loads(sys.argv[5]) # Load jason | |
33 | +util.outconf() | |
34 | +handPosFrame = [15,18] | |
35 | +armature = objects.Armadura('Armature.001') | |
36 | +initialFrame,endFrame = 15,25 | |
37 | + | |
38 | +#Initial Pose | |
39 | +objects.Pose([0], armature) #Set the default pose | |
40 | + | |
41 | +#ConfHandRight | |
42 | +if(json_input["rightHand"] != []): | |
43 | + movRight = json_input["rightHand"][0] | |
44 | + pose = armature.pose.bones['ik_FK.R'] | |
45 | + if(movRight == "pontual"): | |
46 | + handRight = objects.MaoDireita(json_input["rightHand"][-3:],[15,endFrame], armature) | |
47 | + else: | |
48 | + handRight = objects.MaoDireita(json_input["rightHand"][-3:],handPosFrame, armature) | |
49 | + if(movRight == "circular" or movRight == "semicircular"): | |
50 | + orientation,direction,radius,laps = json_input["rightHand"][1:5] | |
51 | + endFrame = circular_or_semiCircular(handRight,pose,orientation,direction,radius,laps,5) | |
52 | + handRight.genConf({'loc':[endFrame],'rot':[endFrame]}) | |
53 | + handRight.genOri({'loc':[endFrame],'rot':[endFrame]}) | |
54 | + elif(json_input["rightHand"][0] == "retilineo"): | |
55 | + pass | |
56 | + | |
57 | +#ConfLeftRight | |
58 | +if(json_input["leftHand"] != []): | |
59 | + movLeft = json_input["leftHand"][0] | |
60 | + pose = armature.pose.bones['ik_FK.L'] | |
61 | + if(movLeft == "pontual"): | |
62 | + handLeft = objects.MaoEsquerda(json_input["leftHand"][-3:],[15,endFrame], armature) | |
63 | + else: | |
64 | + handLeft = objects.MaoEsquerda(json_input["leftHand"][-3:], handPosFrame, armature) | |
65 | + if(movLeft == "circular" or movLeft == "semicircular"): | |
66 | + orientation,direction,radius,laps = json_input["leftHand"][1:5] | |
67 | + endFrame = circular_or_semiCircular(handRight,pose,orientation,direction,radius,laps,5) | |
68 | + handLeft.genConf({'loc':[endFrame],'rot':[endFrame]}) | |
69 | + handLeft.genOri({'loc':[endFrame],'rot':[endFrame]}) | |
70 | + elif(json_input["leftHand"][0] == "retilineo"): | |
71 | + pass | |
72 | + | |
73 | +if(json_input["facialExp"] != []): | |
74 | + #confFace | |
75 | + objects.Face(json_input["facialExp"], armature, int(endFrame/1.5)) # Set face | |
76 | + | |
77 | +#confPoseEnd | |
78 | +objects.Pose([endFrame+20],armature) # Set the final pose | |
79 | + | |
80 | +util.render_sign(json_input["userId"],json_input["signName"],1,endFrame + 20) | ... | ... |
... | ... | @@ -0,0 +1,234 @@ |
1 | +import bpy # import Blender | |
2 | +import math | |
3 | +# from Blender.Scene import Render | |
4 | + | |
5 | +from Libs.Libs_py import * | |
6 | +from Libs.Libs_py import LibPosePadrao, LibConfigMaoDir, LibPontoArticulacaoDir, LibOrientacaoDir, LibConfigMaoEsq, LibPontoArticulacaoEsq, LibOrientacaoEsq, LibExpFacial | |
7 | + | |
8 | +class Armadura: | |
9 | + def __init__(self,nameArmature): | |
10 | + self.armadura = bpy.context.scene.objects.get(nameArmature) # bpy.data.objects['Armature.001'] # bpy.context.object # self.armadura = Blender.Object.Get(nameArmature) | |
11 | + self.pose = self.armadura.pose # self.armadura.getPose() | |
12 | + self.act = bpy.context.scene.animation_data_create() #self.act = Armature.NLA.NewAction(nameAction) | |
13 | + # bpy.context.scene.objects.active = self.armadura # self.act.setActive(self.armadura) | |
14 | + | |
15 | +class BasePose (object): | |
16 | + def setPose(self,groupIndex,actionIndex,poseLibIndex): | |
17 | + bpy.ops.object.mode_set(mode = 'POSE') | |
18 | + armadura.pose_library = bpy.data.actions[actionIndex] | |
19 | + bpy.ops.poselib.apply_pose(pose_index= poseLibIndex) | |
20 | + bpy.context.object.pose.bone_groups.active_index = groupIndex | |
21 | + bpy.ops.pose.group_select() | |
22 | + for x in range(0,len(self.positionFrames)): | |
23 | + bpy.context.scene.frame_set(self.positionFrames[x]) | |
24 | + bpy.ops.anim.keyframe_insert_menu(type = 'BUILTIN_KSI_LocRot') | |
25 | + | |
26 | +class Mao(BasePose): | |
27 | + def __init__(self,handParam,posFrames,armadura): | |
28 | + self.parameters = handParam | |
29 | + self.positionFrames = posFrames | |
30 | + self.armature = armadura | |
31 | + | |
32 | + def genConf(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
33 | + if(posFrames != None): | |
34 | + self.positionFrames = posFrames | |
35 | + self.setPose(groupIndex,actionIndex,poseLibIndex) | |
36 | + | |
37 | + def genArtPoint(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
38 | + if(posFrames != None): | |
39 | + self.positionFrames = posFrames | |
40 | + self.setPose() | |
41 | + | |
42 | + def genOri(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
43 | + if(posFrames != None): | |
44 | + self.positionFrames = posFrames | |
45 | + self.setPose() | |
46 | + | |
47 | + def rotationCircular(self,center, radius, i_axis, j_axis, k_axis,pose, initialPosition, laps, frameJump = 5, initialFrame = 15, turn = None): | |
48 | + const = radius * math.sqrt(2) / 2 | |
49 | + const1 = (radius/2) | |
50 | + currentFrame = initialFrame | |
51 | + for l in range(initialPosition, initialPosition + math.floor(8 * laps) + 1): | |
52 | + if ((l % 8) == 0 ): | |
53 | + pose.location[i_axis] = center[i_axis] + radius | |
54 | + pose.location[j_axis] = center[j_axis] | |
55 | + pose.location[k_axis] = center[k_axis] | |
56 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
57 | + currentFrame += frameJump | |
58 | + if ((l % 8) == 1): | |
59 | + pose.location[i_axis] = center[i_axis] + const | |
60 | + pose.location[j_axis] = center[j_axis] + const | |
61 | + pose.location[k_axis] = center[k_axis] | |
62 | + if(turn == 1): | |
63 | + pose.location[i_axis] = center[i_axis] + const | |
64 | + pose.location[j_axis] = center[j_axis] + const1 | |
65 | + pose.location[k_axis] = center[k_axis] - const1 | |
66 | + elif(turn == -1): | |
67 | + pose.location[i_axis] = center[i_axis] + const | |
68 | + pose.location[j_axis] = center[j_axis] + const1 | |
69 | + pose.location[k_axis] = center[k_axis] + const1 | |
70 | + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') | |
71 | + currentFrame += frameJump | |
72 | + if ((l % 8) == 2): | |
73 | + pose.location[i_axis] = center[i_axis] | |
74 | + pose.location[j_axis] = center[j_axis] + radius | |
75 | + pose.location[k_axis] = center[k_axis] | |
76 | + if(turn == 1): | |
77 | + pose.location[j_axis] = center[j_axis] + const | |
78 | + pose.location[k_axis] = center[k_axis] - const | |
79 | + elif(turn == -1): | |
80 | + pose.location[j_axis] = center[j_axis] + const | |
81 | + pose.location[k_axis] = center[k_axis] + const | |
82 | + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') | |
83 | + currentFrame += frameJump | |
84 | + if ((l % 8) == 3): | |
85 | + pose.location[i_axis] = center[i_axis] - const | |
86 | + pose.location[j_axis] = center[j_axis] + const | |
87 | + pose.location[k_axis] = center[k_axis] | |
88 | + if(turn == 1): | |
89 | + pose.location[i_axis] = center[i_axis] - const | |
90 | + pose.location[j_axis] = center[j_axis] + const1 | |
91 | + pose.location[k_axis] = center[k_axis] - const1 | |
92 | + elif(turn == -1): | |
93 | + pose.location[i_axis] = center[i_axis] - const | |
94 | + pose.location[j_axis] = center[j_axis] + const1 | |
95 | + pose.location[k_axis] = center[k_axis] + const1 | |
96 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
97 | + currentFrame += frameJump | |
98 | + | |
99 | + if ((l % 8) == 4): | |
100 | + pose.location[i_axis] = center[i_axis] - radius | |
101 | + pose.location[j_axis] = center[j_axis] | |
102 | + pose.location[k_axis] = center[k_axis] | |
103 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
104 | + currentFrame += frameJump | |
105 | + | |
106 | + if ((l % 8) == 5): | |
107 | + pose.location[i_axis] = center[i_axis] - const | |
108 | + pose.location[j_axis] = center[j_axis] - const | |
109 | + pose.location[k_axis] = center[k_axis] | |
110 | + if(turn == 1): | |
111 | + pose.location[i_axis] = center[i_axis] - const | |
112 | + pose.location[j_axis] = center[j_axis] - const1 | |
113 | + pose.location[k_axis] = center[k_axis] + const1 | |
114 | + elif(turn == -1): | |
115 | + pose.location[i_axis] = center[i_axis] - const | |
116 | + pose.location[j_axis] = center[j_axis] - const1 | |
117 | + pose.location[k_axis] = center[k_axis] - const1 | |
118 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
119 | + currentFrame += frameJump | |
120 | + | |
121 | + if ((l % 8) == 6): | |
122 | + pose.location[i_axis] = center[i_axis] | |
123 | + pose.location[j_axis] = center[j_axis] - radius | |
124 | + pose.location[k_axis] = center[k_axis] | |
125 | + if(turn == 1): | |
126 | + pose.location[j_axis] = center[j_axis] - const | |
127 | + pose.location[k_axis] = center[k_axis] + const | |
128 | + elif(turn == -1): | |
129 | + pose.location[j_axis] = center[j_axis] - const | |
130 | + pose.location[k_axis] = center[k_axis] - const | |
131 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
132 | + currentFrame += frameJump | |
133 | + | |
134 | + if ((l % 8) == 7): | |
135 | + pose.location[i_axis] = center[i_axis] + const | |
136 | + pose.location[j_axis] = center[j_axis] - const | |
137 | + pose.location[k_axis] = center[k_axis] | |
138 | + if(turn == 1): | |
139 | + pose.location[i_axis] = center[i_axis] + const | |
140 | + pose.location[j_axis] = center[j_axis] - const1 | |
141 | + pose.location[k_axis] = center[k_axis] + const1 | |
142 | + elif(turn == -1): | |
143 | + pose.location[i_axis] = center[i_axis] + const | |
144 | + pose.location[j_axis] = center[j_axis] - const1 | |
145 | + pose.location[k_axis] = center[k_axis] - const1 | |
146 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
147 | + currentFrame += frameJump | |
148 | + currentFrame -= frameJump | |
149 | + return currentFrame | |
150 | + | |
151 | + def genMov(self,pose,frames,calculos): | |
152 | + for i in range(0, len(frames)): | |
153 | + pose.location[:] = calculos[i][0], calculos[i][1], calculos[i][2] | |
154 | + pose.keyframe_insert(data_path = 'location',frame = frames[i],index= -1) | |
155 | + | |
156 | +class MaoDireita(Mao): | |
157 | + def __init__(self, handParam, posFrames, armadura): | |
158 | + super(self.__class__, self).__init__(handParam,posFrames,armadura) | |
159 | + self.genConf() | |
160 | + self.genOri() | |
161 | + self.genArtPoint() | |
162 | + | |
163 | + def genConf(self,posFrames = None,param = None): | |
164 | + if(param != None): | |
165 | + self.parameters = param | |
166 | + super(self.__class__, self).genConf(5,0,handParam[0],posFrames) | |
167 | + | |
168 | + | |
169 | + def genOri(self,posFrames = None,param = None): | |
170 | + if(param != None): | |
171 | + self.parameters = param | |
172 | + super(self.__class__, self).genOri(5,2,handParam[1],posFrames) | |
173 | + | |
174 | + def genArtPoint(self,posFrames = None,param = None): | |
175 | + if(param != None): | |
176 | + self.parameters = param | |
177 | + super(self.__class__, self).genArtPoint(5,4,handParam[2],posFrames) | |
178 | + | |
179 | +class MaoEsquerda(Mao): | |
180 | + def __init__(self,handParam,posFrames,armadura): | |
181 | + super(self.__class__,self).__init__(handParam,posFrames,armadura) | |
182 | + self.genConf() | |
183 | + self.genOri() | |
184 | + self.genArtPoint() | |
185 | + | |
186 | + def genConf(self,posFrames = None,param = None): | |
187 | + default_pose = LibConfigMaoEsq.lib | |
188 | + if(param != None): | |
189 | + self.parameters = param | |
190 | + super(self.__class__, self).genConf(default_pose,posFrames) | |
191 | + | |
192 | + def genOri(self,posFrames = None,param = None): | |
193 | + default_pose = LibOrientacaoEsq.lib | |
194 | + if(param != None): | |
195 | + self.parameters = param | |
196 | + super(self.__class__, self).genOri(default_pose,posFrames) | |
197 | + | |
198 | + def genArtPoint(self, posFrames = None,param = None): | |
199 | + default_pose = LibPontoArticulacaoEsq.lib | |
200 | + if(param != None): | |
201 | + self.parameters = param | |
202 | + super(self.__class__, self).genArtPoint(default_pose,posFrames) | |
203 | + | |
204 | +class Face(BasePose): | |
205 | + def __init__(self,faceParam, armadura, endFram): | |
206 | + self.parameters = ("Exp_9", faceParam, "Exp_9") | |
207 | + self.armature = armadura | |
208 | + self.endFrame = endFram | |
209 | + self.genFace() | |
210 | + | |
211 | + def genFace(self): | |
212 | + default_pose = LibExpFacial.lib | |
213 | + self.setPose(default_pose) | |
214 | + | |
215 | + def setPose(self,default_pose): | |
216 | + for h in range(0,len(self.parameters)): | |
217 | + for cfg in default_pose: | |
218 | + if cfg['name'] == self.parameters[h]: | |
219 | + for bone in cfg['bones']: | |
220 | + pose_bone = self.armature.pose.bones[bone['name']] | |
221 | + pose_bone.location = bone['loc'] | |
222 | + pose_bone.keyframe_insert(data_path = 'location',frame = h*(self.endFrame/2) + 1 + h*3, index = -1) | |
223 | + pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2]) | |
224 | + pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion() | |
225 | + pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = h*(self.endFrame/2) + 1, index = -1) | |
226 | + | |
227 | +class Pose(BasePose): | |
228 | + def __init__ (self, posFrames, armadura): | |
229 | + self.armature = armadura | |
230 | + self.positionFrames = posFrames | |
231 | + self.genPose()0 | |
232 | + | |
233 | + def genPose(self): | |
234 | + self.setPose(8,8,0) | ... | ... |
... | ... | @@ -0,0 +1,236 @@ |
1 | +import bpy # import Blender | |
2 | +import math | |
3 | +# from Blender.Scene import Render | |
4 | + | |
5 | +from Libs.Libs_py import * | |
6 | +from Libs.Libs_py import LibPosePadrao, LibConfigMaoDir, LibPontoArticulacaoDir, LibOrientacaoDir, LibConfigMaoEsq, LibPontoArticulacaoEsq, LibOrientacaoEsq, LibExpFacial | |
7 | + | |
8 | +class Armadura: | |
9 | + def __init__(self,nameArmature): | |
10 | + self.armadura = bpy.context.scene.objects.get(nameArmature) # bpy.data.objects['Armature.001'] # bpy.context.object # self.armadura = Blender.Object.Get(nameArmature) | |
11 | + self.pose = self.armadura.pose # self.armadura.getPose() | |
12 | + self.act = bpy.context.scene.animation_data_create() #self.act = Armature.NLA.NewAction(nameAction) | |
13 | + # bpy.context.scene.objects.active = self.armadura # self.act.setActive(self.armadura) | |
14 | + | |
15 | +class BasePose (object): | |
16 | + def setPose(self,groupIndex,actionIndex,poseLibIndex): | |
17 | + bpy.ops.object.mode_set(mode = 'POSE') | |
18 | + self.armature.pose_library = bpy.data.actions[actionIndex] | |
19 | + bpy.ops.poselib.apply_pose(pose_index= poseLibIndex) | |
20 | + bpy.context.object.pose.bone_groups.active_index = groupIndex | |
21 | + bpy.ops.pose.group_select() | |
22 | + for x in range(0,len(self.positionFrames)): | |
23 | + bpy.context.scene.frame_set(self.positionFrames[x]) | |
24 | + bpy.ops.anim.keyframe_insert_menu(type = 'BUILTIN_KSI_LocRot') | |
25 | + bpy.ops.pose.group_deselect() | |
26 | + | |
27 | + | |
28 | +class Mao(BasePose): | |
29 | + def __init__(self,handParam,posFrames,armadura): | |
30 | + self.parameters = handParam | |
31 | + self.positionFrames = posFrames | |
32 | + self.armature = armadura | |
33 | + | |
34 | + def genConf(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
35 | + if(posFrames != None): | |
36 | + self.positionFrames = posFrames | |
37 | + self.setPose(groupIndex,actionIndex,poseLibIndex) | |
38 | + | |
39 | + def genArtPoint(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
40 | + if(posFrames != None): | |
41 | + self.positionFrames = posFrames | |
42 | + self.setPose() | |
43 | + | |
44 | + def genOri(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): | |
45 | + if(posFrames != None): | |
46 | + self.positionFrames = posFrames | |
47 | + self.setPose() | |
48 | + | |
49 | + def rotationCircular(self,center, radius, i_axis, j_axis, k_axis,pose, initialPosition, laps, frameJump = 5, initialFrame = 15, turn = None): | |
50 | + const = radius * math.sqrt(2) / 2 | |
51 | + const1 = (radius/2) | |
52 | + currentFrame = initialFrame | |
53 | + for l in range(initialPosition, initialPosition + math.floor(8 * laps) + 1): | |
54 | + if ((l % 8) == 0 ): | |
55 | + pose.location[i_axis] = center[i_axis] + radius | |
56 | + pose.location[j_axis] = center[j_axis] | |
57 | + pose.location[k_axis] = center[k_axis] | |
58 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
59 | + currentFrame += frameJump | |
60 | + if ((l % 8) == 1): | |
61 | + pose.location[i_axis] = center[i_axis] + const | |
62 | + pose.location[j_axis] = center[j_axis] + const | |
63 | + pose.location[k_axis] = center[k_axis] | |
64 | + if(turn == 1): | |
65 | + pose.location[i_axis] = center[i_axis] + const | |
66 | + pose.location[j_axis] = center[j_axis] + const1 | |
67 | + pose.location[k_axis] = center[k_axis] - const1 | |
68 | + elif(turn == -1): | |
69 | + pose.location[i_axis] = center[i_axis] + const | |
70 | + pose.location[j_axis] = center[j_axis] + const1 | |
71 | + pose.location[k_axis] = center[k_axis] + const1 | |
72 | + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') | |
73 | + currentFrame += frameJump | |
74 | + if ((l % 8) == 2): | |
75 | + pose.location[i_axis] = center[i_axis] | |
76 | + pose.location[j_axis] = center[j_axis] + radius | |
77 | + pose.location[k_axis] = center[k_axis] | |
78 | + if(turn == 1): | |
79 | + pose.location[j_axis] = center[j_axis] + const | |
80 | + pose.location[k_axis] = center[k_axis] - const | |
81 | + elif(turn == -1): | |
82 | + pose.location[j_axis] = center[j_axis] + const | |
83 | + pose.location[k_axis] = center[k_axis] + const | |
84 | + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') | |
85 | + currentFrame += frameJump | |
86 | + if ((l % 8) == 3): | |
87 | + pose.location[i_axis] = center[i_axis] - const | |
88 | + pose.location[j_axis] = center[j_axis] + const | |
89 | + pose.location[k_axis] = center[k_axis] | |
90 | + if(turn == 1): | |
91 | + pose.location[i_axis] = center[i_axis] - const | |
92 | + pose.location[j_axis] = center[j_axis] + const1 | |
93 | + pose.location[k_axis] = center[k_axis] - const1 | |
94 | + elif(turn == -1): | |
95 | + pose.location[i_axis] = center[i_axis] - const | |
96 | + pose.location[j_axis] = center[j_axis] + const1 | |
97 | + pose.location[k_axis] = center[k_axis] + const1 | |
98 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
99 | + currentFrame += frameJump | |
100 | + | |
101 | + if ((l % 8) == 4): | |
102 | + pose.location[i_axis] = center[i_axis] - radius | |
103 | + pose.location[j_axis] = center[j_axis] | |
104 | + pose.location[k_axis] = center[k_axis] | |
105 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
106 | + currentFrame += frameJump | |
107 | + | |
108 | + if ((l % 8) == 5): | |
109 | + pose.location[i_axis] = center[i_axis] - const | |
110 | + pose.location[j_axis] = center[j_axis] - const | |
111 | + pose.location[k_axis] = center[k_axis] | |
112 | + if(turn == 1): | |
113 | + pose.location[i_axis] = center[i_axis] - const | |
114 | + pose.location[j_axis] = center[j_axis] - const1 | |
115 | + pose.location[k_axis] = center[k_axis] + const1 | |
116 | + elif(turn == -1): | |
117 | + pose.location[i_axis] = center[i_axis] - const | |
118 | + pose.location[j_axis] = center[j_axis] - const1 | |
119 | + pose.location[k_axis] = center[k_axis] - const1 | |
120 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
121 | + currentFrame += frameJump | |
122 | + | |
123 | + if ((l % 8) == 6): | |
124 | + pose.location[i_axis] = center[i_axis] | |
125 | + pose.location[j_axis] = center[j_axis] - radius | |
126 | + pose.location[k_axis] = center[k_axis] | |
127 | + if(turn == 1): | |
128 | + pose.location[j_axis] = center[j_axis] - const | |
129 | + pose.location[k_axis] = center[k_axis] + const | |
130 | + elif(turn == -1): | |
131 | + pose.location[j_axis] = center[j_axis] - const | |
132 | + pose.location[k_axis] = center[k_axis] - const | |
133 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
134 | + currentFrame += frameJump | |
135 | + | |
136 | + if ((l % 8) == 7): | |
137 | + pose.location[i_axis] = center[i_axis] + const | |
138 | + pose.location[j_axis] = center[j_axis] - const | |
139 | + pose.location[k_axis] = center[k_axis] | |
140 | + if(turn == 1): | |
141 | + pose.location[i_axis] = center[i_axis] + const | |
142 | + pose.location[j_axis] = center[j_axis] - const1 | |
143 | + pose.location[k_axis] = center[k_axis] + const1 | |
144 | + elif(turn == -1): | |
145 | + pose.location[i_axis] = center[i_axis] + const | |
146 | + pose.location[j_axis] = center[j_axis] - const1 | |
147 | + pose.location[k_axis] = center[k_axis] - const1 | |
148 | + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') | |
149 | + currentFrame += frameJump | |
150 | + currentFrame -= frameJump | |
151 | + return currentFrame | |
152 | + | |
153 | + def genMov(self,pose,frames,calculos): | |
154 | + for i in range(0, len(frames)): | |
155 | + pose.location[:] = calculos[i][0], calculos[i][1], calculos[i][2] | |
156 | + pose.keyframe_insert(data_path = 'location',frame = frames[i],index= -1) | |
157 | + | |
158 | +class MaoDireita(Mao): | |
159 | + def __init__(self, handParam, posFrames, armadura): | |
160 | + super(self.__class__, self).__init__(handParam,posFrames,armadura) | |
161 | + self.genConf() | |
162 | + self.genOri() | |
163 | + self.genArtPoint() | |
164 | + | |
165 | + def genConf(self,posFrames = None,param = None): | |
166 | + if(param != None): | |
167 | + self.parameters = param | |
168 | + super(self.__class__, self).genConf(5,0,handParam[0],posFrames) | |
169 | + | |
170 | + | |
171 | + def genOri(self,posFrames = None,param = None): | |
172 | + if(param != None): | |
173 | + self.parameters = param | |
174 | + super(self.__class__, self).genOri(5,2,handParam[1],posFrames) | |
175 | + | |
176 | + def genArtPoint(self,posFrames = None,param = None): | |
177 | + if(param != None): | |
178 | + self.parameters = param | |
179 | + super(self.__class__, self).genArtPoint(5,4,handParam[2],posFrames) | |
180 | + | |
181 | +class MaoEsquerda(Mao): | |
182 | + def __init__(self,handParam,posFrames,armadura): | |
183 | + super(self.__class__,self).__init__(handParam,posFrames,armadura) | |
184 | + self.genConf() | |
185 | + self.genOri() | |
186 | + self.genArtPoint() | |
187 | + | |
188 | + def genConf(self,posFrames = None,param = None): | |
189 | + default_pose = LibConfigMaoEsq.lib | |
190 | + if(param != None): | |
191 | + self.parameters = param | |
192 | + super(self.__class__, self).genConf(default_pose,posFrames) | |
193 | + | |
194 | + def genOri(self,posFrames = None,param = None): | |
195 | + default_pose = LibOrientacaoEsq.lib | |
196 | + if(param != None): | |
197 | + self.parameters = param | |
198 | + super(self.__class__, self).genOri(default_pose,posFrames) | |
199 | + | |
200 | + def genArtPoint(self, posFrames = None,param = None): | |
201 | + default_pose = LibPontoArticulacaoEsq.lib | |
202 | + if(param != None): | |
203 | + self.parameters = param | |
204 | + super(self.__class__, self).genArtPoint(default_pose,posFrames) | |
205 | + | |
206 | +class Face(BasePose): | |
207 | + def __init__(self,faceParam, armadura, endFram): | |
208 | + self.parameters = ("Exp_9", faceParam, "Exp_9") | |
209 | + self.armature = armadura | |
210 | + self.endFrame = endFram | |
211 | + self.genFace() | |
212 | + | |
213 | + def genFace(self): | |
214 | + default_pose = LibExpFacial.lib | |
215 | + self.setPose(default_pose) | |
216 | + | |
217 | + def setPose(self,default_pose): | |
218 | + for h in range(0,len(self.parameters)): | |
219 | + for cfg in default_pose: | |
220 | + if cfg['name'] == self.parameters[h]: | |
221 | + for bone in cfg['bones']: | |
222 | + pose_bone = self.armature.pose.bones[bone['name']] | |
223 | + pose_bone.location = bone['loc'] | |
224 | + pose_bone.keyframe_insert(data_path = 'location',frame = h*(self.endFrame/2) + 1 + h*3, index = -1) | |
225 | + pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2]) | |
226 | + pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion() | |
227 | + pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = h*(self.endFrame/2) + 1, index = -1) | |
228 | + | |
229 | +class Pose(BasePose): | |
230 | + def __init__ (self, posFrames, armadura): | |
231 | + self.armature = armadura | |
232 | + self.positionFrames = posFrames | |
233 | + self.genPose() | |
234 | + | |
235 | + def genPose(self): | |
236 | + self.setPose(8,8,0) | ... | ... |