示例#1
0
 def exposeSockets(self, socketDict):
     for socket in socketDict.keys():
         s = coreUtils.addChild(self.sockets_grp, 'group',
                                '%s_%s_socket' % (self.name, socket))
         coreUtils.align(s, socketDict[socket], orient=0)
         pmc.parentConstraint(socketDict[socket], s, mo=1)
         self.sockets[socket] = s
示例#2
0
def plug(node=None, socket=None, plugType='parent', name=''):
    if not node or not socket:
        sel = pmc.selected()
        if len(sel) == 2:
            node = sel[0]
            socket = sel[1]
        else:
            return 'Please supply or select node and socket'

    main_grp = pmc.group(empty=1, name='%s_%s_PLUG' % (name, plugType))

    # constrained group
    const_grp = coreUtils.addChild(main_grp,
                                   'group',
                                   name='%s_%s_CONST' % (name, plugType))
    coreUtils.align(const_grp, node)
    pmc.parentConstraint(socket, const_grp, mo=1)

    if plugType == 'parent':
        pmc.parentConstraint(const_grp, node, mo=1)
    elif plugType == 'point':
        pmc.pointConstraint(const_grp, node, mo=1)
    else:
        pmc.orientConstraint(const_grp, node, mo=1)

    return main_grp
示例#3
0
    def buildHand(self, settingsNode, fingerDict, colour, cleanup):
        ctrlSize=None
        for finger in fingerDict.keys():
            for i in range(len(fingerDict[finger])):
                if not ctrlSize:
                        ctrlSize = coreUtils.getDistance(fingerDict[finger][0], fingerDict[finger][1]) * .25
                if i > 0:
                    j2 = coreUtils.createAlignedNode(fingerDict[finger][i], 'joint',
                                                     '%s_%s_%s_translate_JNT' % (self.name, finger, str(i+1).zfill(2)))
                    j2.setParent(self.joints[-1])
                    j2.jointOrient.set(fingerDict[finger][i].jointOrient.get())
                    j2.r.set((0, 0, 0))
                    coreUtils.addParent(j2, 'group',
                                        '%s_%s_%s_translateJnt_ZERO' % (self.name, finger, str(i+1).zfill(2)))
                    self.joints.append(j2)
                j = coreUtils.createAlignedNode(fingerDict[finger][i], 'joint',
                                                '%s_%s_%s_JNT' % (self.name, finger, str(i+1).zfill(2)))

                c = controls.squareCtrl(axis='x', name='%s_%s_%s_CTRL' % (self.name, finger, str(i+1).zfill(2)),
                                        size=ctrlSize)
                coreUtils.align(c, j)
                pmc.select('%s.cv[*]' % c.name())
                pmc.scale(5.0, scaleY=1)

                if i == 0:
                    j.setParent(self.rig_grp)
                    jGrp = coreUtils.addParent(j, 'group', '%s_%s_joints_GRP' % (self.name, finger))
                    j.jointOrient.set((0, 0, 0))
                    j.r.set((0, 0, 0))
                    c.setParent(self.ctrls_grp)
                    cGrp = coreUtils.addParent(c, 'group', '%s_%s_ctrls_GRP' % (self.name, finger))
                    c.t.connect(j.t)
                    c.r.connect(j.r)
                    pmc.parentConstraint(cGrp, jGrp)
                else:
                    j.setParent(self.joints[-1])
                    j.jointOrient.set((0, 0, 0))
                    j.r.set((0, 0, 0))
                    c.setParent(self.ctrls[-1])
                    coreUtils.addParent(c, 'group', '%s_%s_%s_ZERO' % (self.name, finger, str(i+1).zfill(2)))
                    c.t.connect(j2.t)
                    c.r.connect(j.r)
                self.joints.append(j)
                self.ctrls.append(c)

        coreUtils.colorize(colour, self.ctrls)

        if settingsNode:
            pmc.addAttr(settingsNode, longName='finger_ctrls_vis', at='bool', k=0, h=0)
            pmc.setAttr(settingsNode.finger_ctrls_vis, channelBox=1)
            settingsNode.finger_ctrls_vis.connect(self.ctrls_grp.visibility)

        if cleanup:
            self.cleanup()
示例#4
0
        def _makeSubCtrls(parent, prefix='', colour='red', grpParent=None):
            for i in range(len(subs.keys())):
                c = controls.squareCtrl(size=ctrlSize * .15,
                                        name='%s_%s_CTRL' %
                                        (prefix, subs[i][0]),
                                        axis='z')
                coreUtils.align(c, parent, parent=1)
                c.tx.set(ctrlSize * subs[i][1])
                coreUtils.addParent(c, 'group',
                                    c.name().replace('_CTRL', 'Ctrl_ZERO'))
                coreUtils.colorize(colour, [c])
                self.ctrls.append(c)

                g = coreUtils.addChild(grpParent, 'group',
                                       '%s_%s_DRV' % (prefix, subs[i][0]))
                j = coreUtils.addChild(g, 'joint',
                                       '%s_%s_JNT' % (prefix, subs[i][0]))
                j.t.set((ctrlSize * subs[i][1], 0, 0))
                self.joints.append(j)

                c.t.connect(g.t)
示例#5
0
    def buildCockle(self):
        self.main_grp = pmc.group(empty=1, name='%s_GRP' % self.name)
        if not self.settingsNode:
            self.settingsNode = self.main_grp

        self.lf_grp = coreUtils.addChild(self.main_grp,
                                         'group',
                                         name='%s_lf_ZERO' % self.name)
        coreUtils.align(self.lf_grp, self.lf_GD)
        self.lf_drv = coreUtils.addChild(self.lf_grp,
                                         'group',
                                         name='%s_lf_DRV' % self.name)
        pmc.transformLimits(self.lf_drv, rz=(0, 0), erz=(0, 1))

        self.rt_grp = coreUtils.addChild(self.lf_drv,
                                         'group',
                                         name='%s_rt_ZERO' % self.name)
        coreUtils.align(self.rt_grp, self.rt_GD)
        self.rt_drv = coreUtils.addChild(self.rt_grp,
                                         'group',
                                         name='%s_rt_DRV' % self.name)
        pmc.transformLimits(self.rt_drv, rz=(0, 0), erz=(1, 0))

        self.fnt_grp = coreUtils.addChild(self.rt_drv,
                                          'group',
                                          name='%s_fnt_ZERO' % self.name)
        coreUtils.align(self.fnt_grp, self.fnt_GD)
        self.fnt_drv = coreUtils.addChild(self.fnt_grp,
                                          'group',
                                          name='%s_fnt_DRV' % self.name)
        pmc.transformLimits(self.fnt_drv, rx=(0, 0), erx=(1, 0))

        self.bck_grp = coreUtils.addChild(self.fnt_drv,
                                          'group',
                                          name='%s_bck_ZERO' % self.name)
        coreUtils.align(self.bck_grp, self.bck_GD)
        self.bck_drv = coreUtils.addChild(self.bck_grp,
                                          'group',
                                          name='%s_bck_DRV' % self.name)
        pmc.transformLimits(self.bck_drv, rx=(0, 0), erx=(0, 1))

        pmc.addAttr(self.settingsNode, ln='side_tilt', at='double', k=1, h=0)
        pmc.addAttr(self.settingsNode, ln='front_tilt', at='double', k=1, h=0)

        self.settingsNode.side_tilt.connect(self.lf_drv.rz)
        self.settingsNode.side_tilt.connect(self.rt_drv.rz)
        self.settingsNode.front_tilt.connect(self.fnt_drv.rx)
        self.settingsNode.front_tilt.connect(self.bck_drv.rx)

        pmc.delete([self.lf_GD, self.rt_GD, self.fnt_GD, self.bck_GD])
