Commit 29821cc0a522f5122a9ffe594aacd9c9351de7f5

Authored by FrancoNeto
1 parent e22bc7c0
Exists in master

Corrige parâmetros das libs em (Libras.py) e adiciona libs no avatar

.gitignore
1 1 *~
2 2 *.avi
3   -*.blend
4 3 *.blend1
5 4 *.mp4
6 5 *.pyc
... ...
.gitignore.swp 0 → 100644
No preview for this file type
NewFormat_Json
... ... @@ -1,6 +0,0 @@
1   - '{"userId": 4,"rightHand": ["circular","perpendicular","horario",0.6,1,"conf_20","Ori_4","Pa_6"],"leftHand":["pontual","conf_10","Ori_3","Pa_3"],"facialExp": "Exp_6","signName":"Novis"}'
2   -
3   - '{"userId": 4,"rightHand": ["pontual","conf_20","Ori_4","Pa_6"],"leftHand":["circular","perpendicular","horario",0.6,1,"conf_20","Ori_4","Pa_6"],"facialExp": "Exp_6","signName":"pontual_direita"}'
4   -
5   -
6   - '{"userId": 4,"rightHand": ["semicircular","perpendicular","horario",0.6,0.5,"conf_20","Ori_4","Pa_6"],"leftHand":["pontual","conf_10","Ori_3","Pa_3"],"facialExp": "Exp_6","signName":"SemiCircular"}'
avatar_Hozana_wikiLibras.blend
No preview for this file type
inicial.txt
... ... @@ -1 +0,0 @@
1   -Repositorio wikilibras-core Criado
lbsObjects.py
... ... @@ -1,247 +0,0 @@
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, default_pose):
17   - for cfg in default_pose:
18   - if cfg['name'] in self.parameters:
19   - for bone in cfg['bones']:
20   - pose_bone = self.armature.pose.bones[bone['name']] # pose_bone = self.armature.armadura.pose.bones[bone['name']]
21   - pose_bone.location = bone['loc']
22   - for l in range(0,len(self.positionFrames['loc'])):
23   - pose_bone.keyframe_insert(data_path = 'location',frame = self.positionFrames['loc'][l], index = -1)
24   - pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2])
25   - pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion()
26   - for r in range(0,len(self.positionFrames['rot'])):
27   - pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = self.positionFrames['rot'][r], index = -1)
28   - # pose_bone.insertKey(self.armature.armadura, self.positionFrames['rot'][r], Object.Pose.ROT,True)
29   -
30   - #bpy.context.object.rotation_mode = rot_mode
31   -
32   -class Mao(BasePose):
33   - def __init__(self,handParam,posFrames,armadura):
34   - self.parameters = handParam
35   - self.positionFrames = posFrames
36   - self.armature = armadura
37   -
38   - def genConf(self,default_pose,posFrames = None):
39   - if(posFrames != None):
40   - self.positionFrames = posFrames
41   - default_pose = default_pose
42   - self.setPose(default_pose)
43   -
44   - def genArtPoint(self,default_pose,posFrames = None):
45   - if(posFrames != None):
46   - self.positionFrames = posFrames
47   - default_pose = default_pose
48   - self.setPose(default_pose)
49   -
50   - def genOri(self,default_pose,posFrames = None):
51   - if(posFrames != None):
52   - self.positionFrames = posFrames
53   - default_pose = default_pose
54   - self.setPose(default_pose)
55   -
56   - def rotationCircular(self,center, radius, i_axis, j_axis, k_axis,pose, initialPosition, laps, frameJump = 5, initialFrame = 15, turn = None):
57   - const = radius * math.sqrt(2) / 2
58   - const1 = (radius/2)
59   - currentFrame = initialFrame
60   - for l in range(initialPosition, initialPosition + math.floor(8 * laps) + 1):
61   - if ((l % 8) == 0 ):
62   - pose.location[i_axis] = center[i_axis] + radius
63   - pose.location[j_axis] = center[j_axis]
64   - pose.location[k_axis] = center[k_axis]
65   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
66   - currentFrame += frameJump
67   - if ((l % 8) == 1):
68   - pose.location[i_axis] = center[i_axis] + const
69   - pose.location[j_axis] = center[j_axis] + const
70   - pose.location[k_axis] = center[k_axis]
71   - if(turn == 1):
72   - pose.location[i_axis] = center[i_axis] + const
73   - pose.location[j_axis] = center[j_axis] + const1
74   - pose.location[k_axis] = center[k_axis] - const1
75   - elif(turn == -1):
76   - pose.location[i_axis] = center[i_axis] + const
77   - pose.location[j_axis] = center[j_axis] + const1
78   - pose.location[k_axis] = center[k_axis] + const1
79   - pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location')
80   - currentFrame += frameJump
81   - if ((l % 8) == 2):
82   - pose.location[i_axis] = center[i_axis]
83   - pose.location[j_axis] = center[j_axis] + radius
84   - pose.location[k_axis] = center[k_axis]
85   - if(turn == 1):
86   - pose.location[j_axis] = center[j_axis] + const
87   - pose.location[k_axis] = center[k_axis] - const
88   - elif(turn == -1):
89   - pose.location[j_axis] = center[j_axis] + const
90   - pose.location[k_axis] = center[k_axis] + const
91   - pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location')
92   - currentFrame += frameJump
93   - if ((l % 8) == 3):
94   - pose.location[i_axis] = center[i_axis] - const
95   - pose.location[j_axis] = center[j_axis] + const
96   - pose.location[k_axis] = center[k_axis]
97   - if(turn == 1):
98   - pose.location[i_axis] = center[i_axis] - const
99   - pose.location[j_axis] = center[j_axis] + const1
100   - pose.location[k_axis] = center[k_axis] - const1
101   - elif(turn == -1):
102   - pose.location[i_axis] = center[i_axis] - const
103   - pose.location[j_axis] = center[j_axis] + const1
104   - pose.location[k_axis] = center[k_axis] + const1
105   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
106   - currentFrame += frameJump
107   -
108   - if ((l % 8) == 4):
109   - pose.location[i_axis] = center[i_axis] - radius
110   - pose.location[j_axis] = center[j_axis]
111   - pose.location[k_axis] = center[k_axis]
112   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
113   - currentFrame += frameJump
114   -
115   - if ((l % 8) == 5):
116   - pose.location[i_axis] = center[i_axis] - const
117   - pose.location[j_axis] = center[j_axis] - const
118   - pose.location[k_axis] = center[k_axis]
119   - if(turn == 1):
120   - pose.location[i_axis] = center[i_axis] - const
121   - pose.location[j_axis] = center[j_axis] - const1
122   - pose.location[k_axis] = center[k_axis] + const1
123   - elif(turn == -1):
124   - pose.location[i_axis] = center[i_axis] - const
125   - pose.location[j_axis] = center[j_axis] - const1
126   - pose.location[k_axis] = center[k_axis] - const1
127   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
128   - currentFrame += frameJump
129   -
130   - if ((l % 8) == 6):
131   - pose.location[i_axis] = center[i_axis]
132   - pose.location[j_axis] = center[j_axis] - radius
133   - pose.location[k_axis] = center[k_axis]
134   - if(turn == 1):
135   - pose.location[j_axis] = center[j_axis] - const
136   - pose.location[k_axis] = center[k_axis] + const
137   - elif(turn == -1):
138   - pose.location[j_axis] = center[j_axis] - const
139   - pose.location[k_axis] = center[k_axis] - const
140   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
141   - currentFrame += frameJump
142   -
143   - if ((l % 8) == 7):
144   - pose.location[i_axis] = center[i_axis] + const
145   - pose.location[j_axis] = center[j_axis] - const
146   - pose.location[k_axis] = center[k_axis]
147   - if(turn == 1):
148   - pose.location[i_axis] = center[i_axis] + const
149   - pose.location[j_axis] = center[j_axis] - const1
150   - pose.location[k_axis] = center[k_axis] + const1
151   - elif(turn == -1):
152   - pose.location[i_axis] = center[i_axis] + const
153   - pose.location[j_axis] = center[j_axis] - const1
154   - pose.location[k_axis] = center[k_axis] - const1
155   - pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location')
156   - currentFrame += frameJump
157   - currentFrame -= frameJump
158   - return currentFrame
159   -
160   - def genMov(self,pose,frames,calculos):
161   - for i in range(0, len(frames)):
162   - pose.location[:] = calculos[i][0], calculos[i][1], calculos[i][2]
163   - pose.keyframe_insert(data_path = 'location',frame = frames[i],index= -1)
164   -
165   -class MaoDireita(Mao):
166   - def __init__(self, handParam, posFrames, armadura):
167   - super(self.__class__, self).__init__(handParam,posFrames,armadura)
168   - self.genConf()
169   - self.genOri()
170   - self.genArtPoint()
171   -
172   - def genConf(self,posFrames = None,param = None):
173   - default_pose = LibConfigMaoDir.lib
174   - if(param != None):
175   - self.parameters = param
176   - super(self.__class__, self).genConf(default_pose,posFrames)
177   -
178   - def genOri(self,posFrames = None,param = None):
179   - default_pose = LibOrientacaoDir.lib
180   - if(param != None):
181   - self.parameters = param
182   - super(self.__class__, self).genOri(default_pose,posFrames)
183   -
184   - def genArtPoint(self,posFrames = None,param = None):
185   - default_pose = LibPontoArticulacaoDir.lib
186   - if(param != None):
187   - self.parameters = param
188   - super(self.__class__, self).genArtPoint(default_pose,posFrames)
189   -
190   -class MaoEsquerda(Mao):
191   - def __init__(self,handParam,posFrames,armadura):
192   - super(self.__class__,self).__init__(handParam,posFrames,armadura)
193   - self.genConf()
194   - self.genOri()
195   - self.genArtPoint()
196   -
197   - def genConf(self,posFrames = None,param = None):
198   - default_pose = LibConfigMaoEsq.lib
199   - if(param != None):
200   - self.parameters = param
201   - super(self.__class__, self).genConf(default_pose,posFrames)
202   -
203   - def genOri(self,posFrames = None,param = None):
204   - default_pose = LibOrientacaoEsq.lib
205   - if(param != None):
206   - self.parameters = param
207   - super(self.__class__, self).genOri(default_pose,posFrames)
208   -
209   - def genArtPoint(self, posFrames = None,param = None):
210   - default_pose = LibPontoArticulacaoEsq.lib
211   - if(param != None):
212   - self.parameters = param
213   - super(self.__class__, self).genArtPoint(default_pose,posFrames)
214   -
215   -class Face(BasePose):
216   - def __init__(self,faceParam, armadura, endFram):
217   - self.parameters = ("Exp_9", faceParam, "Exp_9")
218   - self.armature = armadura
219   - self.endFrame = endFram
220   - self.genFace()
221   -
222   - def genFace(self):
223   - default_pose = LibExpFacial.lib
224   - self.setPose(default_pose)
225   -
226   - def setPose(self,default_pose):
227   - for h in range(0,len(self.parameters)):
228   - for cfg in default_pose:
229   - if cfg['name'] == self.parameters[h]:
230   - for bone in cfg['bones']:
231   - pose_bone = self.armature.pose.bones[bone['name']]
232   - pose_bone.location = bone['loc']
233   - pose_bone.keyframe_insert(data_path = 'location',frame = h*(self.endFrame/2) + 1 + h*3, index = -1)
234   - pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2])
235   - pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion()
236   - pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = h*(self.endFrame/2) + 1, index = -1)
237   -
238   -class Pose(BasePose):
239   - parameters = ["Pose_1", "Pose_2"]
240   - def __init__ (self, posFrames, armadura):
241   - self.armature = armadura
242   - self.positionFrames = posFrames
243   - self.genPose()
244   -
245   - def genPose(self):
246   - default_pose = LibPosePadrao.lib
247   - self.setPose(default_pose)
libras.py
... ... @@ -13,15 +13,14 @@ import bpy
13 13 import json
14 14  
15 15 # importa modulos locais
16   -import objects
17 16 import util
18 17 import moves
19   -
  18 +'''
20 19 # verifica a quantidade de argumentos recebidos
21 20 if (len(sys.argv) != 6):
22 21 print ("WikiLibras: Invalid number of arguments")
23 22 exit(1)
24   -
  23 +'''
