#-------------------------------------------------------------------------------
# Name: YJ_CreatBone
# Purpose:
#
# Author: CreateBone
#
# Created: 25/06/2014
# Copyright: (c) yangjie 2014
# Licence: <your licence>
#-------------------------------------------------------------------------------
from maya.cmds import*
from YJ_NameTool import*
from YJ_Rig_Pub import*
from YJ_Create_Body_Rig_UI_p import*
from YJ_Ctrl_Colour import*
##YJ_Creat_Leg_Bone(1,'xyz','zup',0.1)
##
##
##
def YJ_CreateBone_All():
Neck_CB_V,Arm_CB_V,Finger_CB_V,Leg_CB_V,Type,Bone_Rad,Spine_Jnt_seg,Neck_Jnt_seg,Finger_Jnt_Nub,Finger_Jnt_seg = YJ_GetBodyRig_Attr()
AttrValueList = [Neck_CB_V,Arm_CB_V,Finger_CB_V,Leg_CB_V,Type,Bone_Rad,Spine_Jnt_seg,Neck_Jnt_seg,Finger_Jnt_Nub,Finger_Jnt_seg]
YJ_Save_List(AttrValueList,'AttrValueList.pkl')
orientJoint,SecAO = 'xyz','zup'
YJ_Creat_Ctrl('Cur5','all_anim_F')
#
L_LegJnt_List,R_LegJnt_List, Leg_ExpLis = YJ_Judge_Create_for_Leg(Leg_CB_V,Type,orientJoint,SecAO,Bone_Rad)
YJ_Save_List(L_LegJnt_List,'L_LegJnt_List.pkl')
#
L_FootJnt_List,L_Help_FootJnt_List,L_toeJnt_List,R_FootJnt_List, Foot_ExpLis = YJ_Judge_Create_for_Foot(Leg_CB_V,Type,orientJoint,SecAO,Bone_Rad)
YJ_Save_List(L_FootJnt_List,'L_FootJnt_List.pkl')
YJ_Save_List(L_Help_FootJnt_List,'L_Help_FootJnt_List.pkl')
YJ_Save_List(L_toeJnt_List,'L_toeJnt_List.pkl')
#
Hip_Jnt_List,Spine_Jnt_List = YJ_Creat_Spine_Bone(Type,"spine_@_jnt",orientJoint,SecAO,Spine_Jnt_seg,Bone_Rad)
YJ_Save_List(Hip_Jnt_List,'Hip_Jnt_List.pkl')
YJ_Save_List(Spine_Jnt_List,'Spine_Jnt_List.pkl')
#
Neck_Jnt_List = YJ_Judge_Create_for_Neck(Neck_CB_V,Type,orientJoint,SecAO,Neck_Jnt_seg,Bone_Rad)
YJ_Save_List(Neck_Jnt_List,'Neck_Jnt_List.pkl')
#
L_Shloud_Jnt_List,R_Shloud_Jnt_List, Should_ExpLis = YJ_Judge_Create_for_Should(Arm_CB_V,Type,orientJoint,SecAO,Bone_Rad)
YJ_Save_List(L_Shloud_Jnt_List,'L_Shloud_Jnt_List.pkl')
#
L_Arm_Jnt_List,R_Arm_Jnt_List, Arm_Explis = YJ_Judge_Create_for_Arm(Arm_CB_V,Type,orientJoint,SecAO,Bone_Rad)
YJ_Save_List(L_Arm_Jnt_List,'L_Arm_Jnt_List.pkl')
#
Hand_Help_Jnt_L,L_FingerAllList_Lis, L_FingerAll_List,R_FingerAll_List ,Finger_Explis = YJ_Judge_Create_for_fingers(Finger_CB_V,Finger_Jnt_Nub,Type,orientJoint,SecAO,Finger_Jnt_seg,Bone_Rad)
YJ_Save_List(Hand_Help_Jnt_L,'Hand_Help_Jnt_L.pkl')
YJ_Save_List(L_FingerAllList_Lis,'L_FingerAllList_Lis.pkl')
#
AllJntsListLis = [L_LegJnt_List]+[R_LegJnt_List]+[L_FootJnt_List]+[R_FootJnt_List]+[Hip_Jnt_List]+[Spine_Jnt_List]+[Neck_Jnt_List]+[L_Shloud_Jnt_List]+[R_Shloud_Jnt_List]+[L_Arm_Jnt_List]+[R_Arm_Jnt_List]+[L_FingerAll_List]+[R_FingerAll_List]
#
NewAllJntsListLis = YJ_resetList_RemoveEmp(AllJntsListLis)
#
YJ_SetParentStarJntsToAllAnim(NewAllJntsListLis,'all_anim_F')
#
#
#
def YJ_SetParentStarJntsToAllAnim(JntsList_Lis,Anim):
for i in JntsList_Lis:
YJ_Try_Parent(i[0],Anim)
#
def YJ_Judge_Create_for_Hand(Arm_CB_V,Type,orientJoint,SecAO,Bone_Rad):
if Arm_CB_V == 0:
L_Hand_Jnt_List = YJ_Creat_Hand_Bone(Type,orientJoint,SecAO,Bone_Rad)
R_Hand_Jnt_List = YJ_MirJoint(L_Hand_Jnt_List)
Hand_Explis = YJ_createMirrorExpression(L_Hand_Jnt_List,R_Hand_Jnt_List)
elif Arm_CB_V == 1:
L_Hand_Jnt_List,R_Hand_Jnt_List, Hand_Explis = [],[],[]
return L_Hand_Jnt_List,R_Hand_Jnt_List, Hand_Explis
#
def YJ_Judge_Create_for_Arm(Arm_CB_V,Type,orientJoint,SecAO,Bone_Rad):
if Arm_CB_V == 0:
L_Arm_Jnt_List = YJ_Creat_Arm_Bone(Type,orientJoint,SecAO,Bone_Rad)
R_Arm_Jnt_List = YJ_MirJoint(L_Arm_Jnt_List)
Arm_Explis = YJ_createMirrorExpression(L_Arm_Jnt_List,R_Arm_Jnt_List)
elif Arm_CB_V == 1:
L_Arm_Jnt_List,R_Arm_Jnt_List, Arm_Explis = [],[],[]
return L_Arm_Jnt_List,R_Arm_Jnt_List, Arm_Explis
#
def YJ_Judge_Create_for_Should(Arm_CB_V,Type,orientJoint,SecAO,Bone_Rad):
if Arm_CB_V == 0:
L_Shloud_Jnt_List = YJ_Creat_Should_Bone(Type,orientJoint,SecAO,Bone_Rad)
R_Shloud_Jnt_List = YJ_MirJoint(L_Shloud_Jnt_List)
Should_ExpLis = YJ_createMirrorExpression(L_Shloud_Jnt_List,R_Shloud_Jnt_List)
elif Arm_CB_V == 1:
L_Shloud_Jnt_List,R_Shloud_Jnt_List, Should_ExpLis = [],[],[]
return L_Shloud_Jnt_List,R_Shloud_Jnt_List, Should_ExpLis
#
#
def YJ_Judge_Create_for_Neck(Neck_CB_V,Type,orientJoint,SecAO,Neck_Jnt_seg,Bone_Rad):
if Neck_CB_V == 0:
Neck_Jnt_List = YJ_Creat_Neck_Bone(Type,"neck_@_jnt",orientJoint,SecAO,Neck_Jnt_seg,Bone_Rad)
elif Neck_CB_V == 1:
Neck_Jnt_List = []
return Neck_Jnt_List
#
def YJ_Judge_Create_for_Foot(Leg_CB_V,Type,orientJoint,SecAO,Bone_Rad):
if Leg_CB_V == 0:
L_FootJnt_List,L_Help_FootJnt_List,L_toeJnt_List = YJ_Creat_Foot_Bone(Type,orientJoint,SecAO,Bone_Rad)
R_FootJnt_List = YJ_MirJoint(L_FootJnt_List)
Foot_ExpLis = YJ_createMirrorExpression(L_FootJnt_List,R_FootJnt_List)
elif Leg_CB_V == 1:
L_FootJnt_List,R_FootJnt_List, Foot_ExpLis = [],[],[]
return L_FootJnt_List,L_Help_FootJnt_List,L_toeJnt_List,R_FootJnt_List, Foot_ExpLis
#
def YJ_Judge_Create_for_Leg(Leg_CB_V,Type,orientJoint,SecAO,Bone_Rad):
if Leg_CB_V == 0:
L_LegJnt_List = YJ_Creat_Leg_Bone(Type,orientJoint,SecAO,Bone_Rad)
R_LegJnt_List = YJ_MirJoint(L_LegJnt_List)
Leg_ExpLis =YJ_createMirrorExpression(L_LegJnt_List,R_LegJnt_List)
elif Leg_CB_V == 1:
L_LegJnt_List,R_LegJnt_List,Leg_ExpLis= [],[],[]
return L_LegJnt_List,R_LegJnt_List, Leg_ExpLis
#
def YJ_Judge_Create_for_fingers(Finger_CB_V,Finger_Jnt_Nub,Type,orientJoint,SecAO,Finger_Jnt_seg,Bone_Rad):
if Finger_CB_V == 0:
Hand_Help_Jnt_L,L_FingerAllList_Lis =YJ_Create_Finger_Bone(Finger_Jnt_Nub,Type,orientJoint,SecAO,Finger_Jnt_seg,Bone_Rad,'L_Thumb_@_jnt','L_Index_@_jnt')
R_FingerAll_List = YJ_MirJoint(Hand_Help_Jnt_L)
L_FingerAll_List = YJ_GetMir_List(R_FingerAll_List)
Finger_Explis = YJ_createMirrorExpression(L_FingerAll_List,R_FingerAll_List)
elif Finger_CB_V == 1:
Hand_Help_Jnt_L,L_FingerAllList_Lis = [],[]
R_FingerAll_List = []
L_FingerAll_List = []
Finger_Explis = []
return Hand_Help_Jnt_L,L_FingerAllList_Lis, L_FingerAll_List,R_FingerAll_List ,Finger_Explis
#
def YJ_GetBodyRig_Attr():
Neck_CB_V = checkBox('Neck_CB',q=1,v=1)
Arm_CB_V = checkBox('Arm_CB',q=1,v=1)
Finger_CB_V = checkBox('Finger_CB',q=1,v=1)
Leg_CB_V = checkBox('Leg_CB',q=1,v=1)
Type = optionMenuGrp('Chr_Choose_OPMG',q=1,sl=1)
Bone_Rad = float(textField( 'Bone_Rad_tf',q=1,tx=1) )
Spine_Jnt_seg = int(intFieldGrp('SpineSegIFG' ,q=1,v=1)[0])
Neck_Jnt_seg = int(intFieldGrp('NeckSegIFG' ,q=1,v=1)[0])
Finger_Jnt_Nub = int(intFieldGrp('FingerNubIFG' ,q=1,v=1)[0])
Finger_Jnt_seg = int(intFieldGrp('FingerSegIFG' ,q=1,v=1)[0])
return Neck_CB_V,Arm_CB_V,Finger_CB_V,Leg_CB_V,Type,Bone_Rad,Spine_Jnt_seg,Neck_Jnt_seg,Finger_Jnt_Nub,Finger_Jnt_seg
#Pub
def YJ_createMirrorExpression(LeftList,RightList):
AttrList = ['.tx','.ty','.tz','.rx','.ry','.rz']
LeftAttrList = YJ_GetAttrListByList(AttrList,LeftList)
RightAttrList = YJ_GetAttrListByList(AttrList,RightList)
ExpLis = []
ExpNub = 1
for i in range(len(LeftAttrList)):
if not getAttr(LeftAttrList[i],l=1):
PM = YJ_GetPM_Of_Exp(LeftAttrList[i],RightAttrList[i])
MirExpStr = RightAttrList[i] + '=' + PM + LeftAttrList[i]
ExpStrN = str(ExpNub)
ExpName = 'Mir_Jnt_Exp'+ExpStrN
expression(s=MirExpStr,n = ExpName )
ExpNub = ExpNub + 1
ExpLis.append(ExpName)
return ExpLis
def YJ_GetAttrListByList(AttrLis,ObjLis):
Obj_Attr_Lis = []
for Attr in AttrLis:
for Obj in ObjLis:
Obj_Attr_Lis = Obj_Attr_Lis +[(Obj+Attr)]
return Obj_Attr_Lis
def YJ_GetPM_Of_Exp(L_Attr,R_Attr):
L_Attr_v = getAttr(L_Attr)
R_Attr_v = getAttr(R_Attr)
if L_Attr_v != R_Attr_v:
Pm = '-'
elif L_Attr_v == R_Attr_v:
Pm = ''
return Pm
def YJ_Create_Jnt_By_Piv(PivList,NameList,Bone_Rad):
select(cl=1)
JntList=[]
for i in range(len(PivList)):
name=joint(p=[PivList[i][0],PivList[i][1],PivList[i][2]],n=NameList[i],rad=Bone_Rad)
JntList.append(name)
return JntList
def YJ_SplitJoint(StarJnt,EndJnt,segment):
JntRa = getAttr(StarJnt+".radius")
EndJntT_List = getAttr(EndJnt+".t")
EndJntTranL=[]
for t in range(3):
EndJntTranL.append(EndJntT_List[0][t])
if (EndJntTranL[0]*EndJntTranL[0] )> (EndJntTranL[1]*EndJntTranL[1]) and(EndJntTranL[0]*EndJntTranL[0] )> (EndJntTranL[2]*EndJntTranL[2]) :
tran = '.tx'
EndJntTran = EndJntTranL[0]
elif (EndJntTranL[1]*EndJntTranL[1] )> (EndJntTranL[0]*EndJntTranL[0]) and(EndJntTranL[1]*EndJntTranL[1] )> (EndJntTranL[2]*EndJntTranL[2]):
tran = '.ty'
EndJntTran = EndJntTranL[1]
elif (EndJntTranL[2]*EndJntTranL[2] )> (EndJntTranL[1]*EndJntTranL[1]) and(EndJntTranL[2]*EndJntTranL[2] )> (EndJntTranL[0]*EndJntTranL[0]):
tran = '.tz'
EndJntTran = EndJntTranL[2]
#
EndJntTran = float(EndJntTran)
trans = EndJntTran / segment
Getted_JntList=[]
for i in range(segment-1):
Getted_JntList.append(insertJoint(StarJnt))
for i in Getted_JntList:
setAttr(i+tran,trans)
setAttr(i+".radius",JntRa)
setAttr(EndJnt+tran,trans)
Getted_JntList.reverse()
Getted_JntList=[StarJnt]+Getted_JntList+[EndJnt]
return Getted_JntList
def YJ_SegmentJnt_Rename(NewName,JntList):
select( clear=True )
for i in JntList:
select(i, add=True )
YJ_Name(0,NewName)
NewList=ls(sl=1)
select( clear=True )
return NewList
def YJ_GetJnt_LocTran(orientJoint):
MainTran=orientJoint[0]
ThirTran=orientJoint[-1]
if MainTran == 'x':
TranLocList = ['.ty','.tz']
elif MainTran =='y':
TranLocList = ['.tx','.tz']
elif MainTran =='z':
TranLocList = ['.tx','.ty']
if ThirTran == 'x':
RoLocList = ['.ry','.rz']
elif ThirTran =='y':
RoLocList = ['.rx','.rz']
elif ThirTran =='z':
RoLocList = ['.rx','.ry']
return TranLocList,RoLocList
def YJ_Get_Jnt_LocSc(JntList):
ReAttList = []
for i in JntList:
ReAttList.append(i+'.sx')
ReAttList.append(i+'.sy')
ReAttList.append(i+'.sz')
ReAttList.append(i+'.v')
return ReAttList
def YJ_LockOrUnlock_Attr(AttrList,Va):
for i in AttrList:
setAttr(i,lock=Va)
#PubEnd
#LegJnt
#YJ_Creat_Leg_Bone(1,'xyz','zup',0.1)
def YJ_Creat_Leg_Bone(Type,orientJoint,SecAO,Bone_Rad):
Leg_Piv_L,Leg_Jnt_L=YJ_Get_Leg_Piv(Type)
Jnt_List_L=YJ_Create_Jnt_By_Piv(Leg_Piv_L,Leg_Jnt_L,Bone_Rad)
YJ_OrientJnt(Jnt_List_L,orientJoint,SecAO)
Jnt_LocAttr_List_L= YJ_GetLeg_LocAttr(Type,Jnt_List_L,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_L,1)
return Jnt_List_L
def YJ_Get_Leg_Piv(Type):
Leg_Piv_L_1=[(0.5,5,-0.2),(0.5,2.6,-0.1),(0.5,0.36,-0.3)]
Leg_Jnt_L_1=['L_up_leg_jnt','L_low_leg_jnt','L_foot_jnt']
if Type==1:
Leg_Piv_L = Leg_Piv_L_1
Leg_Jnt_L = Leg_Jnt_L_1
return Leg_Piv_L,Leg_Jnt_L
def YJ_GetLeg_LocAttr(Type,Jnt_List_L,orientJoint):
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Leg_LocAttrTranRO_L_1=['L_low_leg_jnt'+TranLocList[0],'L_low_leg_jnt'+TranLocList[1],'L_low_leg_jnt'+RoLocList[0],'L_low_leg_jnt'+RoLocList[1],'L_foot_jnt'+TranLocList[0],'L_foot_jnt'+TranLocList[1]]
Leg_LocAttrSc_L_1 = YJ_Get_Jnt_LocSc(Jnt_List_L)
Leg_LocAttr_L_1 = Leg_LocAttrTranRO_L_1 + Leg_LocAttrSc_L_1
if Type==1:
Leg_LocAttr_L = Leg_LocAttr_L_1
return Leg_LocAttr_L
#LegJntEnd
#FootJnt
def YJ_Creat_Foot_Bone(Type,orientJoint,SecAO,Bone_Rad):
Foot_Piv_L,Foot_Jnt_L=YJ_Get_Foot_Piv(Type)
Foot_Jnt_List_L=YJ_Create_Jnt_By_Piv(Foot_Piv_L,Foot_Jnt_L,Bone_Rad)
YJ_OrientJnt(Foot_Jnt_List_L,orientJoint,SecAO)
Foot_Help_Piv_L,Foot_Help_Jnt_L = YJ_Get_Foot_Help_Piv(Type)
Foot_Help_Jnt_List_L=YJ_Create_Jnt_By_Piv(Foot_Help_Piv_L,Foot_Help_Jnt_L,Bone_Rad)
YJ_SetFootParent(Foot_Help_Jnt_List_L)
Foot_Jnt_List_all_L=Foot_Jnt_List_L+Foot_Help_Jnt_List_L
FootJnt_LocAttr_List_L= YJ_GetFoot_LocAttr(Type,Foot_Jnt_List_all_L,orientJoint)
YJ_LockOrUnlock_Attr(FootJnt_LocAttr_List_L,1)
return Foot_Jnt_List_all_L,Foot_Help_Jnt_List_L,Foot_Jnt_List_L
#
def YJ_Get_Foot_Piv(Type):
Foot_Piv_L_1=[(0.5,0,0.4),(0.5,0,1)]
Foot_Jnt_L_1=['L_toe_jnt','L_toeEnd_jnt']
if Type==1:
Foot_Piv_L = Foot_Piv_L_1
Foot_Jnt_L = Foot_Jnt_L_1
return Foot_Piv_L,Foot_Jnt_L
def YJ_Get_Foot_Help_Piv(Type):
Foot_Help_Piv_L_1=[(0.5,0,-0.4),(0.2,0,0.4),(0.8,0,0.4)]
Foot_Help_Jnt_L_1=['L_heel_helpjnt','L_inSide_helpjnt','L_outSide_helpjnt']
if Type==1:
Foot_Help_Piv_L = Foot_Help_Piv_L_1
Foot_Help_Jnt_L = Foot_Help_Jnt_L_1
return Foot_Help_Piv_L,Foot_Help_Jnt_L
def YJ_SetFootParent(Chr_Jnt_List):
for i in Chr_Jnt_List:
YJ_Try_Parent(i,'L_toe_jnt')
def YJ_Rotate_HelpJntToToe(JntList):
for i in JntList:
YJ_MoveOrRotateToTargetWd('L_toe_jnt',i,'ro','r')
def YJ_GetFoot_LocAttr(Type,Jnt_List_L,orientJoint):
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Foot_LocAttrTranRO_L_1=['L_toeEnd_jnt'+TranLocList[0],'L_toeEnd_jnt'+TranLocList[1],'L_toeEnd_jnt'+RoLocList[0],'L_toeEnd_jnt'+RoLocList[1]]
Foot_LocAttrSc_L_1 = YJ_Get_Jnt_LocSc(Jnt_List_L)
if Type==1:
Foot_LocAttr_L = Foot_LocAttrSc_L_1+Foot_LocAttrTranRO_L_1
return Foot_LocAttr_L
#FootEnd
#Spine
#YJ_Creat_Spine_Bone(1,'Spine_@_skin','xyz','zup',4,0.1)
def YJ_Creat_Spine_Bone(Type,SpineNameMod,orientJoint,SecAO,seg,Bone_Rad):
SpineStarEnd_P = YJ_Get_SpineJntStarEnd_Piv(Type)
SpineStarEnd_Jnt_LIst = YJ_Create_Jnt_By_Piv(SpineStarEnd_P,['st_jnt','ed_jnt'],Bone_Rad)
Hip_p = [SpineStarEnd_P[0]]
Hip_Jnt_List=YJ_Create_Jnt_By_Piv(Hip_p,['Hip_jnt'],(Bone_Rad*1.5))
Spine_jnt_Old = YJ_SplitJoint(SpineStarEnd_Jnt_LIst[0],SpineStarEnd_Jnt_LIst[1],seg)
Spine_Jnt_List = YJ_SegmentJnt_Rename(SpineNameMod,Spine_jnt_Old)
YJ_OrientJnt(Spine_Jnt_List,orientJoint,SecAO)
Jnt_LocAttr_List_AlL= YJ_Get_Spine_LocAttr(Spine_Jnt_List,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_AlL,1)
return Hip_Jnt_List,Spine_Jnt_List
def YJ_Get_SpineJntStarEnd_Piv(Type):
SpineStarEndPiv_1 = [(0,5,0),(0,7,0)]
if Type == 1:
SpineStarEndPiv = SpineStarEndPiv_1
return SpineStarEndPiv
def YJ_Get_Spine_LocAttr(Spine_Jnt_List,orientJoint):
Spine_LocAttrSc_L = YJ_Get_Jnt_LocSc(Spine_Jnt_List)
Spine_Jnt_List_N = Spine_Jnt_List[1:]
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Spine_LocAttrTranRO=[]
for i in Spine_Jnt_List_N:
Tran_I_0 = i + TranLocList[0]
Tran_I_1 = i + TranLocList[1]
Ro_I_0 = i + RoLocList[0]
Ro_I_1 = i + RoLocList[1]
Spine_LocAttrTranRO=Spine_LocAttrTranRO+[Tran_I_0]+[Tran_I_1]+[Ro_I_0]+[Ro_I_1]
Spine_LocAttrTranRO_all = Spine_LocAttrTranRO + Spine_LocAttrSc_L
return Spine_LocAttrTranRO_all
#SpineEnd
#Neck
def YJ_Creat_Neck_Bone(Type,NeckNameMod,orientJoint,SecAO,seg,Bone_Rad):
NeckStarEnd_P = YJ_Get_NeckJntStarEnd_Piv(Type)
NeckStarEnd_Jnt_LIst = YJ_Create_Jnt_By_Piv(NeckStarEnd_P,['stN_jnt','edN_jnt'],Bone_Rad)
Neck_jnt_Old = YJ_SplitJoint(NeckStarEnd_Jnt_LIst[0],NeckStarEnd_Jnt_LIst[1],seg)
Neck_Jnt_List = YJ_SegmentJnt_Rename(NeckNameMod,Neck_jnt_Old)
YJ_OrientJnt(Neck_Jnt_List,orientJoint,SecAO)
Jnt_LocAttr_List_AlL= YJ_Get_Neck_LocAttr(Neck_Jnt_List,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_AlL,1)
return Neck_Jnt_List
def YJ_Get_NeckJntStarEnd_Piv(Type):
NeckStarEndPiv_1 = [(0,8,0),(0,8.5,0)]
if Type == 1:
NeckStarEndPiv = NeckStarEndPiv_1
return NeckStarEndPiv
def YJ_Get_Neck_LocAttr(Neck_Jnt_List,orientJoint):
Neck_LocAttrSc_L = YJ_Get_Jnt_LocSc(Neck_Jnt_List)
Neck_Jnt_List_N = Neck_Jnt_List[1:]
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Neck_LocAttrTranRO=[]
for i in Neck_Jnt_List_N:
Tran_I_0 = i + TranLocList[0]
Tran_I_1 = i + TranLocList[1]
Ro_I_0 = i + RoLocList[0]
Ro_I_1 = i + RoLocList[1]
Neck_LocAttrTranRO=Neck_LocAttrTranRO+[Tran_I_0]+[Tran_I_1]+[Ro_I_0]+[Ro_I_1]
Neck_LocAttrTranRO_all = Neck_LocAttrTranRO + Neck_LocAttrSc_L
return Neck_LocAttrTranRO_all
#NeckEnd
#Should
#YJ_Creat_Should_Bone(1,'xyz','zup',0.1)
def YJ_Creat_Should_Bone(Type,orientJoint,SecAO,Bone_Rad):
Should_Piv_L,Should_Jnt_L=YJ_Get_Should_Piv(Type)
Should_Jnt_List = YJ_Create_Jnt_By_Piv(Should_Piv_L,Should_Jnt_L,Bone_Rad)
YJ_OrientJnt(Should_Jnt_List,orientJoint,SecAO)
Jnt_LocAttr_List_AlL= YJ_GetShould_LocAttr(Type,Should_Jnt_List)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_AlL,1)
return Should_Jnt_List
def YJ_Get_Should_Piv(Type):
Should_Piv_L_1=[(0.1,7.7,-0.2),(0.5,7.7,-0.2)]
Should_Jnt_L_1=['L_should_jnt','L_shouldEnd_jnt']
if Type==1:
Should_Piv_L = Should_Piv_L_1
Should_Jnt_L = Should_Jnt_L_1
return Should_Piv_L,Should_Jnt_L
def YJ_GetShould_LocAttr(Type,Jnt_List_L):
Should_LocAttrSc_L_1 = YJ_Get_Jnt_LocSc(Jnt_List_L)
if Type==1:
Should_LocAttr_L = Should_LocAttrSc_L_1
return Should_LocAttr_L
#ShouldEnd
#Arm
#YJ_Creat_Arm_Bone(1,'xyz','zup',0.1)
def YJ_Creat_Arm_Bone(Type,orientJoint,SecAO,Bone_Rad):
Arm_Piv_L,Arm_Jnt_L=YJ_Get_Arm_Piv(Type)
Jnt_List_L=YJ_Create_Jnt_By_Piv(Arm_Piv_L,Arm_Jnt_L,Bone_Rad)
YJ_OrientJnt(Jnt_List_L,orientJoint,SecAO)
Jnt_LocAttr_List_L= YJ_GetArm_LocAttr(Type,Jnt_List_L,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_L,1)
return Jnt_List_L
def YJ_Get_Arm_Piv(Type):
Arm_Piv_L_1=[(0.5,7.7,-0.2),(2,7.7,-0.2),(3.4,7.7,-0.2),(4.8,7.7,-0.2)]
Arm_Jnt_L_1=['L_up_Arm_jnt','L_low_Arm_jnt','L_Hand_jnt','L_Hand_Endjnt']
if Type==1:
Arm_Piv_L = Arm_Piv_L_1
Arm_Jnt_L = Arm_Jnt_L_1
return Arm_Piv_L,Arm_Jnt_L
def YJ_GetArm_LocAttr(Type,Jnt_List_L,orientJoint):
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Arm_LocAttrTranRO_L_1=['L_low_Arm_jnt'+TranLocList[0],'L_low_Arm_jnt'+TranLocList[1],'L_low_Arm_jnt'+RoLocList[0],'L_low_Arm_jnt'+RoLocList[1],'L_Hand_jnt'+TranLocList[0],'L_Hand_jnt'+TranLocList[1]]
Arm_LocAttrSc_L_1 = YJ_Get_Jnt_LocSc(Jnt_List_L)
Arm_LocAttr_L_1 = Arm_LocAttrTranRO_L_1 + Arm_LocAttrSc_L_1
if Type==1:
Arm_LocAttr_L = Arm_LocAttr_L_1
return Arm_LocAttr_L
def YJ_Rebuild_Arm_Bone(Jnt_LocAttr_List_L,Jnt_List_L,orientJoint,SecAO):
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_L,0)
YJ_FreezeAttr(Jnt_List_L)
YJ_OrientJnt(Jnt_List_L,orientJoint,SecAO)
#ArmEnd
#Thumb
#Type=1,Bone_Rad=0.1,seg=3
def YJ_Creat_Thumb_Bone(Type,orientJoint,SecAO,seg,Bone_Rad,ThumbNameMod):
ThumbStarEnd_P = YJ_Get_ThumbJntStarEnd_Piv(Type)
ThumbStarEnd_Jnt_LIst = YJ_Create_Jnt_By_Piv(ThumbStarEnd_P,['stN_jnt','edN_jnt'],Bone_Rad)
Thumb_jnt_Old = YJ_SplitJoint(ThumbStarEnd_Jnt_LIst[0],ThumbStarEnd_Jnt_LIst[1],seg)
Thumb_Jnt_List = YJ_SegmentJnt_Rename(ThumbNameMod,Thumb_jnt_Old)
YJ_OrientJnt(Thumb_Jnt_List,orientJoint,SecAO)
Jnt_LocAttr_List_AlL= YJ_Get_Thumb_LocAttr(Thumb_Jnt_List,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_AlL,1)
return Thumb_Jnt_List
def YJ_Get_ThumbJntStarEnd_Piv(Type):
ThumbStarEndPiv_1 = [(3.7,7.7,0.17),(4.5,7.7,0.17)]
if Type == 1:
ThumbStarEndPiv = ThumbStarEndPiv_1
return ThumbStarEndPiv
def YJ_Get_Thumb_LocAttr(Thumb_Jnt_List,orientJoint):
Thumb_LocAttrSc_L = YJ_Get_Jnt_LocSc(Thumb_Jnt_List)
Thumb_Jnt_List_N = Thumb_Jnt_List[1:]
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Thumb_LocAttrTranRO=[]
for i in Thumb_Jnt_List_N:
Tran_I_0 = i + TranLocList[0]
Tran_I_1 = i + TranLocList[1]
Ro_I_0 = i + RoLocList[0]
Ro_I_1 = i + RoLocList[1]
Thumb_LocAttrTranRO=Thumb_LocAttrTranRO+[Tran_I_0]+[Tran_I_1]+[Ro_I_0]+[Ro_I_1]
Thumb_LocAttrTranRO_all = Thumb_LocAttrTranRO + Thumb_LocAttrSc_L
return Thumb_LocAttrTranRO_all
#ThumbEnd
#Finger
#IndexLocAttrList ,Index_Jnt_List= YJ_Creat_Index_Bone(Type,orientJoint,SecAO,2,Bone_Rad,'L_Index_@_jnt')
#FingerList = YJ_judge_Create_Fin(4,1,orientJoint,SecAO,3,Bone_Rad,'L_Index_@_jnt')
#FinList=YJ_Dup_Fin(4,DupJnt)
def YJ_Create_Finger_Bone(FinNub,Type,orientJoint,SecAO,seg,Bone_Rad,ThumbNameMod,IndexNameMod):
Hand_Help_Piv_L,Hand_Help_Jnt_L=YJ_Get_HandHelp_Piv(Type)
Hand_HelpJnt_List = YJ_Create_Jnt_By_Piv(Hand_Help_Piv_L,Hand_Help_Jnt_L,Bone_Rad)
Thumb_Jnt_List = YJ_Creat_Thumb_Bone(Type,orientJoint,SecAO,seg,Bone_Rad,ThumbNameMod)
FinList = YJ_judge_Create_Fin(FinNub,Type,orientJoint,SecAO,seg,Bone_Rad,IndexNameMod)
FingerAllList = [Thumb_Jnt_List] + FinList
YJ_ParentFinger_Jnt(FingerAllList,Hand_HelpJnt_List)
return Hand_Help_Jnt_L,FingerAllList
def YJ_ParentFinger_Jnt(FingerList,Hand_HelpJnt_List):
for i in FingerList:
YJ_Try_Parent(i[0],Hand_HelpJnt_List[0])
def YJ_judge_Create_Fin(FinNub,Type,orientJoint,SecAO,seg,Bone_Rad,IndexNameMod):
if FinNub >= 1:
IndexLocAttrList ,Index_Jnt_List= YJ_Creat_Index_Bone(Type,orientJoint,SecAO,seg,Bone_Rad,IndexNameMod)
DupJnt = Index_Jnt_List[0]
FinList = [Index_Jnt_List]
FinList=YJ_Dup_Fin(FinNub,DupJnt,FinList)
return FinList
#
def YJ_Dup_Fin(FinNub,DupJnt,FinList):
if FinNub > 1:
DupNub = FinNub-1
Width = 0.1
for i in range(DupNub):
DupJnt = duplicate(DupJnt,rc=1)
if i == 0:
move( 0, -0.1, 0, DupJnt[0], r=1,os=1,wd=1 )
DupJnt = YJ_SegmentJnt_Rename('L_Mid_@_Jnt',DupJnt)
FinList.append(DupJnt)
if i == 1:
move( 0, -0.1, 0, DupJnt[0], r=1,os=1,wd=1 )
DupJnt = YJ_SegmentJnt_Rename('L_Ring_@_Jnt',DupJnt)
FinList.append(DupJnt)
if i == 2:
move( 0, -0.1, 0, DupJnt[0], r=1,os=1,wd=1 )
DupJnt = YJ_SegmentJnt_Rename('L_Pinky_@_Jnt',DupJnt)
FinList.append(DupJnt)
return FinList
#Type,orientJoint,SecAO,seg,Bone_Rad,IndexNameMod=1,'xyz','zup',3,0.01,'Index_@_Jnt'
#
def YJ_Creat_Index_Bone(Type,orientJoint,SecAO,seg,Bone_Rad,IndexNameMod):
IndexStarEnd_P = YJ_Get_IndexJntStarEnd_Piv(Type)
IndexStarEnd_Jnt_LIst = YJ_Create_Jnt_By_Piv(IndexStarEnd_P,['stN_jnt','edN_jnt'],Bone_Rad)
Index_jnt_Old = YJ_SplitJoint(IndexStarEnd_Jnt_LIst[0],IndexStarEnd_Jnt_LIst[1],seg)
Index_Jnt_List = YJ_SegmentJnt_Rename(IndexNameMod,Index_jnt_Old)
YJ_OrientJnt(Index_Jnt_List,orientJoint,SecAO)
Jnt_LocAttr_List_AlL= YJ_Get_Index_LocAttr(Index_Jnt_List,orientJoint)
YJ_LockOrUnlock_Attr(Jnt_LocAttr_List_AlL,1)
return Jnt_LocAttr_List_AlL,Index_Jnt_List
def YJ_Get_IndexJntStarEnd_Piv(Type):
IndexStarEndPiv_1 = [(4,7.7,0.1),(4.5,7.7,0.1)]
if Type == 1:
IndexStarEndPiv = IndexStarEndPiv_1
return IndexStarEndPiv
def YJ_Get_Index_LocAttr(Index_Jnt_List,orientJoint):
Index_LocAttrSc_L = YJ_Get_Jnt_LocSc(Index_Jnt_List)
Index_Jnt_List_A=Index_Jnt_List[1:-1]
TranLocList,RoLocList = YJ_GetJnt_LocTran(orientJoint)
Index_LocAttrTranRO=[]
for i in Index_Jnt_List_A:
Tran_I_0 = i + TranLocList[0]
Tran_I_1 = i + TranLocList[1]
Ro_I_0 = i + RoLocList[0]
Ro_I_1 = i + RoLocList[1]
Index_LocAttrTranRO=Index_LocAttrTranRO+[Tran_I_0]+[Tran_I_1]+[Ro_I_0]+[Ro_I_1]
Index_LocAttrTranRO_all = Index_LocAttrTranRO + Index_LocAttrSc_L
return Index_LocAttrTranRO_all
def YJ_Get_HandHelp_Piv(Type):
Hand_Help_Piv_L_1=[(3.4,7.7,-0.2)]
Hand_Help_Jnt_L_1=['L_HandHelp_jnt']
if Type==1:
Hand_Help_Piv_L = Hand_Help_Piv_L_1
Hand_Help_Jnt_L = Hand_Help_Jnt_L_1
return Hand_Help_Piv_L,Hand_Help_Jnt_L
##