#YJ_CreatFkRig()//YJ_GetBaseJntList(StarBaseJnt,EndBaseJnt)/YJ_DuplicateJntChain(AllBaseJntList,Suf)
###YJ_DuplicateJntChain(AllBaseJntList,Suf) YJ_SetParentConstraint(newJntList,AllBaseJntList)
#YJ_Creat_IK(YJ_IK_Start_Joint,YJ_IK_End_Joint,IK_solver)
##StarBaseJnt='L_foot_skin'
#EndBaseJnt='L_toeEnd_skin'
#footanim='L_foot_ik_anim',footanim[0:1]
#HeelPvJnt='L_heel_skin'
#Ctrl=footanim,footIkHandle='L_upLeg_ik_IKHandle'
def YJ_CreateFootRig(StarBaseJnt,EndBaseJnt,HeelPvJnt,footanim,footIkHandle):
parent(HeelPvJnt,w=1)
AllBaseJntList=YJ_GetBaseJntList(StarBaseJnt,EndBaseJnt)
newJntList=YJ_DuplicateJntChain(AllBaseJntList,'ik')
YJ_SetParentConstraint(newJntList,AllBaseJntList)
FootIkJnt=newJntList[0]
ToeIkJnt=newJntList[1]
ToeEndIkJnt=newJntList[2]
InsidePiv,OutsidePiv,ToePiv,BallPiv,HeelPiv,WigglePiv=YJ_CreatEmGrp(FootIkJnt,ToeIkJnt,ToeEndIkJnt,HeelPvJnt)
FootSCIkHandle=YJ_Creat_IK(FootIkJnt,ToeIkJnt,'ikSCsolver')
ToeSCIkHandle=YJ_Creat_IK(ToeIkJnt,ToeEndIkJnt,'ikSCsolver')
YJ_ParentFootIkHandle(HeelPiv,BallPiv,WigglePiv,footIkHandle,FootSCIkHandle,ToeSCIkHandle,footanim)
YJ_AddFootAnimAttr(footanim)
footExpr=YJ_AddFootExpr(footanim,HeelPiv,BallPiv,ToePiv,OutsidePiv,InsidePiv,WigglePiv)
def YJ_CreatEmGrp(FootIkJnt,ToeIkJnt,ToeEndIkJnt,HeelPvJnt):
ToeLength=getAttr(ToeEndIkJnt+'.tx')
SideOff=ToeLength/2
InsidePiv=group( em=1, n=FootIkJnt[0:2]+'InsidePiv' )
YJ_MoveOrRotateToTargetWd(ToeIkJnt,InsidePiv,'t','t')
move(-1*SideOff,InsidePiv,x=1,r=1,os=1,wd=1)
OutsidePiv=group( em=1, n=FootIkJnt[0:2]+'OutsidePiv' )
YJ_MoveOrRotateToTargetWd(ToeIkJnt,OutsidePiv,'t','t')
move(SideOff,OutsidePiv,x=1,r=1,os=1,wd=1)
ToePiv=group( em=1, n=FootIkJnt[0:2]+'ToePiv' )
YJ_MoveOrRotateToTargetWd(ToeEndIkJnt,ToePiv,'t','t')
BallPiv=group( em=1, n=FootIkJnt[0:2]+'BallPiv' )
YJ_MoveOrRotateToTargetWd(ToeIkJnt,BallPiv,'t','t')
HeelPiv=group( em=1, n=FootIkJnt[0:2]+'HeelPiv' )
YJ_MoveOrRotateToTargetWd(HeelPvJnt,HeelPiv,'t','t')
WigglePiv=group( em=1, n=FootIkJnt[0:2]+'WigglePiv' )
YJ_MoveOrRotateToTargetWd(ToeIkJnt,WigglePiv,'t','t')
parent(BallPiv,InsidePiv)
parent(InsidePiv,OutsidePiv)
parent(OutsidePiv,ToePiv)
parent(ToePiv,HeelPiv)
parent(WigglePiv,InsidePiv)
delete(HeelPvJnt)
return InsidePiv,OutsidePiv,ToePiv,BallPiv,HeelPiv,WigglePiv
def YJ_AddFootAnimAttr(Ctrl):
AttrList1=['roll','toelift','toestraight','lean','side','toespin','toewiggle']
YJ_AddAttr(Ctrl,AttrList1,0)
def YJ_AddAttr(CtrL,AttrList,Atype):
while Atype == 0:
for i in AttrList:
addAttr( CtrL,longName=i, attributeType='double',k=1)
break
while Atype == 1:
for i in AttrList:
addAttr( CtrL,longName=i, attributeType='double',min=0,max=1,dv=0,k=1)
def YJ_ParentFootIkHandle(HeelPiv,BallPiv,WigglePiv,footIkHandle,FootSCIkHandle,ToeSCIkHandle,footanim):
parent(footIkHandle,BallPiv)
parent(ToeSCIkHandle,WigglePiv)
parent(FootSCIkHandle,WigglePiv)
parent(HeelPiv,footanim)
def YJ_AddFootExpr(footanim,HeelPiv,BallPiv,ToePiv,OutsidePiv,InsidePiv,WigglePiv):
string='$roll ='+ footanim+'.roll;\n$toeLift = '+footanim+'.toelift;\n$toeStraight ='+ footanim+'.toestraight;\n$lean = '+footanim+'.lean;\n$side ='\
+footanim+'.side;\n$spin =' +footanim+'.toespin;\n$wiggle ='+ footanim+'.toewiggle;\n'+HeelPiv+'.rotateX = min($roll,0);\n'\
+BallPiv+'.rotateX = (linstep(0,$toeLift,$roll)) *(1-(linstep($toeLift,$toeStraight,$roll))) * $roll;\n'\
+ToePiv+'.rotateX = linstep($toeLift, $toeStraight, $roll) * $roll;\n'+BallPiv+'.rotateY = $lean;\n'\
+OutsidePiv+'.rotateZ = min($side,0);\n'+InsidePiv+'.rotateZ= max(0,$side);\n'\
+ToePiv+'.rotateY = $spin;\n'+WigglePiv+'.rotateX = $wiggle;'
exprName=footanim+'_expr'
expression( s=string,n=exprName)
return exprName