示例#6
0
    def buildMouth(self, crv, numCtrls, numLipJoints, cleanup):
        if not crv:
            return 'DrMouth: Please provide a curve for the mouth to ride along'
        self.topLip = drRail.DrRail(name='topLip',
                                    crv=crv,
                                    numCtrls=numCtrls,
                                    numSubCtrls=numLipJoints)
        self.topLip.main_grp.end_uValue.set(1.0)
        self.topLip.main_grp.setParent(self.main_grp)

        self.btmLip = drRail.DrRail(name='btmLip',
                                    crv=crv,
                                    numCtrls=numCtrls,
                                    numSubCtrls=numLipJoints)
        self.btmLip.main_grp.end_uValue.set(1.0)
        self.btmLip.main_grp.setParent(self.main_grp)

        ctrlSize = coreUtils.getDistance(crv.getCV(0), crv.getCV(1)) * .5

        self.rtCtrl = controls.circleBumpCtrl(radius=ctrlSize,
                                              name='%s_rt_corner_CTRL' %
                                              self.name)
        coreUtils.align(self.rtCtrl, self.topLip.ctrls[0])
        self.rtCtrl.setParent(self.ctrls_grp)
        zero = coreUtils.addParent(self.rtCtrl, 'group',
                                   '%s_rt_cornerCtrl_ZERO' % self.name)
        coreUtils.colorize('red', [self.rtCtrl])

        self.lfCtrl = controls.circleBumpCtrl(radius=ctrlSize,
                                              name='%s_lf_corner_CTRL' %
                                              self.name)
        coreUtils.align(self.lfCtrl, self.topLip.ctrls[-1])
        self.lfCtrl.setParent(self.ctrls_grp)
        zero = coreUtils.addParent(self.lfCtrl, 'group',
                                   '%s_lf_cornerCtrl_ZERO' % self.name)
        coreUtils.colorize('blue', [self.lfCtrl])
        zero.sx.set(-1)

        #split into left and right
        for i in range(numCtrls):
            topCtrl = self.topLip.ctrls[i]
            topLoc = self.topLip.locs[i]
            btmCtrl = self.btmLip.ctrls[i]
            btmLoc = self.btmLip.locs[i]
            if i < numCtrls / 2:
                coreUtils.colorize('red', [topCtrl, btmCtrl])
            elif i > numCtrls / 2:
                coreUtils.colorize('blue', [topCtrl, btmCtrl])
                topCtrl.getParent().sx.set(-1)
                topLoc.getParent().sx.set(-1)
                btmCtrl.getParent().sx.set(-1)
                btmLoc.getParent().sx.set(-1)
            else:
                coreUtils.colorize('green', [topCtrl, btmCtrl])
            if i == 0:
                pmc.delete([topCtrl.getParent(), btmCtrl.getParent()])
            if i == (numCtrls - 1):
                pmc.delete([topCtrl.getParent(), btmCtrl.getParent()])
        self.topLip.ctrls = self.topLip.ctrls[1:-1]
        self.btmLip.ctrls = self.btmLip.ctrls[1:-1]

        #split subCtrls into left and right
        for i in range(numLipJoints):
            topCtrl = self.topLip.subCtrls[i]
            topDrv = self.topLip.drivenGrps[i]
            btmCtrl = self.btmLip.subCtrls[i]
            btmDrv = self.btmLip.drivenGrps[i]
            if i < numLipJoints / 2:
                coreUtils.colorize('red', [topCtrl, btmCtrl])
            elif i > numLipJoints / 2:
                coreUtils.colorize('blue', [topCtrl, btmCtrl])
                topCtrl.getParent().sx.set(-1)
                topDrv.sx.set(-1)
                btmCtrl.getParent().sx.set(-1)
                btmDrv.sx.set(-1)
            else:
                coreUtils.colorize('green', [topCtrl, btmCtrl])

        rt_loc = coreUtils.addChild(self.rig_grp, 'locator',
                                    '%s_rt_corner_LOC' % self.name)
        coreUtils.align(rt_loc, self.rtCtrl)
        rt_zero = coreUtils.addParent(rt_loc, 'group',
                                      '%s_rt_cornerLoc_ZERO' % self.name)
        self.rtCtrl.t.connect(rt_loc.t)
        self.rtCtrl.getParent().t.connect(rt_zero.t)
        rtCornerClosestPoint = pmc.createNode(
            'nearestPointOnCurve',
            name='closestCrvPoint_%s_rt_corner_UTL' % self.name)
        locShape = pmc.listRelatives(rt_loc, s=1, c=1)[0]
        locShape.worldPosition[0].connect(rtCornerClosestPoint.inPosition)
        crvShape = coreUtils.getShape(crv)
        crvShape.worldSpace[0].connect(rtCornerClosestPoint.inputCurve)
        rtCornerClosestPoint.parameter.connect(
            self.topLip.main_grp.start_uValue)
        rtCornerClosestPoint.parameter.connect(
            self.btmLip.main_grp.start_uValue)
        self.rtCtrl.ty.connect(self.topLip.locs[0].ty)
        self.rtCtrl.tz.connect(self.topLip.locs[0].tz)
        self.rtCtrl.ty.connect(self.btmLip.locs[0].ty)
        self.rtCtrl.tz.connect(self.btmLip.locs[0].tz)

        lf_loc = coreUtils.addChild(self.rig_grp, 'locator',
                                    '%s_lf_corner_LOC' % self.name)
        coreUtils.align(lf_loc, self.lfCtrl)
        lf_zero = coreUtils.addParent(lf_loc, 'group',
                                      '%s_lf_cornerLoc_ZERO' % self.name)
        self.lfCtrl.t.connect(lf_loc.t)
        self.lfCtrl.getParent().t.connect(lf_zero.t)
        lfCornerClosestPoint = pmc.createNode(
            'nearestPointOnCurve',
            name='closestCrvPoint_%s_lf_corner_UTL' % self.name)
        locShape = pmc.listRelatives(lf_loc, s=1, c=1)[0]
        locShape.worldPosition[0].connect(lfCornerClosestPoint.inPosition)
        crvShape.worldSpace[0].connect(lfCornerClosestPoint.inputCurve)
        lfCornerClosestPoint.parameter.connect(self.topLip.main_grp.end_uValue)
        lfCornerClosestPoint.parameter.connect(self.btmLip.main_grp.end_uValue)
        self.lfCtrl.ty.connect(self.topLip.locs[-1].ty)
        self.lfCtrl.tz.connect(self.topLip.locs[-1].tz)
        self.lfCtrl.ty.connect(self.btmLip.locs[-1].ty)
        self.lfCtrl.tz.connect(self.btmLip.locs[-1].tz)

        # Constrain systems
        pmc.parentConstraint(self.ctrls_grp, self.topLip.const_grp)
        pmc.scaleConstraint(self.ctrls_grp, self.topLip.const_grp)
        pmc.parentConstraint(self.ctrls_grp, self.btmLip.const_grp)
        pmc.scaleConstraint(self.ctrls_grp, self.btmLip.const_grp)

        if cleanup:
            self.cleanup()
