def SK_IKHandPivot(): Lock = LockHideAttr(True,True,False,False) newcons = CreateControler() handIK = rig.ls('*Arm_Wrist_IK') if handIK: for ikcon in handIK: #增加旋转属性 rig.addAttr(ikcon,at = 'float',ln = 'pivotIKRX',k = True) rig.addAttr(ikcon,at = 'float',ln = 'pivotIKRY',k = True) rig.addAttr(ikcon,at = 'float',ln = 'pivotIKRZ',k = True) val = rig.getAttr(ikcon+'.scaleVal')#获得缩放值 newcons.setObjScale((val,val,val)) con = newcons.SK_b01(ikcon+'_Pivot') jointFinger = ikcon[0:2]+'_mid2_jnt'#手指骨骼 pos = rig.xform(jointFinger,q = True,t = True,ws = True)#旋转轴心点位置 rig.xform(con,t = pos,ws = True) ikConChild = rig.listRelatives(ikcon,c = True,type = 'transform')#获得IK控制器下的物体 rig.parent(con,ikcon) rig.makeIdentity(con,apply = True,t = True,s = True,r = True) rig.parent(ikConChild,con) Switch = ikcon[0:2]+'Arm_Switch' rig.addAttr(Switch,at = 'enum',ln = 'pivotIK',en = 'OFF:ON:',k = False) rig.connectAttr(Switch+'.pivotIK',con+'.visibility') Lock.hideAndLockObj(con) #连接旋转属性 rig.connectAttr(ikcon+'.pivotIKRX',con+'.rx') rig.connectAttr(ikcon+'.pivotIKRY',con+'.ry') rig.connectAttr(ikcon+'.pivotIKRZ',con+'.rz')
def createController(self): if not rig.attributeQuery('sign', node=self.ployName, ex=True): rig.addAttr(self.ployName, ln='sign', at='long', dv=7648) #----------------------------------------------------------------------- 得到控制器颜色 conColor = 13 if 1 == self.color: conColor = 13 if 2 == self.color: conColor = 17 if 3 == self.color: conColor = 15 SMCON = CreateControler(conColor, (self.size, self.size, self.size)) for i in range(self.start, self.start + self.col * self.row): if 1 == self.shape: con = SMCON.SK_b03(self.conPre + '_' + str(i) + '_P') if 2 == self.shape: con = SMCON.SK_b01(self.conPre + '_' + str(i) + '_P') if 3 == self.shape: con = SMCON.SK_b05(self.conPre + '_' + str(i) + '_P') rig.connectAttr(self.ployName + '.sign', con + '.sign')
def buildController(self): size = [(0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1), (0.1, 0.1, 0.1)] colors = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12] conJoint = [ u'Lf_Brow_Joint', u'Rt_Brow_Joint', u'Lf_Cheek_Joint', u'Rt_Cheek_Joint', u'Lf_CornerLip_Joint', u'Rt_CornerLip_Joint', u'Up_Lip_Joint', u'Mouth_Tip_Joint', u'Dn_Lip_Joint', u'Nose_Joint', 'JawMain_Joint' ] #生成Macro控制器 for i, jnt in enumerate(conJoint): pos = rig.xform(jnt, q=True, t=True, ws=True) controllers = CreateControler( 15, [j * self.scale * 0.6 for j in size[i]]) controllers.signValue = 18290 controllers.color = colors[i] con = controllers.SK_b03(jnt.replace('_Joint', 'Macro_M')) rig.xform(con, t=pos, ws=True) self.connectAddAttr(con, 'CTRLMacroCurve') #连接属性 #生成blendShape控制器 crossColor = [17 for i in range(11)] #cross控制器颜色 colors = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 17] #blendShape控制器颜色 for i, jnt in enumerate(conJoint): pos = rig.xform(jnt, q=True, t=True, ws=True) #获得位置信息 controllers = CreateControler(15, [j * self.scale for j in size[i]]) controllers.signValue = 44390 controllers.color = colors[i] if 'JawMain_Joint' == jnt: con = controllers.SK_b01(jnt.replace('_Joint', '_M')) else: con = controllers.SK_b03(jnt.replace('_Joint', '_M')) #blendShape控制器 self.connectAddAttr(con, 'CTRLBsCurve') #连接属性 controllers.color = crossColor[i] controllers.setObjScale([i * 1.6 for i in controllers.curveSale]) conCross = controllers.SK_b16(jnt.replace('_Joint', 'Cross_M')) #cross控制器 rig.xform(con, t=pos, ws=True) rig.xform(conCross, t=pos, ws=True) rig.parent(rig.listRelatives(conCross, s=True)[0], con, s=True, add=True) #parent形节点 rig.delete(conCross) #删除cross控制器 #生成jawSwivel控制器 controllers.setRelativesScale([0.3, 0.3, 0.3]) jawSwivel = controllers.SK_b01('jawSwivel_M') rig.xform(jawSwivel, t=(0, 15.97, 2.485), ws=True) self.connectAddAttr(jawSwivel, 'CTRLBsCurve') #连接属性 rig.hide('Mouth_TipMacro_MShape') #增加旋转blendShape属性 rig.addAttr('JawMain_M', at='float', ln='limitMinrz', dv=-30, k=True) rig.addAttr('JawMain_M', at='float', ln='limitMaxrz', dv=30, k=True) rig.addAttr('jawSwivel_M', at='float', ln='limitMinrz', dv=-30, k=True) rig.addAttr('jawSwivel_M', at='float', ln='limitMaxrz', dv=30, k=True) rig.addAttr('Mouth_Tip_M', at='float', ln='limitMinrz', dv=-30, k=True) rig.addAttr('Mouth_Tip_M', at='float', ln='limitMaxrz', dv=30, k=True) rig.addAttr('Lf_Brow_M', at='float', ln='limitMinrz', dv=-30, k=True) rig.addAttr('Lf_Brow_M', at='float', ln='limitMaxrz', dv=30, k=True) rig.addAttr('Rt_Brow_M', at='float', ln='limitMinrz', dv=-30, k=True) rig.addAttr('Rt_Brow_M', at='float', ln='limitMaxrz', dv=30, k=True)