def createRootTransform(self, ctrlBody, grpTorso, spineInfo,
                            spineStretchNameDiv, *args):
        # we are trying to normalize this value so the spine stretches properly
        rootName = "rootTransform"
        grpRootTransformName = "GRP_" + rootName

        grpRootTransform = mc.group(n=grpRootTransformName, em=True, w=True)
        mc.parent(ctrlBody, grpTorso, grpRootTransform)
        globalScaleNormalizeDiv = "globalScale_spineNormalize_DIV"
        mc.shadingNode("multiplyDivide", n=globalScaleNormalizeDiv, au=True)
        mc.setAttr("{0}.operation".format(globalScaleNormalizeDiv), 2)

        mc.connectAttr("{0}.arcLength".format(spineInfo),
                       "{0}.i1x".format(globalScaleNormalizeDiv))
        mc.connectAttr("{0}.sy".format(grpRootTransformName),
                       "{0}.i2x".format(globalScaleNormalizeDiv))
        # we want to overwrite the old version
        mc.connectAttr("{0}.ox".format(globalScaleNormalizeDiv),
                       "{0}.i1x".format(spineStretchNameDiv),
                       f=True)

        # creates the control
        ctrlRoot, fkShape = CRU.createCTRLsFKDirect(grpRootTransformName,
                                                    50,
                                                    orientVal=(0, 1, 0),
                                                    colourTU=13,
                                                    addPrefix="CTRL")

        ctrlRootRename = ctrlRoot.replace("_GRP_", "_")
        ctrlRoot = mc.rename(ctrlRoot, ctrlRootRename)
        CRU.layerEdit(ctrlRoot, bodyLayer=True, noRecurse=True, colourTU=13)

        CRU.lockHideCtrls(ctrlRoot, visibility=True)

        return globalScaleNormalizeDiv
예제 #2
0
    def neckCleanUpExtras(self, cbJaw, grpJaw, ctrlJaw, cbEyes, eyeCtrlArray,
                          eyesCtrl, eyeGrpArray, eyesGrp, grpHeadDNT,
                          jntArrayHead, ikNeckEnd, checkHead, *args):
        if checkHead:
            mc.parent(jntArrayHead[0], grpHeadDNT)

        if cbJaw:
            CRU.lockHideCtrls(grpJaw,
                              translate=True,
                              rotate=True,
                              scale=True,
                              visibility=True)
            CRU.lockHideCtrls(ctrlJaw,
                              translate=True,
                              scale=True,
                              visibility=True)

        if cbEyes:
            # lock and hide the group values for the eyes
            CRU.lockHideCtrls(eyesGrp,
                              translate=True,
                              rotate=True,
                              scale=True,
                              visibility=True)
            for i in range(len(eyeGrpArray)):
                CRU.lockHideCtrls(eyeGrpArray[i],
                                  translate=True,
                                  rotate=True,
                                  scale=True,
                                  visibility=True)

            # lock and hide all but the translates for the individual eyes
            for i in range(len(eyeCtrlArray)):
                CRU.lockHideCtrls(eyeCtrlArray[i],
                                  rotate=True,
                                  scale=True,
                                  visibility=True)

            # lock and hide the scale and visible eyes control
            CRU.lockHideCtrls(eyesCtrl, scale=True, visibility=True)
        # I'm just going to hardcode this bit for simplicity's sake

        grpGeoHead = "GRP_GEO_head"
        if mc.objExists(grpGeoHead):
            mc.parentConstraint(ikNeckEnd, grpGeoHead, mo=True)
            mc.parent(grpGeoHead, grpHeadDNT)

        if checkHead:
            altBnds = [
                x for x in jntArrayHead if "eye" in x.lower()
                or "jaw1" in x.lower() or "end" in x.lower()
            ]
            CRU.layerEdit(jntArrayHead, bndLayer=True, noRecurse=True)
            CRU.layerEdit(altBnds, bndAltLayer=True, noRecurse=True)