示例#7
0
    def buildEyes(self, rtPos, lfPos):
        if not rtPos or not lfPos:
            return 'DrEyes: Please supply and right and left location for your eye rig'
        # Make Ctrls
        ctrlSize = coreUtils.getDistance(rtPos, lfPos)
        self.mainCtrl = controls.squareCtrl(axis='z',
                                            name='%s_CTRL' % self.name,
                                            size=ctrlSize)
        pmc.select('%s.cv[ * ]' % coreUtils.getShape(self.mainCtrl))
        pmc.scale(2.5, scaleX=1)
        pmc.scale(1.25, scaleY=1)
        self.ctrls.append(self.mainCtrl)
        ctrlZero = coreUtils.addParent(self.mainCtrl, 'group',
                                       '%s_ctrl_ZERO' % self.name)
        ctrlZero.setParent(self.ctrls_grp)
        midPos = coreUtils.pointsAlongVector(lfPos, rtPos)[1]
        ctrlZero.t.set((midPos[0], midPos[1], midPos[2] + (ctrlSize * 10)))

        self.rtCtrl = controls.circleCtrl(radius=ctrlSize * .25,
                                          name='rt_eye_CTRL')
        self.ctrls.append(self.rtCtrl)
        coreUtils.align(self.rtCtrl, self.mainCtrl, parent=1)
        rtCtrlZero = coreUtils.addParent(self.rtCtrl, 'group',
                                         'rt_eyeCtrl_ZERO')
        rtCtrlZero.tx.set(rtPos[0])

        self.lfCtrl = controls.circleCtrl(radius=ctrlSize * .25,
                                          name='lf_eye_CTRL')
        self.ctrls.append(self.lfCtrl)
        coreUtils.align(self.lfCtrl, self.mainCtrl, parent=1)
        lfCtrlZero = coreUtils.addParent(self.lfCtrl, 'group',
                                         'lf_eyeCtrl_ZERO')
        lfCtrlZero.tx.set(lfPos[0])
        lfCtrlZero.sx.set(-1)

        coreUtils.colorize('green', [self.mainCtrl])
        coreUtils.colorize('red', [self.rtCtrl])
        coreUtils.colorize('blue', [self.lfCtrl])

        # Set up aims
        rtGrp = coreUtils.addChild(self.rig_grp, 'group', 'rt_eye_GRP')
        rtGrp.t.set(rtPos)
        pmc.parentConstraint(self.ctrls_grp, rtGrp, mo=1)
        pmc.scaleConstraint(self.ctrls_grp, rtGrp, mo=1)

        rtAimGrp = coreUtils.addChild(rtGrp, 'group', 'rt_eyeAim_GRP')
        pmc.aimConstraint(self.rtCtrl,
                          rtAimGrp,
                          aim=(0, 0, 1),
                          wut='objectrotation',
                          wuo=rtGrp)
        rtJnt = coreUtils.addChild(rtAimGrp, 'joint', 'rt_eyeAim_JNT')
        self.joints.append(rtJnt)

        lfGrp = coreUtils.addChild(self.rig_grp, 'group', 'lf_eye_GRP')
        lfGrp.t.set(lfPos)
        pmc.parentConstraint(self.ctrls_grp, lfGrp, mo=1)
        pmc.scaleConstraint(self.ctrls_grp, lfGrp, mo=1)

        lfAimGrp = coreUtils.addChild(lfGrp, 'group', 'lf_eyeAim_GRP')
        pmc.aimConstraint(self.lfCtrl,
                          lfAimGrp,
                          aim=(0, 0, 1),
                          wut='objectrotation',
                          wuo=lfGrp)
        lfJnt = coreUtils.addChild(lfAimGrp, 'joint', 'lf_eyeAim_JNT')
        self.joints.append(lfJnt)

        # softness
        pmc.addAttr(self.main_grp,
                    longName='eye_pull',
                    minValue=0.0,
                    maxValue=1.0,
                    at='double',
                    k=1,
                    h=0)
        eyePullRev = coreUtils.reverse(self.main_grp.eye_pull,
                                       name='rev_eyePull_UTL')

        rtSoftGrp = coreUtils.addChild(rtGrp, 'group', 'rt_eyeSoft_GRP')
        rtSoftJnt = coreUtils.addChild(rtSoftGrp, 'joint', 'rt_soft_JNT')
        self.joints.append(rtSoftJnt)
        con = pmc.orientConstraint(rtGrp, rtAimGrp, rtSoftGrp)
        con.interpType.set(2)
        w0 = pmc.Attribute('%s.%sW0' % (con.name(), rtGrp.name()))
        w1 = pmc.Attribute('%s.%sW1' % (con.name(), rtAimGrp.name()))
        self.main_grp.eye_pull.connect(w1)
        eyePullRev.outputX.connect(w0)

        lfSoftGrp = coreUtils.addChild(lfGrp, 'group', 'lf_eyeSoft_GRP')
        lfSoftJnt = coreUtils.addChild(lfSoftGrp, 'joint', 'lf_soft_JNT')
        self.joints.append(lfSoftJnt)
        con = pmc.orientConstraint(lfGrp, lfAimGrp, lfSoftGrp)
        con.interpType.set(2)
        w0 = pmc.Attribute('%s.%sW0' % (con.name(), lfGrp.name()))
        w1 = pmc.Attribute('%s.%sW1' % (con.name(), lfAimGrp.name()))
        self.main_grp.eye_pull.connect(w1)
        eyePullRev.outputX.connect(w0)

        #############################################################################################################
        # Lids

        pmc.addAttr(self.main_grp,
                    ln='lids_rotate_factor',
                    at='double',
                    k=0,
                    h=0)
        pmc.setAttr(self.main_grp.lids_rotate_factor, channelBox=1)
        self.main_grp.lids_rotate_factor.set(-10)
        pmc.addAttr(self.main_grp,
                    ln='lids_auto',
                    at='double',
                    k=0,
                    h=0,
                    minValue=0.0,
                    maxValue=1.0)
        self.main_grp.lids_auto.set(1.0)

        rtLidGrp = coreUtils.addChild(self.rig_grp, 'group', 'rt_lids_GRP')
        coreUtils.align(rtLidGrp, rtGrp)

        # rt_top
        rtTopLidZero = coreUtils.addChild(rtLidGrp, 'group', 'rt_topLid_ZERO')
        rtTopLidAutoGrp = coreUtils.addChild(rtTopLidZero, 'group',
                                             'rt_topLidAuto_GRP')
        md = coreUtils.multiply(rtAimGrp.rx,
                                self.main_grp.lids_auto,
                                name='md_rtLidsAuto_UTL')
        md.outputX.connect(rtTopLidAutoGrp.rx)

        # rt_btm
        rtBtmLidZero = coreUtils.addChild(rtLidGrp, 'group', 'rt_btmLid_ZERO')
        rtBtmLidAutoGrp = coreUtils.addChild(rtBtmLidZero, 'group',
                                             'rt_btmLidAuto_GRP')
        md.outputX.connect(rtBtmLidAutoGrp.rx)

        # lf_top
        lfLidGrp = coreUtils.addChild(self.rig_grp, 'group', 'lf_lids_GRP')
        coreUtils.align(lfLidGrp, lfGrp)

        lfTopLidZero = coreUtils.addChild(lfLidGrp, 'group', 'lf_topLid_ZERO')
        lfTopLidAutoGrp = coreUtils.addChild(lfTopLidZero, 'group',
                                             'lf_topLidAuto_GRP')
        md = coreUtils.multiply(lfAimGrp.rx,
                                self.main_grp.lids_auto,
                                name='md_lfLidsAuto_UTL')
        md.outputX.connect(lfTopLidAutoGrp.rx)

        # lf_btm
        lfBtmLidZero = coreUtils.addChild(lfLidGrp, 'group', 'lf_btmLid_ZERO')
        lfBtmLidAutoGrp = coreUtils.addChild(lfBtmLidZero, 'group',
                                             'lf_btmLidAuto_GRP')
        md.outputX.connect(lfBtmLidAutoGrp.rx)

        def _addControl(slave, driver):
            md = coreUtils.multiply(driver.ty,
                                    self.main_grp.lids_rotate_factor,
                                    name='md_%s_UTL' %
                                    driver.name().replace('_CTRL', ''))
            md.outputX.connect(slave.rx)

        # CTRLS
        def _makeCtrl(prefix='', colour='red', pos=(0, 0, 0), grpParent=None):
            c = controls.squareCtrl(size=ctrlSize,
                                    name='%s_CTRL' % prefix,
                                    axis='z')
            c.t.set(pos)
            zero = coreUtils.addParent(c, 'group', '%sCtrl_ZERO' % prefix)
            zero.setParent(self.ctrls_grp)
            pmc.select('%s.cv[ * ]' % coreUtils.getShape(c))
            pmc.scale(.33, scaleY=1)
            coreUtils.colorize(colour, [c])
            self.ctrls.append(c)

            g = coreUtils.addChild(grpParent, 'group', '%s_DRV' % prefix)
            _addControl(g, c)

            return c, g

        def _makeSubCtrls(parent, prefix='', colour='red', grpParent=None):
            for i in range(len(subs.keys())):
                c = controls.squareCtrl(size=ctrlSize * .15,
                                        name='%s_%s_CTRL' %
                                        (prefix, subs[i][0]),
                                        axis='z')
                coreUtils.align(c, parent, parent=1)
                c.tx.set(ctrlSize * subs[i][1])
                coreUtils.addParent(c, 'group',
                                    c.name().replace('_CTRL', 'Ctrl_ZERO'))
                coreUtils.colorize(colour, [c])
                self.ctrls.append(c)

                g = coreUtils.addChild(grpParent, 'group',
                                       '%s_%s_DRV' % (prefix, subs[i][0]))
                j = coreUtils.addChild(g, 'joint',
                                       '%s_%s_JNT' % (prefix, subs[i][0]))
                jEnd = coreUtils.addChild(
                    j, 'joint', '%s_%sEnd_JNT' % (prefix, subs[i][0]))
                jEnd.t.set((ctrlSize * subs[i][1], 0, ctrlSize * .33))
                self.joints.append(jEnd)

                _addControl(g, c)

        subs = {0: ['in', .33], 1: ['mid', 0], 2: ['out', -.33]}
        # rt top lid
        c, g = _makeCtrl('rt_topLid', 'red',
                         (rtPos[0], rtPos[1] +
                          (ctrlSize * .33), rtPos[2] + ctrlSize),
                         rtTopLidAutoGrp)
        _makeSubCtrls(c, 'rt_topLid', 'red', g)

        # rt btm lid
        c, g = _makeCtrl('rt_btmLid', 'red',
                         (rtPos[0], rtPos[1] +
                          (ctrlSize * -.33), rtPos[2] + ctrlSize),
                         rtBtmLidAutoGrp)
        _makeSubCtrls(c, 'rt_btmLid', 'red', g)

        subs = {0: ['in', -.33], 1: ['mid', 0], 2: ['out', .33]}

        # lf top lid
        c, g = _makeCtrl('lf_topLid', 'blue',
                         (lfPos[0], lfPos[1] +
                          (ctrlSize * .33), lfPos[2] + ctrlSize),
                         lfTopLidAutoGrp)
        _makeSubCtrls(c, 'lf_topLid', 'blue', g)

        #lf btm lid
        c, g = _makeCtrl('lf_btmLid', 'blue',
                         (lfPos[0], lfPos[1] +
                          (ctrlSize * -.33), lfPos[2] + ctrlSize),
                         lfBtmLidAutoGrp)
        _makeSubCtrls(c, 'lf_btmLid', 'blue', g)
示例#8
0
def multiPlug(node=None,
              targetList=[],
              targetNames=[],
              settingsNode=None,
              plugType='parent',
              name=''):
    # Argument validation
    if not node or not targetList:
        sel = pmc.selected()
        if len(sel) > 1:
            node = sel[0]
            targetList = [s for s in sel[1:]]
        else:
            return 'Please supply or select node and targetList'
    if type(targetList) != type([]):
        targetList = [targetList]
    if not settingsNode:
        settingsNode = node
    if not targetNames:
        targetNames = [t.name() for t in targetList]

    # main group
    main_grp = pmc.group(empty=1, name='%s_%s_PLUG' % (name, plugType))

    # constrained group
    const_grp = coreUtils.addChild(main_grp,
                                   'group',
                                   name='%s_%s_CONST' % (name, plugType))
    coreUtils.align(const_grp, node)

    if plugType == 'parent':
        pmc.parentConstraint(const_grp, node)
    elif plugType == 'point':
        pmc.pointConstraint(const_grp, node)
    else:
        pmc.orientConstraint(const_grp, node)

    # targets
    targets = []
    for t in range(len(targetList)):
        targ = coreUtils.addChild(main_grp,
                                  'group',
                                  name='%s_%s_TGT' % (name, targetNames[t]))
        coreUtils.align(targ, const_grp)
        pmc.parentConstraint(targetList[t], targ, mo=1)
        targets.append(targ)

    parentEnumString = ''
    for t in targetNames:
        parentEnumString += (t + ':')
    par = pmc.parentConstraint(targets, const_grp)
    pmc.addAttr(settingsNode,
                longName='parent_space',
                at='enum',
                enumName=parentEnumString,
                keyable=True)
    # Set driven keys to drive the weights of the targets in the orient constraint
    parentWeightAliasList = [
        str(w) for w in pmc.parentConstraint(par, q=True, weightAliasList=True)
    ]
    for spaceIndex in range(len(targetList)):
        rv = pmc.createNode('remapValue',
                            name='remapVal_%s_%s_UTL' %
                            (name, targetNames[spaceIndex]))
        settingsNode.parent_space.connect(rv.inputValue)
        rv.inputMin.set(spaceIndex - 1)
        rv.inputMax.set(spaceIndex + 1)
        rv.value[1].value_FloatValue.set(0)
        rv.value[2].value_Position.set(0.5)
        rv.value[2].value_FloatValue.set(1)
        rv.value[2].value_Interp.set(1)
        rv.outValue.connect(parentWeightAliasList[spaceIndex])

    return main_grp
