Пример #1
0
    def setupTeeth(self):
        allCons = []
        conGrps = []
        ConObj = CreateControler(
            13, (0.1 * self.scale, 0.1 * self.scale, 0.1 * self.scale))
        ConObj.signValue = 54861
        for i, jnt in enumerate(self.jnts):
            jntMat = rig.getAttr(jnt + '.worldMatrix')
            con = ConObj.SK_b08(jnt.split('_')[0] + '_M')
            allCons.append(con)
            rig.xform(con, ro=(90, 0, 0), wd=True)
            rig.makeIdentity(apply=True, r=True)
            rig.xform(con, m=jntMat)

            conGrp = CA.addGrp().grp(con, 'Freeze')
            conGrps.append(conGrp)

            rig.parentConstraint(con, jnt, mo=True)
            rig.scaleConstraint(con, jnt, mo=True)

        self.Connect.connect(self.grp, allCons)  #连接控制器属性
        newGrp = rig.group(conGrps, n=self.grp + '_CTRLGrp')
        rig.parent(newGrp, self.grp)

        #连接visibility属性
        Connect = CA.connectAttribute()
        Connect.sourceAttr = 'conVis'
        Connect.targetAttr = 'visibility'
        Connect.connect(self.grp,
                        [rig.listRelatives(con, p=True)[0] for con in allCons])
Пример #2
0
 def setupTongue(self):
     #对骨骼校正轴向
     oj = 'zyx'
     secondaryAxisOrient = 'yup'
     orientJoints = [jnt for jnt in self.jnts]#排除不需要校正轴向的骨骼
     for jnt in orientJoints:
         rig.joint(jnt,e = True, oj = oj, secondaryAxisOrient = secondaryAxisOrient, ch = False, zso = True)
     rig.joint(self.jnts[-1],e = True, oj = 'none', ch = False, zso = True)
     
     
     #生成控制器并增加父子约束
     allCons = []
     preCon  = ''
     ConObj = CreateControler(13, (0.1*self.scale, 0.1*self.scale, 0.1*self.scale))
     ConObj.signValue = 32547
     for i,jnt in enumerate(self.jnts):
         jntMat = rig.getAttr(jnt+'.worldMatrix')
         con = ConObj.SK_b08(jnt.split('_')[0]+'_'+str(i)+'M')
         allCons.append(con)
         rig.xform(con, ro = (90, 0, 0), wd = True)
         rig.makeIdentity(apply = True, r = True)
         rig.xform(con, m = jntMat)
         
         conGrp = CA.addGrp().grp(con, 'Freeze')
         if i != 0:
             rig.parent(conGrp, preCon)
         preCon = con
         
         rig.parentConstraint(con, jnt, mo = True)
     
     self.Connect.connect(self.grp, allCons)#连接控制器属性
     
     #连接visibility属性
     self.Connect.sourceAttr = 'conVis'
     self.Connect.targetAttr = 'visibility'
     self.Connect.connect(self.grp, [rig.listRelatives(con, p = True)[0] for con in allCons])
Пример #3
0
    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)
Пример #4
0
    def createController(self):

        vtxNum = 0
        for i, cur in enumerate(self.allLoftCurve):
            color = self.colors[i]
            controllers = CreateControler(color, (0.02, 0.02, 0.02))
            controllers.signValue = 18424

            #区分控制器的左右和控制器的编号
            vtxs = rig.ls(rig.listRelatives(cur, s=True)[0] + '.cv[*]',
                          fl=True)  #控制器点数
            LenVtx = len(vtxs)
            vtxNums = []
            LfRtVtxs = []
            if len(vtxs) % 2:
                average = (LenVtx - 1) / 2
                for num in range(average):  #左边控制器编号
                    LfRtVtxs.append('Lf')
                    vtxNums.append(num)
                vtxNums.append(0)
                LfRtVtxs.append('Md')
                for num in range(average):  #左边控制器编号
                    vtxNums.append(average - num - 1)
                    LfRtVtxs.append('Rt')

            else:
                average = (LenVtx) / 2
                for num in range(average):  #左边控制器编号
                    LfRtVtxs.append('Lf')
                    vtxNums.append(num)
                for num in range(average):  #右边控制器编号
                    vtxNums.append(average - num - 1)
                    LfRtVtxs.append('Rt')

            #控制器是否左右对称
            if re.compile(r'(out_Lf[A-Z]+|out_Rt[A-Z]+)').match(
                    cur) or re.compile(r'(in_Lf[A-Z]+|in_Rt[A-Z]+)').match(
                        cur):
                LfRt = True
            else:
                LfRt = False

            for j, vtx in enumerate(vtxs):

                if LfRt:
                    conName = self.names[i] + '_' + str(j) + 'M'  #控制器名字
                else:
                    conName = LfRtVtxs[j] + self.names[i] + '_' + str(
                        vtxNums[j]) + 'M'  #控制器名字
                con = controllers.SK_b03(conName)
                rig.addAttr(con, at='long', ln='vtxNum', dv=vtxNum)  #增加属性
                rig.setAttr(con + '.vtxNum', l=True)  #锁定属性
                self.connectAddAttr(con, 'CTRLCurve')  #连接属性
                pos = rig.xform(vtx, q=True, t=True, ws=True)
                rig.xform(con, t=pos, ws=True)

                rig.connectAttr(con + '.translate',
                                vtx.replace(
                                    '.cv[',
                                    '.controlPoints['))  #将控制器的位移属性连接到曲线的控制点上
                vtxNum += 1