예제 #3
0
    def neckCleanUp(self, jntArray, fkJnts, ikNeckBase, ikNeckEnd, hdlNeck,
                    crvNeck, grpHead, grpNeckFK, ctrlHead, *args):

        # Make the objects invisible
        mc.setAttr("{0}.v".format(ikNeckBase), False)
        mc.setAttr("{0}.v".format(ikNeckEnd), False)
        mc.setAttr("{0}.v".format(hdlNeck), False)
        mc.setAttr("{0}.v".format(crvNeck), False)
        # mc.setAttr("{0}.v".format(jntArray[0]), False)

        grpHeadDNT = "GRP_DO_NOT_TOUCH_head"
        mc.group(n=grpHeadDNT, w=True, em=True)
        parentFK = mc.listRelatives(jntArray[0], p=True)[0]
        mc.parent(grpHeadDNT, parentFK)
        mc.parent(jntArray[0], ikNeckBase, ikNeckEnd, hdlNeck, crvNeck,
                  grpHeadDNT)

        # hide scale on ctrlHead
        CRU.lockHideCtrls(ctrlHead, scale=True)

        # hide translate, scale, radius on FK Control
        CRU.lockHideCtrls(fkJnts[0], scale=True, translate=True)
        CRU.lockHideCtrls(fkJnts[0],
                          theVals=["radi"],
                          channelBox=False,
                          toLock=True,
                          attrVisible=False)

        CRU.lockHideCtrls(grpHead,
                          translate=True,
                          rotate=True,
                          scale=True,
                          visibility=True)
        CRU.lockHideCtrls(grpNeckFK,
                          translate=True,
                          rotate=True,
                          scale=True,
                          visibility=True)
        CRU.lockHideCtrls(ikNeckEnd,
                          translate=True,
                          rotate=True,
                          scale=True,
                          visibility=True)

        CRU.layerEdit(jntArray, bndLayer=True, noRecurse=True)

        altBnds = [x for x in jntArray if "end" in x.lower()]
        CRU.layerEdit(altBnds, bndAltLayer=True, noRecurse=True)
        return grpHeadDNT
예제 #4
0
    def createHeadCtrls(self, ikNeckEnd, *args):
        # Creates the head control
        ctrlHeadName = "CTRL_head"
        ctrlHeadPre, ctrlHeadPreName = CRU.setupCtrl(
            ikNeckEnd,
            14,
            orientVal=(0, 1, 0),
            colourTU=CRU.clrBodyFK,
        )
        ctrlHead = mc.rename(ctrlHeadPre, ctrlHeadName)
        todelete = mc.pointConstraint(ikNeckEnd, ctrlHead)
        mc.delete(todelete)

        mc.makeIdentity(ctrlHead, apply=True, t=True, r=True, s=True)
        mc.select(ctrlHead + ".cv[:]")
        mc.move(20, y=True, r=True, os=True, wd=True)
        CRU.changeRotateOrder([ctrlHead], "ZXY")
        CRU.layerEdit([ctrlHead], ikLayer=True, noRecurse=True)
        mc.parentConstraint(ctrlHead, ikNeckEnd, mo=True)

        return ctrlHead
    def spineCleanup(self, ctrlFKJnts, ctrlFKJntsEnds, grpFKConsts, grpTorso,
                     ctrlBody, spineIKs, spineIKCtrls, crvSpine, hdlSpine,
                     jntArray, *args):  # lock attributes

        # lock the translate/scale for the control joints
        for i in range(len(ctrlFKJnts)):
            CRU.lockHideCtrls(ctrlFKJnts[i],
                              translate=True,
                              scale=True,
                              visibility=True)
            CRU.lockHideCtrls(ctrlFKJnts[i],
                              theVals=["radi"],
                              channelBox=False,
                              toLock=True,
                              attrVisible=False)

        # lock everything for the other fk bones
        for i in range(len(ctrlFKJntsEnds)):
            CRU.lockHideCtrls(ctrlFKJntsEnds[i],
                              translate=True,
                              scale=True,
                              rotate=True,
                              visibility=True)
            CRU.lockHideCtrls(ctrlFKJntsEnds[i],
                              theVals=["radi"],
                              channelBox=False,
                              toLock=True,
                              attrVisible=False)

        # lock everything except visibility for grpTorso
        CRU.lockHideCtrls(
            grpTorso,
            translate=True,
            scale=True,
            rotate=True,
        )

        # lock everything for the grpFK Consts
        for i in range(len(grpFKConsts)):
            CRU.lockHideCtrls(ctrlFKJntsEnds[i],
                              translate=True,
                              scale=True,
                              rotate=True,
                              visibility=True)

        # lock and hide the scale and visibility for everything else
        CRU.lockHideCtrls(ctrlBody, scale=True, visibility=True)

        for i in range(len(spineIKs)):
            CRU.lockHideCtrls(spineIKs[i], scale=True)

        for i in range(len(spineIKCtrls)):
            CRU.lockHideCtrls(spineIKCtrls[i], visibility=True, scale=True)

        mc.setAttr('{0}.v'.format(crvSpine), False)
        mc.setAttr('{0}.v'.format(hdlSpine), False)

        CRU.lockHideCtrls(crvSpine, visibility=True)
        CRU.lockHideCtrls(hdlSpine, visibility=True)

        CRU.layerEdit(ctrlFKJnts,
                      fkLayer=True,
                      noRecurse=True,
                      colourTU=CRU.clrBodyFK)
        CRU.layerEdit(ctrlFKJntsEnds,
                      fkLayer=True,
                      noRecurse=True,
                      colourTU=CRU.clrBodyFK)
        CRU.layerEdit(spineIKCtrls,
                      ikLayer=True,
                      noRecurse=True,
                      colourTU=CRU.clrBodyIK)
        CRU.layerEdit(jntArray, bndLayer=True, noRecurse=True, layerState=1)

        altBnds = [x for x in jntArray if "end" in x.lower()]
        CRU.layerEdit(altBnds, bndAltLayer=True, noRecurse=True, layerState=1)

        CRU.layerEdit(ctrlBody,
                      bodyLayer=True,
                      noRecurse=True,
                      colourTU=CRU.clrBodyMain)