示例#9
0
    def buildLimb(self, joints, leg, cleanup, alignIkToJoints, flip=1):
        if not joints:
            return 'DrLimb: Please supply 4 joints to build limb from'

        # Make duplicate joint chains
        self.tripleChain = systemUtils.tripleChain(joints=joints,
                                                   name=self.name,
                                                   flip=flip)

        self.tripleChain['main_grp'].setParent(self.rig_grp)
        self.const_grp = coreUtils.addParent(self.tripleChain['main_grp'],
                                             'group',
                                             '%s_const_grp' % self.name)

        # Orientation for controls and aim constraints
        axis = 'x'
        aimVec = (1, 0, 0)
        if self.tripleChain['resultChain'][1].tx.get() < 0.0:
            axis = '-x'
            aimVec = (-1, 0, 0)
        ctrlSize = coreUtils.getDistance(
            self.tripleChain['resultChain'][0],
            self.tripleChain['resultChain'][1]) * .25

        # CONTROLS
        # settings ctrl
        self.settingsCtrl = controls.crossCtrl(name='%s_settings_CTRL' %
                                               self.name,
                                               size=ctrlSize)
        self.settingsCtrl.setParent(self.tripleChain['resultChain'][2])
        settingsOffset = ctrlSize * 1.5
        if self.tripleChain['resultChain'][2].tx.get() < 0.0:
            settingsOffset = ctrlSize * -1.5
        if leg:
            settingsOffset = settingsOffset * -1
        self.settingsCtrl.t.set((0, settingsOffset, 0))
        self.settingsCtrl.r.set(0, 0, 0)
        self.settingsCtrl.setParent(self.ctrls_grp)
        pmc.parentConstraint(self.tripleChain['resultChain'][2],
                             self.settingsCtrl,
                             mo=1)
        self.ctrls.append(self.settingsCtrl)
        pmc.addAttr(self.settingsCtrl,
                    ln='ik_fk_blend',
                    at='double',
                    k=1,
                    h=0,
                    minValue=0.0,
                    maxValue=1.0)
        for bc in self.tripleChain['blendColors']:
            self.settingsCtrl.ik_fk_blend.connect(bc.blender)

        # fk top ctrl
        self.fkTopCtrl = controls.circleBumpCtrl(name='%s_top_fk_CTRL' %
                                                 self.name,
                                                 axis=axis,
                                                 radius=ctrlSize)
        coreUtils.align(self.fkTopCtrl, self.tripleChain['fkChain'][0])
        self.fkTopCtrl.setParent(self.ctrls_grp)
        self.fkCtrls_grp = coreUtils.addParent(self.fkTopCtrl, 'group',
                                               '%s_fkCtrls_grp' % self.name)
        self.fkCtrlsConst_grp = coreUtils.addParent(
            self.fkTopCtrl, 'group', '%s_fkConst_grp' % self.name)
        pmc.parentConstraint(self.fkCtrls_grp, self.const_grp)
        self.ctrls.append(self.fkTopCtrl)

        self.settingsCtrl.ik_fk_blend.connect(self.fkCtrls_grp.visibility)

        # fk mid ctrl
        self.fkMidCtrl = controls.circleBumpCtrl(name='%s_mid_fk_CTRL' %
                                                 self.name,
                                                 axis=axis,
                                                 radius=ctrlSize)
        coreUtils.align(self.fkMidCtrl, self.tripleChain['fkChain'][1])
        self.fkMidCtrl.setParent(self.fkTopCtrl)
        coreUtils.addParent(self.fkMidCtrl, 'group',
                            '%s_mid_fkCtrl_ZERO' % self.name)
        self.ctrls.append(self.fkMidCtrl)

        # fk btm ctrl
        self.fkBtmCtrl = controls.circleBumpCtrl(name='%s_btm_fk_CTRL' %
                                                 self.name,
                                                 axis=axis,
                                                 radius=ctrlSize)
        coreUtils.align(self.fkBtmCtrl, self.tripleChain['fkChain'][2])
        self.fkBtmCtrl.setParent(self.fkMidCtrl)
        coreUtils.addParent(self.fkBtmCtrl, 'group',
                            '%s_btm_fkCtrl_ZERO' % self.name)
        self.ctrls.append(self.fkBtmCtrl)

        # rotate order
        for node in [
                self.fkMidCtrl, self.tripleChain['resultChain'][1],
                self.tripleChain['ikChain'][1], self.tripleChain['fkChain'][1]
        ]:
            node.rotateOrder.set(3)

        pmc.parentConstraint(self.fkTopCtrl, self.tripleChain['fkChain'][0])
        pmc.parentConstraint(self.fkMidCtrl,
                             self.tripleChain['fkChain'][1]).rotateOrder.set(4)
        pmc.parentConstraint(self.fkBtmCtrl, self.tripleChain['fkChain'][2])

        # IK ctrl
        self.ikCtrl = controls.boxCtrl(name='%s_ik_CTRL' % self.name,
                                       size=ctrlSize)
        if alignIkToJoints:
            if leg:
                pmc.xform(self.ikCtrl,
                          ws=1,
                          m=coreUtils.getAimMatrix(start=joints[2],
                                                   end=joints[3],
                                                   axis='z',
                                                   upAxis='y',
                                                   worldUpAxis=alignIkToJoints,
                                                   upNode=joints[2]))
            else:
                axis = '-x'
                if self.tripleChain['resultChain'][2].tx.get() < 0.0:
                    axis = 'x'
                pmc.xform(self.ikCtrl,
                          ws=1,
                          m=coreUtils.getAimMatrix(start=joints[2],
                                                   end=joints[3],
                                                   axis=axis,
                                                   upAxis='y',
                                                   worldUpAxis=alignIkToJoints,
                                                   upNode=joints[2]))
        else:
            coreUtils.align(self.ikCtrl,
                            self.tripleChain['ikChain'][2],
                            orient=0)
        self.ikCtrl.setParent(self.ctrls_grp)
        self.ikCtrls_grp = coreUtils.addParent(self.ikCtrl, 'group',
                                               '%s_ikCtrls_ZERO' % self.name)
        self.ctrls.append(self.ikCtrl)

        ik_fk_rev = coreUtils.reverse(self.settingsCtrl.ik_fk_blend,
                                      'rev_%s_ik_fk_blend_UTL' % self.name)
        ik_fk_rev.outputX.connect(self.ikCtrls_grp.visibility)

        pmc.addAttr(self.ikCtrl,
                    longName='stretch',
                    at='double',
                    minValue=0,
                    maxValue=1,
                    defaultValue=0,
                    keyable=True)
        pmc.addAttr(self.ikCtrl, longName='twist', at='double', keyable=True)
        pmc.addAttr(self.ikCtrl,
                    longName='soft',
                    at='double',
                    minValue=0,
                    defaultValue=0,
                    keyable=True)
        pmc.addAttr(self.ikCtrl,
                    longName='mid_pin',
                    at='double',
                    keyable=True,
                    minValue=0,
                    maxValue=1)
        if flip:
            pmc.addAttr(self.ikCtrl,
                        longName='flip_poleVector',
                        at='bool',
                        keyable=True,
                        h=0)
        pmc.addAttr(self.ikCtrl,
                    longName='force_straight',
                    at='double',
                    keyable=True,
                    h=0,
                    minValue=0.0,
                    maxValue=1.0)

        for bc in self.tripleChain['flipBlendColors']:
            self.ikCtrl.flip_poleVector.connect(bc.blender)

        # Soft non-stretchy IK stuff
        ik_grp = coreUtils.addChild(self.rig_grp,
                                    'group',
                                    name='%s_ik_GRP' % self.name)

        softBlend_loc = coreUtils.createAlignedNode(self.ikCtrl,
                                                    'locator',
                                                    name='%s_ikSoftBlend_LOC' %
                                                    self.name)
        softBlend_loc.setParent(ik_grp)

        self.ctrl_loc = coreUtils.createAlignedNode(self.ikCtrl,
                                                    'locator',
                                                    name='%s_ikCtrl_LOC' %
                                                    self.name)
        self.ctrl_loc.setParent(ik_grp)
        if not leg:
            pmc.parentConstraint(self.ikCtrl, self.ctrl_loc)

        aim_loc = coreUtils.addChild(self.const_grp,
                                     'locator',
                                     name='%s_softIkaim_LOC' % self.name)
        pmc.aimConstraint(self.ctrl_loc, aim_loc, upVector=(0, 0, 0))

        btm_loc = coreUtils.createAlignedNode(self.ikCtrl,
                                              'locator',
                                              name='%s_ikBtm_LOC' % self.name)
        btm_loc.setParent(aim_loc)

        chainLen = abs(self.tripleChain['ikChain'][1].tx.get() +
                       self.tripleChain['ikChain'][2].tx.get())

        ctrlDist = coreUtils.distanceBetweenNodes(aim_loc,
                                                  self.ctrl_loc,
                                                  name='dist_%s_ikCtrl_UTL' %
                                                  self.name)
        globalScaleDiv = coreUtils.divide(1.0,
                                          self.main_grp.globalScale,
                                          name='md_%s_globalScaleDiv_UTL' %
                                          self.name)
        isStretchedMult = coreUtils.multiply(ctrlDist.distance,
                                             globalScaleDiv.outputX,
                                             name='md_%s_isStretched_UTL' %
                                             self.name)

        softDist = coreUtils.distanceBetweenNodes(btm_loc,
                                                  softBlend_loc,
                                                  name='dist_%s_soft_UTL' %
                                                  self.name)
        stretchDist = coreUtils.distanceBetweenNodes(
            aim_loc, softBlend_loc, name='dist_%s_stretch_UTL' % self.name)

        chainLenMinusSoft = coreUtils.minus(
            [chainLen, self.ikCtrl.soft],
            name='pma_%s_chainLenMinusSoft_UTL' % self.name)

        isStretchedCond = pmc.createNode('condition',
                                         name='cond_%s_isStretched_UTL' %
                                         self.name)
        isStretchedCond.operation.set(2)
        isStretchedMult.outputX.connect(isStretchedCond.firstTerm)
        chainLenMinusSoft.output1D.connect(isStretchedCond.secondTerm)
        isStretchedMult.outputX.connect(isStretchedCond.colorIfFalseR)

        isSoftCond = pmc.createNode('condition',
                                    name='cond_%s_isSoft_UTL' % self.name)
        isSoftCond.operation.set(2)
        self.ikCtrl.soft.connect(isSoftCond.firstTerm)
        isSoftCond.colorIfFalseR.set(chainLen)

        ctrlDistMinusSoftChain = coreUtils.minus(
            [isStretchedMult.outputX, chainLenMinusSoft.output1D],
            name='pmc_%s_ctrlDistMinusSoftChain_UTL' % self.name)

        divideBySoft = coreUtils.safeDivide(ctrlDistMinusSoftChain.output1D,
                                            self.ikCtrl.soft,
                                            name='md_%s_divideBySoft_UTL' %
                                            self.name)

        invert = coreUtils.multiply(divideBySoft.outputX,
                                    -1,
                                    name='md_%s_invertSoft_UTL' % self.name)

        exp = coreUtils.pow(2.718282,
                            invert.outputX,
                            name='md_%s_exponential_UTL' % self.name)

        multiplyBySoft = coreUtils.multiply(exp.outputX,
                                            self.ikCtrl.soft,
                                            name='md_%s_multiplyBySoft_UTL' %
                                            self.name)

        minusFromChainLen = coreUtils.minus(
            [chainLen, multiplyBySoft.outputX],
            name='md_%s_minusFromChainLen_UTL' % self.name)

        minusFromChainLen.output1D.connect(isSoftCond.colorIfTrueR)

        isSoftCond.outColorR.connect(isStretchedCond.colorIfTrueR)

        isStretchedCond.outColorR.connect(btm_loc.tx)

        # IK Solvers
        ikHandleGrp = coreUtils.createAlignedNode(self.ikCtrl,
                                                  'group',
                                                  name='%s_ikHandle_GRP' %
                                                  self.name)
        ikHandleGrp.setParent(softBlend_loc)
        pmc.orientConstraint(self.ikCtrl, ikHandleGrp, mo=1)

        ikHandle = pmc.ikHandle(solver='ikRPsolver',
                                name='%s_ikHandle' % self.name,
                                startJoint=self.tripleChain['ikChain'][0],
                                endEffector=self.tripleChain['ikChain'][2],
                                setupForRPsolver=1)[0]
        ikHandle.setParent(ikHandleGrp)
        self.ikCtrl.twist.connect(ikHandle.twist)

        endIkHandle = pmc.ikHandle(solver='ikSCsolver',
                                   name='%s_end_ikHandle' % self.name,
                                   startJoint=self.tripleChain['ikChain'][2],
                                   endEffector=self.tripleChain['ikChain'][3],
                                   setupForRPsolver=1)[0]
        endIkHandle.setParent(ikHandleGrp)

        # Flipped solvers
        if flip:
            self.tripleChain['flipChain'][1].preferredAngleY.set(
                self.tripleChain['flipChain'][1].ry.get())
            flip_ikHandle = pmc.ikHandle(
                solver='ikRPsolver',
                name='%s_flip_ikHandle' % self.name,
                startJoint=self.tripleChain['flipChain'][0],
                endEffector=self.tripleChain['flipChain'][2],
                setupForRPsolver=1)[0]
            flip_ikHandle.setParent(ikHandleGrp)
            self.ikCtrl.twist.connect(flip_ikHandle.twist)

            flip_endIkHandle = pmc.ikHandle(
                solver='ikSCsolver',
                name='%s_flip_end_ikHandle' % self.name,
                startJoint=self.tripleChain['flipChain'][2],
                endEffector=self.tripleChain['flipChain'][3],
                setupForRPsolver=1)[0]
            flip_endIkHandle.setParent(ikHandleGrp)

        # Pole Vector
        pvAimGrp = coreUtils.addChild(self.const_grp,
                                      'group',
                                      name='%s_pvAim_GRP' % self.name)
        if leg:
            pmc.aimConstraint(btm_loc,
                              pvAimGrp,
                              mo=0,
                              u=(0, 1, 0),
                              wu=(1, 0, 0),
                              wut='objectRotation',
                              wuo=self.ctrl_loc,
                              aimVector=aimVec)
        else:
            pmc.aimConstraint(btm_loc,
                              pvAimGrp,
                              mo=0,
                              u=(0, 0, 0),
                              aimVector=aimVec)
        self.pvCtrl = controls.crossCtrl(name='%s_pv_CTRL' % self.name,
                                         size=ctrlSize)
        poleOffset = 3
        if '-' in axis:
            poleOffset = -3
        self.pvCtrl.setParent(self.tripleChain['ikChain'][1])
        self.pvCtrl.t.set((0, 0, ctrlSize * poleOffset))
        self.pvCtrl.setParent(self.ikCtrls_grp)
        self.pvZero = coreUtils.addParent(self.pvCtrl, 'group',
                                          '%s_pvCtrl_ZERO' % self.name)
        pmc.poleVectorConstraint(self.pvCtrl, ikHandle)
        self.ctrls.append(self.pvCtrl)

        if flip:
            self.flipPvCtrl = controls.crossCtrl(name='%s_flip_pv_CTRL' %
                                                 self.name,
                                                 size=ctrlSize)
            self.flipPvCtrl.setParent(self.tripleChain['flipChain'][1])
            self.flipPvCtrl.t.set((0, 0, ctrlSize * (poleOffset * -1)))
            self.flipPvCtrl.setParent(self.pvZero)
            self.flipPvZero = coreUtils.addParent(
                self.flipPvCtrl, 'group', '%s_flipPvCtrl_ZERO' % self.name)
            pmc.poleVectorConstraint(self.flipPvCtrl, flip_ikHandle)
            self.ctrls.append(self.flipPvCtrl)

        # stretchy soft IK stuff
        pc = pmc.pointConstraint(btm_loc, self.ctrl_loc, softBlend_loc)
        stretchRev = coreUtils.reverse(self.ikCtrl.stretch,
                                       name='rev_%s_stretch_UTL' % self.name)
        stretchRev.outputX.connect('%s.%sW0' %
                                   (pc.nodeName(), btm_loc.nodeName()))
        self.ikCtrl.stretch.connect('%s.%sW1' %
                                    (pc.nodeName(), self.ctrl_loc.nodeName()))

        scaledSoftDist = coreUtils.multiply(globalScaleDiv.outputX,
                                            softDist.distance,
                                            name='md_%s_scaledSoftDist_UTL' %
                                            self.name)

        # Stretchy Mid
        midLen = coreUtils.multiply(
            (self.tripleChain['ikChain'][1].tx.get() / chainLen),
            scaledSoftDist.outputX,
            name='md_%s_midLen_UTL' % self.name)

        stretchMidLen = coreUtils.multiply(self.ikCtrl.stretch,
                                           midLen.outputX,
                                           name='md_%s_stretchMidLen_UTL' %
                                           self.name)

        stretchMidLenPlusBoneLen = coreUtils.add(
            [self.tripleChain['ikChain'][1].tx.get(), stretchMidLen.outputX],
            name='pma_%s_stretchMidLenPlusBoneLen_UTL' % self.name)

        pinUpperDist = coreUtils.distanceBetweenNodes(
            self.const_grp,
            self.pvCtrl,
            name='dist_%s_pinUpper_UTL' % self.name)
        pinMult = 1.0
        if '-' in axis:
            pinMult = -1.0
        pinUpper_uc = coreUtils.convert(pinUpperDist.distance,
                                        pinMult,
                                        name='uc_%s_pinUpperDist_UTL' %
                                        self.name)
        pinUpperGlobalScale = coreUtils.multiply(
            globalScaleDiv.outputX,
            pinUpper_uc.output,
            name='md_%s_pinUpperGlobalScale_UTL' % self.name)
        pinUpperBlend = coreUtils.blend(
            input1=pinUpperGlobalScale.outputX,
            input2=stretchMidLenPlusBoneLen.output1D,
            blendAttr=self.ikCtrl.mid_pin,
            name='bc_%s_pinUpper_UTL' % self.name)

        # pinUpperBlend.outputR.connect(self.tripleChain['ikChain'][1].tx)
        # pinUpperBlend.outputR.connect(self.tripleChain['flipChain'][1].tx)

        # Stretchy Bot
        botLen = coreUtils.multiply(
            (self.tripleChain['ikChain'][2].tx.get() / chainLen),
            scaledSoftDist.outputX,
            name='md_%s_botLen_UTL' % self.name)

        stretchBotLen = coreUtils.multiply(self.ikCtrl.stretch,
                                           botLen.outputX,
                                           name='md_%s_stretchBotLen_UTL' %
                                           self.name)

        stretchBotLenPlusBoneLen = coreUtils.add(
            [self.tripleChain['ikChain'][2].tx.get(), stretchBotLen.outputX],
            name='pma_%s_stretchBotLenPlusBoneLen_UTL' % self.name)

        pinLowerDist = coreUtils.distanceBetweenNodes(
            softBlend_loc,
            self.pvCtrl,
            name='dist_%s_pinLower_UTL' % self.name)
        pinLower_uc = coreUtils.convert(pinLowerDist.distance,
                                        pinMult,
                                        name='uc_%s_pinLowerDist_UTL' %
                                        self.name)
        pinLowerGlobalScale = coreUtils.multiply(
            globalScaleDiv.outputX,
            pinLower_uc.output,
            name='md_%s_pinLowerGlobalScale_UTL' % self.name)
        pinLowerBlend = coreUtils.blend(
            input1=pinLowerGlobalScale.outputX,
            input2=stretchBotLenPlusBoneLen.output1D,
            blendAttr=self.ikCtrl.mid_pin,
            name='bc_%s_pinLower_UTL' % self.name)

        # pinLowerBlend.outputR.connect(self.tripleChain['ikChain'][2].tx)
        # pinLowerBlend.outputR.connect(self.tripleChain['flipChain'][2].tx)

        # Add ability to force straight arm
        stretchDivGlobal_md = coreUtils.divide(
            stretchDist.distance,
            self.main_grp.globalScale,
            name='md_%s_stretchDivGlobalScale_UTL' % self.name)
        straightUpper_md = coreUtils.multiply(
            stretchDivGlobal_md.outputX,
            self.tripleChain['ikChain'][1].tx.get() / chainLen,
            name='md_%s_midLenTimesChainLen_UTL' % self.name)
        straightLower_md = coreUtils.multiply(
            stretchDivGlobal_md.outputX,
            self.tripleChain['ikChain'][2].tx.get() / chainLen,
            name='md_%s_botLenTimesChainLen_UTL' % self.name)
        straightUpperBlend = coreUtils.blend(
            input1=straightUpper_md.outputX,
            input2=pinUpperBlend.outputR,
            blendAttr=self.ikCtrl.force_straight,
            name='bc_%s_straightUpper_UTL' % self.name)
        straightLowerBlend = coreUtils.blend(
            input1=straightLower_md.outputX,
            input2=pinLowerBlend.outputR,
            blendAttr=self.ikCtrl.force_straight,
            name='bc_%s_straightLower_UTL' % self.name)
        straightUpperBlend.outputR.connect(self.tripleChain['ikChain'][1].tx)
        straightLowerBlend.outputR.connect(self.tripleChain['ikChain'][2].tx)

        if flip:
            straightUpperBlend.outputR.connect(
                self.tripleChain['flipChain'][1].tx)
            straightLowerBlend.outputR.connect(
                self.tripleChain['flipChain'][2].tx)

        # Extract twist
        self.topTwist = coreUtils.extractAxis(
            self.tripleChain['resultChain'][0],
            axis='x',
            name='%s_top_twist' % self.name,
            exposeNode=self.main_grp,
            exposeAttr='top_twist')
        self.topTwist['main_grp'].setParent(self.rig_grp)
        pmc.parentConstraint(self.const_grp, self.topTwist['main_grp'])

        self.midTwist = coreUtils.extractAxis(
            self.tripleChain['resultChain'][1],
            axis='x',
            name='%s_mid_twist' % self.name,
            exposeNode=self.main_grp,
            exposeAttr='mid_twist')
        self.midTwist['main_grp'].setParent(self.rig_grp)
        pmc.pointConstraint(self.tripleChain['resultChain'][1],
                            self.midTwist['main_grp'])
        pmc.orientConstraint(self.topTwist['nonRoll'],
                             self.midTwist['main_grp'])

        btmTwist = coreUtils.extractAxis(self.tripleChain['resultChain'][2],
                                         axis='x',
                                         name='%s_btm_twist' % self.name,
                                         exposeNode=self.main_grp,
                                         exposeAttr='btm_twist')
        btmTwist['main_grp'].setParent(self.rig_grp)
        pmc.pointConstraint(self.tripleChain['resultChain'][2],
                            btmTwist['main_grp'])
        pmc.orientConstraint(self.tripleChain['resultChain'][1],
                             btmTwist['main_grp'])

        # connections
        self.exposeSockets({'poleVectorAim': pvAimGrp})
        self.exposeSockets({'ikCtrl': self.ikCtrl, 'fkCtrl': self.fkBtmCtrl})
        self.exposeSockets({'wrist': self.tripleChain['resultChain'][2]})

        if cleanup:
            self.cleanup()