25 24 # tenta decodificar o argumento JSON recebido
26 25 try:
27 26 json_input = json.loads(sys.argv[5])
... ... @@ -56,7 +55,7 @@ def setPose(actions, parametesConf, positionFrames, bones):
56 55  
57 56 # Função responsável por setar pose padrão
58 57 def poseDefault(positionFrames, bones):
59   - setPose([2], [0], positionFrames, bones)
  58 + setPose([0], [0], positionFrames, bones)
60 59  
61 60 # Função responsável por setar as configuraçẽs das mãos
62 61 def generationConfigurations(actions, handParam, positionFrames, bones):
... ... @@ -103,7 +102,7 @@ def configureHands():
103 102 iks = ['ik_FK.R', 'ik_FK.L']
104 103 bones_ = [util.rightBonesConf, util.leftBonesConf]
105 104 #Array com as actions FAKES que seram selecionadas no Blender para cada lado do corpo
106   - actions = [[0, 3, 5], [1, 4, 6]]
  105 + actions = [[1, 3, 5], [2, 4, 6]]
107 106 global endFrame
108 107 for i in range(len(hands)):
109 108 if(json_input[hands[i]] != []):
... ... @@ -126,8 +125,8 @@ def configureFace():
126 125 # Set face
127 126 faceConfiguration(json_input["facialExp"], [endFrame/2], util.faceBonesConf)
128 127  
129   -#configureHands()
130   -#configureFace()
  128 +configureHands()
  129 +configureFace()
131 130  
132 131 # Default Pose
133 132 poseDefault([0, endFrame+15], util.allBones)
... ...
librasteste.py
... ... @@ -1,80 +0,0 @@
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)
... ... @@ -1,234 +0,0 @@
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)
objects.py
... ... @@ -1,236 +0,0 @@
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)