From 29821cc0a522f5122a9ffe594aacd9c9351de7f5 Mon Sep 17 00:00:00 2001 From: FrancoNeto Date: Thu, 12 Feb 2015 09:39:52 -0200 Subject: [PATCH] Corrige parâmetros das libs em (Libras.py) e adiciona libs no avatar --- .gitignore | 1 - .gitignore.swp | Bin 0 -> 12288 bytes NewFormat_Json | 6 ------ avatar_Hozana_wikiLibras.blend | Bin 11765616 -> 0 bytes inicial.txt | 1 - lbsObjects.py | 247 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- libras.py | 13 ++++++------- librasteste.py | 80 -------------------------------------------------------------------------------- objects | 234 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ objects.py | 236 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 10 files changed, 6 insertions(+), 812 deletions(-) create mode 100644 .gitignore.swp delete mode 100644 NewFormat_Json delete mode 100644 inicial.txt delete mode 100644 lbsObjects.py delete mode 100644 librasteste.py delete mode 100644 objects delete mode 100644 objects.py diff --git a/.gitignore b/.gitignore index d7feb0e..7ab5fc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *~ *.avi -*.blend *.blend1 *.mp4 *.pyc diff --git a/.gitignore.swp b/.gitignore.swp new file mode 100644 index 0000000..3e48ae7 Binary files /dev/null and b/.gitignore.swp differ diff --git a/NewFormat_Json b/NewFormat_Json deleted file mode 100644 index 9bb0828..0000000 --- a/NewFormat_Json +++ /dev/null @@ -1,6 +0,0 @@ - '{"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"}' - - '{"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"}' - - - '{"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"}' diff --git a/avatar_Hozana_wikiLibras.blend b/avatar_Hozana_wikiLibras.blend index fa9255d..a0c5e0b 100644 Binary files a/avatar_Hozana_wikiLibras.blend and b/avatar_Hozana_wikiLibras.blend differ diff --git a/inicial.txt b/inicial.txt deleted file mode 100644 index 89b3598..0000000 --- a/inicial.txt +++ /dev/null @@ -1 +0,0 @@ -Repositorio wikilibras-core Criado diff --git a/lbsObjects.py b/lbsObjects.py deleted file mode 100644 index 250960c..0000000 --- a/lbsObjects.py +++ /dev/null @@ -1,247 +0,0 @@ -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, default_pose): - for cfg in default_pose: - if cfg['name'] in self.parameters: - for bone in cfg['bones']: - pose_bone = self.armature.pose.bones[bone['name']] # pose_bone = self.armature.armadura.pose.bones[bone['name']] - pose_bone.location = bone['loc'] - for l in range(0,len(self.positionFrames['loc'])): - pose_bone.keyframe_insert(data_path = 'location',frame = self.positionFrames['loc'][l], 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() - for r in range(0,len(self.positionFrames['rot'])): - pose_bone.keyframe_insert(data_path ='rotation_quaternion',frame = self.positionFrames['rot'][r], index = -1) - # pose_bone.insertKey(self.armature.armadura, self.positionFrames['rot'][r], Object.Pose.ROT,True) - - #bpy.context.object.rotation_mode = rot_mode - -class Mao(BasePose): - def __init__(self,handParam,posFrames,armadura): - self.parameters = handParam - self.positionFrames = posFrames - self.armature = armadura - - def genConf(self,default_pose,posFrames = None): - if(posFrames != None): - self.positionFrames = posFrames - default_pose = default_pose - self.setPose(default_pose) - - def genArtPoint(self,default_pose,posFrames = None): - if(posFrames != None): - self.positionFrames = posFrames - default_pose = default_pose - self.setPose(default_pose) - - def genOri(self,default_pose,posFrames = None): - if(posFrames != None): - self.positionFrames = posFrames - default_pose = default_pose - self.setPose(default_pose) - - 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): - default_pose = LibConfigMaoDir.lib - if(param != None): - self.parameters = param - super(self.__class__, self).genConf(default_pose,posFrames) - - def genOri(self,posFrames = None,param = None): - default_pose = LibOrientacaoDir.lib - if(param != None): - self.parameters = param - super(self.__class__, self).genOri(default_pose,posFrames) - - def genArtPoint(self,posFrames = None,param = None): - default_pose = LibPontoArticulacaoDir.lib - if(param != None): - self.parameters = param - super(self.__class__, self).genArtPoint(default_pose,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): - parameters = ["Pose_1", "Pose_2"] - def __init__ (self, posFrames, armadura): - self.armature = armadura - self.positionFrames = posFrames - self.genPose() - - def genPose(self): - default_pose = LibPosePadrao.lib - self.setPose(default_pose) diff --git a/libras.py b/libras.py index 08e9652..c62c882 100644 --- a/libras.py +++ b/libras.py @@ -13,15 +13,14 @@ import bpy import json # importa modulos locais -import objects import util import moves - +''' # verifica a quantidade de argumentos recebidos if (len(sys.argv) != 6): print ("WikiLibras: Invalid number of arguments") exit(1) - +''' # tenta decodificar o argumento JSON recebido try: json_input = json.loads(sys.argv[5]) @@ -56,7 +55,7 @@ def setPose(actions, parametesConf, positionFrames, bones): # Função responsável por setar pose padrão def poseDefault(positionFrames, bones): - setPose([2], [0], positionFrames, bones) + setPose([0], [0], positionFrames, bones) # Função responsável por setar as configuraçẽs das mãos def generationConfigurations(actions, handParam, positionFrames, bones): @@ -103,7 +102,7 @@ def configureHands(): iks = ['ik_FK.R', 'ik_FK.L'] bones_ = [util.rightBonesConf, util.leftBonesConf] #Array com as actions FAKES que seram selecionadas no Blender para cada lado do corpo - actions = [[0, 3, 5], [1, 4, 6]] + actions = [[1, 3, 5], [2, 4, 6]] global endFrame for i in range(len(hands)): if(json_input[hands[i]] != []): @@ -126,8 +125,8 @@ def configureFace(): # Set face faceConfiguration(json_input["facialExp"], [endFrame/2], util.faceBonesConf) -#configureHands() -#configureFace() +configureHands() +configureFace() # Default Pose poseDefault([0, endFrame+15], util.allBones) diff --git a/librasteste.py b/librasteste.py deleted file mode 100644 index fce5543..0000000 --- a/librasteste.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- 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 deleted file mode 100644 index fc63278..0000000 --- a/objects +++ /dev/null @@ -1,234 +0,0 @@ -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 deleted file mode 100644 index f45acdb..0000000 --- a/objects.py +++ /dev/null @@ -1,236 +0,0 @@ -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