示例#10
0
    def buildFoot(self, ankle, foot, ball, toe, inner, outer, heel,
                  settingsNode, blendAttr, colour, cleanup):

        # Make duplicate joint chains
        self.tripleChain = systemUtils.tripleChain(
            joints=[ankle, foot, ball, toe], name=self.name, flip=0)
        ikConst_grp = coreUtils.addParent(self.tripleChain['ikChain'][0],
                                          'group',
                                          '%s_ikConst_GRP' % self.name)
        fkConst_grp = coreUtils.addParent(self.tripleChain['fkChain'][0],
                                          'group',
                                          '%s_fkConst_GRP' % self.name)
        resultConst_grp = coreUtils.addParent(
            self.tripleChain['resultChain'][0], 'group',
            '%s_resultConst_GRP' % self.name)

        self.tripleChain['main_grp'].setParent(self.rig_grp)

        if blendAttr:
            par = pmc.parentConstraint(ikConst_grp,
                                       fkConst_grp,
                                       resultConst_grp,
                                       mo=0)
            attr = pmc.Attribute('%s.%sW1' % (par.name(), fkConst_grp.name()))
            blendAttr.connect(attr)
            attr = pmc.Attribute('%s.%sW0' % (par.name(), ikConst_grp.name()))
            blend_rev = coreUtils.reverse(blendAttr,
                                          'reverse_%s_blend, UTL' % self.name)
            blend_rev.outputX.connect(attr)

            for bc in self.tripleChain['blendColors']:
                blendAttr.connect(bc.blender)

        # Orientation for controls
        axis = 'x'
        if self.tripleChain['resultChain'][1].tx.get() < 0.0:
            axis = '-x'
        ctrlSize = coreUtils.getDistance(
            self.tripleChain['resultChain'][0],
            self.tripleChain['resultChain'][1]) * .5

        # ikHandles
        footIkHandle = pmc.ikHandle(solver='ikRPsolver',
                                    name='%s_foot_ikHandle' % self.name,
                                    startJoint=self.tripleChain['ikChain'][0],
                                    endEffector=self.tripleChain['ikChain'][1],
                                    setupForRPsolver=1)[0]
        footIkHandle.setParent(self.rig_grp)
        footIkHandleConst = coreUtils.addParent(
            footIkHandle, 'group', '%s_footIkHandle_CONST' % self.name)

        ballIkHandle = pmc.ikHandle(solver='ikRPsolver',
                                    name='%s_ball_ikHandle' % self.name,
                                    startJoint=self.tripleChain['ikChain'][1],
                                    endEffector=self.tripleChain['ikChain'][2],
                                    setupForRPsolver=1)[0]
        ballIkHandle.setParent(self.rig_grp)
        ballIkHandleConst = coreUtils.addParent(
            ballIkHandle, 'group', '%s_ballIkHandle_CONST' % self.name)

        toeIkHandle = pmc.ikHandle(solver='ikRPsolver',
                                   name='%s_toe_ikHandle' % self.name,
                                   startJoint=self.tripleChain['ikChain'][2],
                                   endEffector=self.tripleChain['ikChain'][3],
                                   setupForRPsolver=1)[0]
        toeIkHandle.setParent(self.rig_grp)
        toeIkHandleConst = coreUtils.addParent(
            toeIkHandle, 'group', '%s_toeIkHandle_CONST' % self.name)

        # ikCtrls
        self.heelIkCtrl = controls.squareCtrl(name='%s_heel_ik_CTRL' %
                                              self.name,
                                              axis=axis,
                                              size=ctrlSize)
        coreUtils.align(self.heelIkCtrl, heel)
        self.heelIkCtrl.setParent(self.ctrls_grp)
        self.ikCtrls_grp = coreUtils.addParent(self.heelIkCtrl, 'group',
                                               '%s_ikCtrls_GRP' % self.name)
        coreUtils.addParent(self.heelIkCtrl, 'group',
                            '%s_heelIkCtrl_ZERO' % self.name)
        self.ctrls.append(self.heelIkCtrl)

        self.toeIkCtrl = controls.squareCtrl(name='%s_toe_ik_CTRL' % self.name,
                                             axis=axis,
                                             size=ctrlSize)
        coreUtils.align(self.toeIkCtrl, self.tripleChain['ikChain'][3])
        self.toeIkCtrl.setParent(self.heelIkCtrl)
        coreUtils.addParent(self.toeIkCtrl, 'group',
                            '%s_toeIkCtrl_ZERO' % self.name)
        self.ctrls.append(self.toeIkCtrl)

        self.innerLoc = coreUtils.createAlignedNode(inner, 'group',
                                                    '%s_inner_GRP' % self.name)
        self.innerLoc.setParent(self.toeIkCtrl)
        innerZero = coreUtils.addParent(self.innerLoc, 'group',
                                        '%s_inner_ZERO' % self.name)

        self.outerLoc = coreUtils.createAlignedNode(outer, 'group',
                                                    '%s_outer_GRP' % self.name)
        self.outerLoc.setParent(self.innerLoc)
        outerZero = coreUtils.addParent(self.outerLoc, 'group',
                                        '%s_outer_ZERO' % self.name)

        self.ballPivotIkCtrl = controls.squareCtrl(
            name='%s_ballPivot_ik_CTRL' % self.name, axis=axis, size=ctrlSize)
        coreUtils.align(self.ballPivotIkCtrl, self.tripleChain['ikChain'][2])
        self.ballPivotIkCtrl.setParent(self.outerLoc)
        coreUtils.addParent(self.ballPivotIkCtrl, 'group',
                            '%s_ballPivotIkCtrl_ZERO' % self.name)
        inv_grp = coreUtils.addParent(self.ballPivotIkCtrl, 'group',
                                      '%s_ballPivotIkCtrlRotX_INV' % self.name)
        inv_uc = coreUtils.convert(self.ballPivotIkCtrl.rx,
                                   -1.0,
                                   name='uc_%s_ballPivotIkCtrlRotX_UTL' %
                                   self.name)
        inv_uc.output.connect(inv_grp.rx)

        pmc.parentConstraint(self.ballPivotIkCtrl, toeIkHandleConst, mo=1)
        self.ctrls.append(self.ballPivotIkCtrl)

        self.ballPivotIkCtrl.rx.connect(self.outerLoc.rx)
        pmc.transformLimits(self.innerLoc, rx=(-45, 0), erx=(0, 1))

        self.ballPivotIkCtrl.rx.connect(self.innerLoc.rx)
        pmc.transformLimits(self.outerLoc, rx=(0, 45), erx=(1, 0))

        self.ballIkCtrl = controls.squareCtrl(name='%s_ball_ik_CTRL' %
                                              self.name,
                                              axis=axis,
                                              size=ctrlSize)
        coreUtils.align(self.ballIkCtrl, self.tripleChain['ikChain'][2])
        self.ballIkCtrl.setParent(self.ballPivotIkCtrl)
        coreUtils.addParent(self.ballIkCtrl, 'group',
                            '%s_ballIkCtrl_ZERO' % self.name)
        pmc.parentConstraint(self.ballIkCtrl, ballIkHandleConst, mo=1)
        self.ctrls.append(self.ballIkCtrl)

        self.footIkCtrl = controls.squareCtrl(name='%s_foot_ik_CTRL' %
                                              self.name,
                                              axis=axis,
                                              size=ctrlSize)
        coreUtils.align(self.footIkCtrl, self.tripleChain['ikChain'][1])
        self.footIkCtrl.setParent(self.ballIkCtrl)
        coreUtils.addParent(self.footIkCtrl, 'group',
                            '%s_footIkCtrl_ZERO' % self.name)
        pmc.parentConstraint(self.footIkCtrl, footIkHandleConst, mo=1)
        pmc.parentConstraint(self.footIkCtrl, ikConst_grp, mo=1)
        self.ctrls.append(self.footIkCtrl)

        # fkCtrls
        self.footFkCtrl = controls.squareCtrl(name='%s_foot_fk_CTRL' %
                                              self.name,
                                              axis=axis,
                                              size=ctrlSize)
        coreUtils.align(self.footFkCtrl, self.tripleChain['fkChain'][1])
        self.footFkCtrl.setParent(self.ctrls_grp)
        self.fkCtrls_grp = coreUtils.addParent(self.footFkCtrl, 'group',
                                               '%s_fkCtrls_GRP' % self.name)
        coreUtils.addParent(self.footFkCtrl, 'group',
                            '%s_footFkCtrl_ZERO' % self.name)
        pmc.parentConstraint(self.footFkCtrl, self.tripleChain['fkChain'][1])
        self.ctrls.append(self.footFkCtrl)

        self.ballFkCtrl = controls.squareCtrl(name='%s_ball_fk_CTRL' %
                                              self.name,
                                              axis=axis,
                                              size=ctrlSize)
        coreUtils.align(self.ballFkCtrl, self.tripleChain['fkChain'][2])
        self.ballFkCtrl.setParent(self.footFkCtrl)
        coreUtils.addParent(self.ballFkCtrl, 'group',
                            '%s_ballFkCtrl_ZERO' % self.name)
        pmc.parentConstraint(self.ballFkCtrl, self.tripleChain['fkChain'][2])
        self.ctrls.append(self.ballFkCtrl)

        coreUtils.colorize(colour, self.ctrls)

        for ctrl in self.ctrls:
            pmc.select('%s.cv[*]' % ctrl.name())
            if ctrl != self.ballPivotIkCtrl:
                pmc.scale(3.0, scaleZ=1)
            else:
                pmc.scale(3.0, scaleY=1)

        pmc.parentConstraint(self.fkCtrls_grp, fkConst_grp, mo=1)

        for joint in self.tripleChain['resultChain']:
            self.joints.append(joint)

        # connections
        self.exposeSockets({'ikFoot': self.tripleChain['ikChain'][0]})

        if cleanup:
            self.cleanup()
