From f572e5c2b12bb2f3fbffcdba76a811f2f057041f Mon Sep 17 00:00:00 2001 From: gtaaas Date: Fri, 19 Dec 2014 14:46:00 -0300 Subject: [PATCH] Modificações no Avatar e no Script --- avatar_Hozana_wikiLibras.blend | Bin 11569144 -> 0 bytes libras.py | 2 +- librasteste.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ objects | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ objects.py | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 librasteste.py create mode 100644 objects create mode 100644 objects.py diff --git a/avatar_Hozana_wikiLibras.blend b/avatar_Hozana_wikiLibras.blend index 363553b..c7be0ff 100644 Binary files a/avatar_Hozana_wikiLibras.blend and b/avatar_Hozana_wikiLibras.blend differ diff --git a/libras.py b/libras.py index d56b4e8..da08884 100644 --- a/libras.py +++ b/libras.py @@ -72,7 +72,7 @@ if(json_input["leftHand"] != []): if(json_input["facialExp"] != []): #confFace - lbsObjects.Face(json_input["facialExp"], armature, endFrame) # Set face + lbsObjects.Face(json_input["facialExp"], armature, int(endFrame/1.5)) # Set face #confPoseEnd lbsObjects.Pose({'loc':[1,endFrame+20],'rot':[1,endFrame+20]},armature) # Set the final pose diff --git a/librasteste.py b/librasteste.py new file mode 100644 index 0000000..fce5543 --- /dev/null +++ b/librasteste.py @@ -0,0 +1,80 @@ +# -*- coding: UTF-8 -*- +import sys +sys.path.append('/home/gtaaas/wikilibras/wikilibras-core') +import json +import objects +import util + + +def circular_or_semiCircular(hand,pose,orientation,direction,radius,laps,intensity = 5,initialFrame = 15): + center = pose.location.x,pose.location.y,pose.location.z + if(orientation == 'perpendicular'): + if(direction == 'horario'): + endFrame = hand.rotationCircular(center,radius,1,0,2,pose,0,laps,intensity,initialFrame) + else: + endFrame = hand.rotationCircular(center,radius,0,1,2,pose,0,laps,intensity,initialFrame) + elif(orientation == 'paralelo'): + if(direction == 'horario'): + endFrame = hand.rotationCircular(center,radius,1,2,0,pose,0,laps,intensity,initialFrame) + else: + endFrame = hand.rotationCircular(center,radius,2,1,0,pose,0,laps,intensity,initialFrame) + return endFrame + +def get_endFrame(json_input): + endsFrame = [] + if(json_input["rightHand"][0] == "circular" or json_input["rightHand"][0] == "semicircular"): + endsFrame.append(int(json_input["rightHand"][4]*8*5+15)) + if(json_input["leftHand"][0] == "circular" or json_input["leftHand"][0] == "semicircular"): + endsFrame.append(int(json_input["leftHand"][4]*8*5+15)) + return(max(endsFrame)) + +#Configurações gerais +json_input = json.loads(sys.argv[5]) # Load jason +util.outconf() +handPosFrame = [15,18] +armature = objects.Armadura('Armature.001') +initialFrame,endFrame = 15,25 + +#Initial Pose +objects.Pose([0], armature) #Set the default pose + +#ConfHandRight +if(json_input["rightHand"] != []): + movRight = json_input["rightHand"][0] + pose = armature.pose.bones['ik_FK.R'] + if(movRight == "pontual"): + handRight = objects.MaoDireita(json_input["rightHand"][-3:],[15,endFrame], armature) + else: + handRight = objects.MaoDireita(json_input["rightHand"][-3:],handPosFrame, armature) + if(movRight == "circular" or movRight == "semicircular"): + orientation,direction,radius,laps = json_input["rightHand"][1:5] + endFrame = circular_or_semiCircular(handRight,pose,orientation,direction,radius,laps,5) + handRight.genConf({'loc':[endFrame],'rot':[endFrame]}) + handRight.genOri({'loc':[endFrame],'rot':[endFrame]}) + elif(json_input["rightHand"][0] == "retilineo"): + pass + +#ConfLeftRight +if(json_input["leftHand"] != []): + movLeft = json_input["leftHand"][0] + pose = armature.pose.bones['ik_FK.L'] + if(movLeft == "pontual"): + handLeft = objects.MaoEsquerda(json_input["leftHand"][-3:],[15,endFrame], armature) + else: + handLeft = objects.MaoEsquerda(json_input["leftHand"][-3:], handPosFrame, armature) + if(movLeft == "circular" or movLeft == "semicircular"): + orientation,direction,radius,laps = json_input["leftHand"][1:5] + endFrame = circular_or_semiCircular(handRight,pose,orientation,direction,radius,laps,5) + handLeft.genConf({'loc':[endFrame],'rot':[endFrame]}) + handLeft.genOri({'loc':[endFrame],'rot':[endFrame]}) + elif(json_input["leftHand"][0] == "retilineo"): + pass + +if(json_input["facialExp"] != []): + #confFace + objects.Face(json_input["facialExp"], armature, int(endFrame/1.5)) # Set face + +#confPoseEnd +objects.Pose([endFrame+20],armature) # Set the final pose + +util.render_sign(json_input["userId"],json_input["signName"],1,endFrame + 20) diff --git a/objects b/objects new file mode 100644 index 0000000..fc63278 --- /dev/null +++ b/objects @@ -0,0 +1,234 @@ +import bpy # import Blender +import math +# from Blender.Scene import Render + +from Libs.Libs_py import * +from Libs.Libs_py import LibPosePadrao, LibConfigMaoDir, LibPontoArticulacaoDir, LibOrientacaoDir, LibConfigMaoEsq, LibPontoArticulacaoEsq, LibOrientacaoEsq, LibExpFacial + +class Armadura: + def __init__(self,nameArmature): + self.armadura = bpy.context.scene.objects.get(nameArmature) # bpy.data.objects['Armature.001'] # bpy.context.object # self.armadura = Blender.Object.Get(nameArmature) + self.pose = self.armadura.pose # self.armadura.getPose() + self.act = bpy.context.scene.animation_data_create() #self.act = Armature.NLA.NewAction(nameAction) + # bpy.context.scene.objects.active = self.armadura # self.act.setActive(self.armadura) + +class BasePose (object): + def setPose(self,groupIndex,actionIndex,poseLibIndex): + bpy.ops.object.mode_set(mode = 'POSE') + armadura.pose_library = bpy.data.actions[actionIndex] + bpy.ops.poselib.apply_pose(pose_index= poseLibIndex) + bpy.context.object.pose.bone_groups.active_index = groupIndex + bpy.ops.pose.group_select() + for x in range(0,len(self.positionFrames)): + bpy.context.scene.frame_set(self.positionFrames[x]) + bpy.ops.anim.keyframe_insert_menu(type = 'BUILTIN_KSI_LocRot') + +class Mao(BasePose): + def __init__(self,handParam,posFrames,armadura): + self.parameters = handParam + self.positionFrames = posFrames + self.armature = armadura + + def genConf(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose(groupIndex,actionIndex,poseLibIndex) + + def genArtPoint(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose() + + def genOri(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose() + + def rotationCircular(self,center, radius, i_axis, j_axis, k_axis,pose, initialPosition, laps, frameJump = 5, initialFrame = 15, turn = None): + const = radius * math.sqrt(2) / 2 + const1 = (radius/2) + currentFrame = initialFrame + for l in range(initialPosition, initialPosition + math.floor(8 * laps) + 1): + if ((l % 8) == 0 ): + pose.location[i_axis] = center[i_axis] + radius + pose.location[j_axis] = center[j_axis] + pose.location[k_axis] = center[k_axis] + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] - const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] + const1 + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 2): + pose.location[i_axis] = center[i_axis] + pose.location[j_axis] = center[j_axis] + radius + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] - const + elif(turn == -1): + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + const + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 3): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] - const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] + const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 4): + pose.location[i_axis] = center[i_axis] - radius + pose.location[j_axis] = center[j_axis] + pose.location[k_axis] = center[k_axis] + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 5): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] + const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] - const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 6): + pose.location[i_axis] = center[i_axis] + pose.location[j_axis] = center[j_axis] - radius + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + const + elif(turn == -1): + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] - const + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 7): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] + const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] - const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + currentFrame -= frameJump + return currentFrame + + def genMov(self,pose,frames,calculos): + for i in range(0, len(frames)): + pose.location[:] = calculos[i][0], calculos[i][1], calculos[i][2] + pose.keyframe_insert(data_path = 'location',frame = frames[i],index= -1) + +class MaoDireita(Mao): + def __init__(self, handParam, posFrames, armadura): + super(self.__class__, self).__init__(handParam,posFrames,armadura) + self.genConf() + self.genOri() + self.genArtPoint() + + def genConf(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genConf(5,0,handParam[0],posFrames) + + + def genOri(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genOri(5,2,handParam[1],posFrames) + + def genArtPoint(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genArtPoint(5,4,handParam[2],posFrames) + +class MaoEsquerda(Mao): + def __init__(self,handParam,posFrames,armadura): + super(self.__class__,self).__init__(handParam,posFrames,armadura) + self.genConf() + self.genOri() + self.genArtPoint() + + def genConf(self,posFrames = None,param = None): + default_pose = LibConfigMaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genConf(default_pose,posFrames) + + def genOri(self,posFrames = None,param = None): + default_pose = LibOrientacaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genOri(default_pose,posFrames) + + def genArtPoint(self, posFrames = None,param = None): + default_pose = LibPontoArticulacaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genArtPoint(default_pose,posFrames) + +class Face(BasePose): + def __init__(self,faceParam, armadura, endFram): + self.parameters = ("Exp_9", faceParam, "Exp_9") + self.armature = armadura + self.endFrame = endFram + self.genFace() + + def genFace(self): + default_pose = LibExpFacial.lib + self.setPose(default_pose) + + def setPose(self,default_pose): + for h in range(0,len(self.parameters)): + for cfg in default_pose: + if cfg['name'] == self.parameters[h]: + for bone in cfg['bones']: + pose_bone = self.armature.pose.bones[bone['name']] + pose_bone.location = bone['loc'] + pose_bone.keyframe_insert(data_path = 'location',frame = h*(self.endFrame/2) + 1 + h*3, index = -1) + pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2]) + pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion() + pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = h*(self.endFrame/2) + 1, index = -1) + +class Pose(BasePose): + def __init__ (self, posFrames, armadura): + self.armature = armadura + self.positionFrames = posFrames + self.genPose()0 + + def genPose(self): + self.setPose(8,8,0) diff --git a/objects.py b/objects.py new file mode 100644 index 0000000..f45acdb --- /dev/null +++ b/objects.py @@ -0,0 +1,236 @@ +import bpy # import Blender +import math +# from Blender.Scene import Render + +from Libs.Libs_py import * +from Libs.Libs_py import LibPosePadrao, LibConfigMaoDir, LibPontoArticulacaoDir, LibOrientacaoDir, LibConfigMaoEsq, LibPontoArticulacaoEsq, LibOrientacaoEsq, LibExpFacial + +class Armadura: + def __init__(self,nameArmature): + self.armadura = bpy.context.scene.objects.get(nameArmature) # bpy.data.objects['Armature.001'] # bpy.context.object # self.armadura = Blender.Object.Get(nameArmature) + self.pose = self.armadura.pose # self.armadura.getPose() + self.act = bpy.context.scene.animation_data_create() #self.act = Armature.NLA.NewAction(nameAction) + # bpy.context.scene.objects.active = self.armadura # self.act.setActive(self.armadura) + +class BasePose (object): + def setPose(self,groupIndex,actionIndex,poseLibIndex): + bpy.ops.object.mode_set(mode = 'POSE') + self.armature.pose_library = bpy.data.actions[actionIndex] + bpy.ops.poselib.apply_pose(pose_index= poseLibIndex) + bpy.context.object.pose.bone_groups.active_index = groupIndex + bpy.ops.pose.group_select() + for x in range(0,len(self.positionFrames)): + bpy.context.scene.frame_set(self.positionFrames[x]) + bpy.ops.anim.keyframe_insert_menu(type = 'BUILTIN_KSI_LocRot') + bpy.ops.pose.group_deselect() + + +class Mao(BasePose): + def __init__(self,handParam,posFrames,armadura): + self.parameters = handParam + self.positionFrames = posFrames + self.armature = armadura + + def genConf(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose(groupIndex,actionIndex,poseLibIndex) + + def genArtPoint(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose() + + def genOri(self,groupIndex,actionIndex,poseLibIndex,posFrames = None): + if(posFrames != None): + self.positionFrames = posFrames + self.setPose() + + def rotationCircular(self,center, radius, i_axis, j_axis, k_axis,pose, initialPosition, laps, frameJump = 5, initialFrame = 15, turn = None): + const = radius * math.sqrt(2) / 2 + const1 = (radius/2) + currentFrame = initialFrame + for l in range(initialPosition, initialPosition + math.floor(8 * laps) + 1): + if ((l % 8) == 0 ): + pose.location[i_axis] = center[i_axis] + radius + pose.location[j_axis] = center[j_axis] + pose.location[k_axis] = center[k_axis] + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] - const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] + const1 + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 2): + pose.location[i_axis] = center[i_axis] + pose.location[j_axis] = center[j_axis] + radius + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] - const + elif(turn == -1): + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + const + pose.keyframe_insert(frame = initialPosition, index = -1, data_path = 'location') + currentFrame += frameJump + if ((l % 8) == 3): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] - const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] + const1 + pose.location[k_axis] = center[k_axis] + const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 4): + pose.location[i_axis] = center[i_axis] - radius + pose.location[j_axis] = center[j_axis] + pose.location[k_axis] = center[k_axis] + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 5): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] + const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] - const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] - const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 6): + pose.location[i_axis] = center[i_axis] + pose.location[j_axis] = center[j_axis] - radius + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + const + elif(turn == -1): + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] - const + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + + if ((l % 8) == 7): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const + pose.location[k_axis] = center[k_axis] + if(turn == 1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] + const1 + elif(turn == -1): + pose.location[i_axis] = center[i_axis] + const + pose.location[j_axis] = center[j_axis] - const1 + pose.location[k_axis] = center[k_axis] - const1 + pose.keyframe_insert(frame = currentFrame, index = -1, data_path = 'location') + currentFrame += frameJump + currentFrame -= frameJump + return currentFrame + + def genMov(self,pose,frames,calculos): + for i in range(0, len(frames)): + pose.location[:] = calculos[i][0], calculos[i][1], calculos[i][2] + pose.keyframe_insert(data_path = 'location',frame = frames[i],index= -1) + +class MaoDireita(Mao): + def __init__(self, handParam, posFrames, armadura): + super(self.__class__, self).__init__(handParam,posFrames,armadura) + self.genConf() + self.genOri() + self.genArtPoint() + + def genConf(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genConf(5,0,handParam[0],posFrames) + + + def genOri(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genOri(5,2,handParam[1],posFrames) + + def genArtPoint(self,posFrames = None,param = None): + if(param != None): + self.parameters = param + super(self.__class__, self).genArtPoint(5,4,handParam[2],posFrames) + +class MaoEsquerda(Mao): + def __init__(self,handParam,posFrames,armadura): + super(self.__class__,self).__init__(handParam,posFrames,armadura) + self.genConf() + self.genOri() + self.genArtPoint() + + def genConf(self,posFrames = None,param = None): + default_pose = LibConfigMaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genConf(default_pose,posFrames) + + def genOri(self,posFrames = None,param = None): + default_pose = LibOrientacaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genOri(default_pose,posFrames) + + def genArtPoint(self, posFrames = None,param = None): + default_pose = LibPontoArticulacaoEsq.lib + if(param != None): + self.parameters = param + super(self.__class__, self).genArtPoint(default_pose,posFrames) + +class Face(BasePose): + def __init__(self,faceParam, armadura, endFram): + self.parameters = ("Exp_9", faceParam, "Exp_9") + self.armature = armadura + self.endFrame = endFram + self.genFace() + + def genFace(self): + default_pose = LibExpFacial.lib + self.setPose(default_pose) + + def setPose(self,default_pose): + for h in range(0,len(self.parameters)): + for cfg in default_pose: + if cfg['name'] == self.parameters[h]: + for bone in cfg['bones']: + pose_bone = self.armature.pose.bones[bone['name']] + pose_bone.location = bone['loc'] + pose_bone.keyframe_insert(data_path = 'location',frame = h*(self.endFrame/2) + 1 + h*3, index = -1) + pose_bone.rotation_euler = math.radians(bone['rot'][0]),math.radians(bone['rot'][1]),math.radians(bone['rot'][2]) + pose_bone.rotation_quaternion = pose_bone.rotation_euler.to_quaternion() + pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = h*(self.endFrame/2) + 1, index = -1) + +class Pose(BasePose): + def __init__ (self, posFrames, armadura): + self.armature = armadura + self.positionFrames = posFrames + self.genPose() + + def genPose(self): + self.setPose(8,8,0) -- libgit2 0.21.2