예제 #6
0
    def createFKJntAndCtrls(self, jntArray, jntEnd, jntEndSize, *args):

        mc.select(cl=True)
        # create FK joints, then orient them to world
        fkJnts = []
        ctrlFKJntsTU = []
        addFKJnt = False
        grpFKConsts = []
        ctrlFKJntsEnds = []

        jntSize = len(jntArray)

        for i in range(0, jntSize):
            if i == jntSize - 1:
                lastTerm = "End"
            elif i == 0:
                lastTerm = "Base"
                addFKJnt = True
            else:
                # we only care if it's the first or last
                continue

            fkName = "JNT_FK_neck{0}".format(lastTerm)

            pos = mc.xform(jntArray[i],
                           query=True,
                           translation=True,
                           worldSpace=True)
            fkJnts.append(mc.joint(name=fkName, p=pos, rad=jntEndSize * 2))

            if addFKJnt:
                ctrlFKJntsTU.append(fkName)

            else:
                # creates the names for GRP_FKConsts
                ctrlFKJntsEnds.append(fkName)
                grpFKConsts.append("GRP_FKConst{0}".format(lastTerm))

            mc.setAttr('{0}.overrideEnabled'.format(fkName), 1)
            mc.setAttr("{0}.overrideColor".format(fkName), 28)

            addFKJnt = False
        # change the rotate order
        CRU.changeRotateOrder([fkJnts[0]], "YZX")
        for i in range(len(fkJnts) - 1):
            mc.joint(fkJnts[i],
                     e=True,
                     zso=True,
                     oj="yxz",
                     secondaryAxisOrient="xup")

        # create the FK control and move it into a nice position
        ctrlFK, ctrlShape = CRU.createCTRLsFKDirect(fkJnts[0],
                                                    10,
                                                    orientVal=(0, 1, 0),
                                                    colourTU=CRU.clrBodyIK)
        # ctrlShape = mc.listRelatives(ctrlFK, s=True, )[0]
        fkJnts[0] = ctrlFK

        fkLength = mc.getAttr("{0}.ty".format(fkJnts[-1]))
        cvsToMove = mc.select(ctrlShape + ".cv[:]")
        mc.move(fkLength * .35, cvsToMove, y=True, r=True, wd=True, os=True)

        CRU.layerEdit(fkJnts, fkLayer=True, noRecurse=True)

        return ctrlFK, fkJnts