示例#11
0
    def buildFoot(self, ankle, foot, ball, toe, inner, outer, heel,
                  settingsNode, blendAttr, colour, cleanup):

        # Make duplicate joint chains
        self.tripleChain = systemUtils.tripleChain(joints=[ankle, foot, toe],
                                                   name=self.name,
                                                   flip=0)
        ikConst_grp = coreUtils.addParent(self.tripleChain['ikChain'][0],
                                          'group',
                                          '%s_ikConst_GRP' % self.name)
        fkConst_grp = coreUtils.addParent(self.tripleChain['fkChain'][0],
                                          'group',
                                          '%s_fkConst_GRP' % self.name)
        resultConst_grp = coreUtils.addParent(
            self.tripleChain['resultChain'][0], 'group',
            '%s_resultConst_GRP' % self.name)

        self.tripleChain['main_grp'].setParent(self.rig_grp)

        if blendAttr:
            par = pmc.parentConstraint(ikConst_grp,
                                       fkConst_grp,
                                       resultConst_grp,
                                       mo=0)
            attr = pmc.Attribute('%s.%sW1' % (par.name(), fkConst_grp.name()))
            blendAttr.connect(attr)
            attr = pmc.Attribute('%s.%sW0' % (par.name(), ikConst_grp.name()))
            blend_rev = coreUtils.reverse(blendAttr,
                                          'reverse_%s_blend, UTL' % self.name)
            blend_rev.outputX.connect(attr)

            for bc in self.tripleChain['blendColors']:
                blendAttr.connect(bc.blender)

        # Orientation for controls
        axis = 'x'
        if self.tripleChain['resultChain'][1].tx.get() < 0.0:
            axis = '-x'
        ctrlSize = coreUtils.getDistance(
            self.tripleChain['resultChain'][0],
            self.tripleChain['resultChain'][1]) * .5

        # ikHandles
        ballIkHandle = pmc.ikHandle(solver='ikRPsolver',
                                    name='%s_ball_ikHandle' % self.name,
                                    startJoint=self.tripleChain['ikChain'][0],
                                    endEffector=self.tripleChain['ikChain'][1],
                                    setupForRPsolver=1)[0]
        ballIkHandle.setParent(self.rig_grp)
        ballIkHandleConst = coreUtils.addParent(
            ballIkHandle, 'group', '%s_ballIkHandle_CONST' % self.name)

        toeIkHandle = pmc.ikHandle(solver='ikRPsolver',
                                   name='%s_toe_ikHandle' % self.name,
                                   startJoint=self.tripleChain['ikChain'][1],
                                   endEffector=self.tripleChain['ikChain'][2],
                                   setupForRPsolver=1)[0]
        toeIkHandle.setParent(self.rig_grp)
        toeIkHandleConst = coreUtils.addParent(
            toeIkHandle, 'group', '%s_toeIkHandle_CONST' % self.name)

        # ikCtrls
        self.heelLoc = coreUtils.createAlignedNode(heel, 'group',
                                                   '%s_heel_GRP' % self.name)
        self.heelLoc.setParent(self.rig_grp)
        self.ikRig_grp = coreUtils.addParent(self.heelLoc, 'group',
                                             '%s_heel_ZERO' % self.name)

        self.toeLoc = coreUtils.createAlignedNode(toe, 'group',
                                                  '%s_toe_GRP' % self.name)
        self.toeLoc.setParent(self.heelLoc)

        self.innerLoc = coreUtils.createAlignedNode(inner, 'group',
                                                    '%s_inner_GRP' % self.name)
        self.innerLoc.setParent(self.toeLoc)
        innerZero = coreUtils.addParent(self.innerLoc, 'group',
                                        '%s_inner_ZERO' % self.name)

        self.outerLoc = coreUtils.createAlignedNode(outer, 'group',
                                                    '%s_outer_GRP' % self.name)
        self.outerLoc.setParent(self.innerLoc)
        outerZero = coreUtils.addParent(self.outerLoc, 'group',
                                        '%s_outer_ZERO' % self.name)

        self.ballPivotLoc = coreUtils.createAlignedNode(
            ball, 'group', '%s_ballPivot_GRP' % self.name)
        self.ballPivotLoc.setParent(self.outerLoc)
        coreUtils.addParent(self.ballPivotLoc, 'group',
                            '%s_ballPivot_ZERO' % self.name)

        pmc.transformLimits(self.innerLoc, rx=(-45, 0), erx=(0, 1))

        pmc.transformLimits(self.outerLoc, rx=(0, 45), erx=(1, 0))

        self.ballLoc = coreUtils.createAlignedNode(foot, 'group',
                                                   '%s_ball_GRP' % self.name)
        self.ballLoc.setParent(self.ballPivotLoc)
        self.ballZero = coreUtils.addParent(self.ballLoc, 'group',
                                            '%s_ball_ZERO' % self.name)
        self.toeWiggleLoc = coreUtils.addChild(self.ballZero, 'group',
                                               '%s_toeWiggle_GRP' % self.name)
        pmc.parentConstraint(self.ballLoc, ballIkHandleConst, mo=1)
        pmc.parentConstraint(self.toeWiggleLoc, toeIkHandleConst, mo=1)

        # driver attributes
        for attrName in [
                'roll_heel', 'roll_ball', 'roll_toe', 'pivot_heel',
                'pivot_ball', 'pivot_toe', 'tilt_side', 'lean_ankle',
                'wiggle_toe', 'lean_toe'
        ]:
            pmc.addAttr(settingsNode, ln=attrName, at='double', k=1, h=0)

        attr = pmc.Attribute('%s.roll_heel' % settingsNode.name())
        attr.connect(self.heelLoc.ry)

        attr = pmc.Attribute('%s.roll_ball' % settingsNode.name())
        attr.connect(self.ballLoc.ry)

        attr = pmc.Attribute('%s.roll_toe' % settingsNode.name())
        attr.connect(self.toeLoc.ry)

        attr = pmc.Attribute('%s.pivot_heel' % settingsNode.name())
        attr.connect(self.heelLoc.rz)

        attr = pmc.Attribute('%s.pivot_ball' % settingsNode.name())
        attr.connect(self.ballPivotLoc.rz)

        attr = pmc.Attribute('%s.pivot_toe' % settingsNode.name())
        attr.connect(self.toeLoc.rz)

        attr = pmc.Attribute('%s.tilt_side' % settingsNode.name())
        attr.connect(self.innerLoc.rx)
        attr.connect(self.outerLoc.rx)

        attr = pmc.Attribute('%s.lean_ankle' % settingsNode.name())
        attr.connect(self.ballLoc.rx)

        attr = pmc.Attribute('%s.wiggle_toe' % settingsNode.name())
        attr.connect(self.toeWiggleLoc.ry)

        attr = pmc.Attribute('%s.lean_toe' % settingsNode.name())
        attr.connect(self.toeWiggleLoc.rx)

        # fkCtrl
        self.ballFkCtrl = controls.pinCtrl(name='%s_ball_fk_CTRL' % self.name,
                                           axis=axis,
                                           radius=ctrlSize)
        coreUtils.align(self.ballFkCtrl, self.tripleChain['fkChain'][1])
        self.ballFkCtrl.setParent(self.ctrls_grp)
        self.ballFkCtrlZero = coreUtils.addParent(
            self.ballFkCtrl, 'group', '%s_ballFkCtrl_ZERO' % self.name)
        pmc.parentConstraint(self.ballFkCtrl, self.tripleChain['fkChain'][1])

        coreUtils.colorize(colour, [self.ballFkCtrl])

        pmc.parentConstraint(self.ballFkCtrlZero, fkConst_grp, mo=1)

        for joint in self.tripleChain['resultChain']:
            self.joints.append(joint)

        # connections
        self.exposeSockets({'ikFoot': self.tripleChain['ikChain'][0]})

        if cleanup:
            self.cleanup()
示例#12
0
    def buildRail(self, crv, numCtrls, numSubCtrls, cleanup):
        if not crv:
            return 'Please provide a curve on which to build your rail'

        ctrlSize = coreUtils.getDistance(crv.getCV(0), crv.getCV(1)) * .25

        self.noXform_grp = coreUtils.addChild(self.rig_grp, 'group',
                                              '%s_noXform_GRP' % self.name)
        self.noXform_grp.inheritsTransform.set(0)

        self.const_grp = coreUtils.addChild(self.rig_grp, 'group',
                                            '%s_CONST' % self.name)

        self.upLoc = coreUtils.addChild(self.rig_grp, 'locator',
                                        '%s_up_LOC' % self.name)
        up_vp = pmc.createNode('vectorProduct',
                               name='vecProd_%s_up_UTL' % self.name)
        self.upLoc.worldMatrix[0].connect(up_vp.matrix)
        up_vp.operation.set(3)
        up_vp.input1.set((0, 1, 0))

        mps = curveUtils.nodesAlongCurve(crv,
                                         numNodes=numCtrls,
                                         name='%s_tangent' % self.name)
        subPoints = [mp.allCoordinates.get() for mp in mps['mpNodes']]

        for i in range(numCtrls):
            mp = mps['grps'][i]
            mp.setParent(self.noXform_grp)
            num = str(i + 1).zfill(2)

            d = curveUtils.curveTangentMatrix(mp, up_vp,
                                              '%s_%s' % (self.name, num))

            g = coreUtils.addChild(self.const_grp, 'group',
                                   '%s_rail_%s_GRP' % (self.name, num))
            d.outputTranslate.connect(g.t)
            d.outputRotate.connect(g.r)

            c = controls.circleBumpCtrl(axis='z',
                                        radius=ctrlSize,
                                        name='%s_%s_CTRL' % (self.name, num))
            coreUtils.align(c, g)
            c.setParent(self.ctrls_grp)
            zero = coreUtils.addParent(c, 'group',
                                       '%s_%sCtrl_ZERO' % (self.name, num))
            const = coreUtils.addParent(zero, 'group',
                                        '%s_%sCtrl_CONST' % (self.name, num))
            pmc.parentConstraint(g, const, mo=0)
            self.ctrls.append(c)

        pmc.addAttr(self.main_grp,
                    ln='start_uValue',
                    at='double',
                    k=1,
                    h=0,
                    minValue=0.0,
                    maxValue=1.0)
        pmc.addAttr(self.main_grp,
                    ln='end_uValue',
                    at='double',
                    k=1,
                    h=0,
                    minValue=0.0,
                    maxValue=1.0)

        self.main_grp.start_uValue.connect(mps['mpNodes'][0].uValue)
        self.main_grp.end_uValue.connect(mps['mpNodes'][-1].uValue)

        # Set up blending of sub curveInfo nodes between start and end
        for i in range(1, numCtrls - 1):
            mp = mps['mpNodes'][i]
            bc = coreUtils.blend(mps['mpNodes'][-1].uValue,
                                 mps['mpNodes'][0].uValue,
                                 name='blend_%s_%s_uValue_UTL' %
                                 (self.name, str(i + 1).zfill(2)))
            bc.blender.set((1.0 / (numCtrls - 1)) * i)
            bc.outputR.connect(mp.uValue)

        # Build sub curve
        locs_grp = coreUtils.addChild(self.rig_grp, 'group',
                                      '%s_subCrvLocs_GRP' % self.name)
        self.subCrv = curveUtils.curveThroughPoints(positions=subPoints,
                                                    name='%s_sub' % self.name)
        self.subCrv.setParent(self.noXform_grp)
        self.locs = curveUtils.connectCurve(self.subCrv)
        for i in range(numCtrls):
            loc = self.locs[i]
            loc.setParent(locs_grp)
            driven = coreUtils.addParent(loc, 'group',
                                         loc.name().replace('_LOC', 'Loc_DRV'))
            zero = coreUtils.addParent(loc, 'group',
                                       loc.name().replace('_LOC', 'Loc_ZERO'))
            self.ctrls[i].t.connect(loc.t)
            self.ctrls[i].getParent().t.connect(zero.t)
            mps['mpNodes'][i].rotate.connect(driven.r)
            mps['mpNodes'][i].allCoordinates.connect(driven.t)

        # Create joints and subCtrls
        subMps = curveUtils.nodesAlongCurve(self.subCrv,
                                            numNodes=numSubCtrls,
                                            name='%s_subTangent' % self.name)
        subCtrls_grp = coreUtils.addChild(self.ctrls_grp, 'group',
                                          '%s_subCtrls_GRP' % self.name)
        for i in range(numSubCtrls):
            num = str(i + 1).zfill(2)
            mp = subMps['grps'][i]
            mp.setParent(self.noXform_grp)
            d = curveUtils.curveTangentMatrix(mp, up_vp,
                                              '%sSub_%s' % (self.name, num))

            g = coreUtils.addChild(self.const_grp, 'group',
                                   '%s_subRail_%s_GRP' % (self.name, num))
            d.outputTranslate.connect(g.t)
            d.outputRotate.connect(g.r)

            driven = coreUtils.addChild(self.noXform_grp, 'group',
                                        '%s_subRail_%s_DRV' % (self.name, num))
            self.drivenGrps.append(driven)
            d.outputTranslate.connect(driven.t)
            d.outputRotate.connect(driven.r)

            c = controls.circleCtrl(axis='z',
                                    radius=ctrlSize * .33,
                                    name='%s_%s_sub_CTRL' % (self.name, num))
            coreUtils.align(c, g)
            c.setParent(subCtrls_grp)
            zero = coreUtils.addParent(c, 'group',
                                       '%s_%sSubCtrl_ZERO' % (self.name, num))
            const = coreUtils.addParent(
                zero, 'group', '%s_%sSubCtrl_CONST' % (self.name, num))
            pmc.parentConstraint(g, const, mo=0)
            self.subCtrls.append(c)

            j = coreUtils.addChild(driven, 'joint',
                                   '%s_%s_JNT' % (self.name, num))
            c.t.connect(j.t)
            c.r.connect(j.r)
            self.joints.append(j)

        pmc.addAttr(self.main_grp, ln='sub_ctrls_vis', at='bool', k=0, h=0)
        pmc.setAttr(self.main_grp.sub_ctrls_vis, channelBox=1)
        self.main_grp.sub_ctrls_vis.connect(subCtrls_grp.visibility)

        if cleanup:
            self.cleanup()