Ejemplo n.º 1
0
    def __baseControls(self):
        ## world control
        oCtrl_world = controls.create('world',
                                      sSide='middle',
                                      iStacks=1,
                                      sParent='controls',
                                      sShape='circle',
                                      fSize=10,
                                      sColor='yellow',
                                      lLockHideAttrs=['sx', 'sy', 'sz', 'v'])
        ## layout control
        oCtrl_layout = controls.create('layout',
                                       sSide='middle',
                                       iStacks=1,
                                       sParent=oCtrl_world.sOutput,
                                       sShape='triangle',
                                       fSize=9.5,
                                       sColor='royal heath',
                                       lLockHideAttrs=['sx', 'sy', 'sz', 'v'])
        ## local control
        oCtrl_local = controls.create('local',
                                      sSide='middle',
                                      iStacks=1,
                                      sParent=oCtrl_layout.sOutput,
                                      sShape='triangle',
                                      fSize=7.5,
                                      sColor='royal purple',
                                      lLockHideAttrs=['sx', 'sy', 'sz', 'v'])
        #### connect scale
        for sCtrl in [
                oCtrl_world.sName, oCtrl_layout.sName, oCtrl_local.sName
        ]:
            cmds.addAttr(sCtrl,
                         ln='rigScale',
                         at='float',
                         dv=1,
                         min=0,
                         keyable=True)
            attributes.connectAttrs([
                '%s.rigScale' % sCtrl,
                '%s.rigScale' % sCtrl,
                '%s.rigScale' % sCtrl,
            ], ['%s.sx' % sCtrl,
                '%s.sy' % sCtrl,
                '%s.sz' % sCtrl],
                                    bForce=True)

        #### connect with xtrs
        for sRes in self.lRes:
            sGrpXtrs = naming.oName(sType='grp',
                                    sSide='m',
                                    sRes=sRes,
                                    sPart='xtrs').sName
            constraints.constraint([oCtrl_local.sName, sGrpXtrs],
                                   sType='all',
                                   bMaintainOffset=False,
                                   bForce=True)
Ejemplo n.º 2
0
	def create(self):
		oName = naming.oName(self._sBpJnt)
		self._sSide = oName.sSide
		self._sPart = oName.sPart
		self._iIndex = oName.iIndex
		self._lPos = transforms.getNodeTransformInfo(self._sBpJnt)
		self._iRotateOrder = cmds.getAttr('%s.ro' %self._sBpJnt)

		sGrp = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%sRig' %self._sPart, iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInJnt)
		sJnt = joints.createJntOnTransformInfo(naming.oName(sType = 'jnt', sSide = self._sSide, sPart = self._sPart, iIndex = self._iIndex).sName, self._lPos, iRotateOrder = self._iRotateOrder, sParent = sGrp)
		sGrpCtrl = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%sCtrl' %self._sPart, iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInCtrl)
		oCtrl = controls.create(self._sPart, sSide = self._sSide, iIndex = self._iIndex, iStacks = self._iStacks, bSub = self._bSub, sParent = sGrpCtrl, iRotateOrder = self._iRotateOrder, sShape = 'circle', fSize = 10, lLockHideAttrs = self._lLockHideAttrs)
		transforms.setNodeTransform(oCtrl.sZero, self._lPos)
		constraints.constraint([oCtrl.sOutput, sJnt], sType = 'parent')

		## write rig info
		lRigInfo = ['singleJointRig', self._sConnectInJnt, self._sConnectInCtrl, sJnt, oCtrl.sOutput, sJnt, oCtrl.sName, sGrpCtrl, sGrp]
		lAttrs = ['sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt', 'sConnectOutCtrl', 'lJnts', 'lCtrls', 'sGrpCtrl', 'sModuleNode']
		self._writeRigInfo(sGrp, lRigInfo, lAttrs)

		self._getRigInfo(sGrp)
Ejemplo n.º 3
0
    def create(self):
        sGrp = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRig' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInJnt)
        sGrpCtrl = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sCtrl' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInCtrl)
        sGrpNode = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sNode' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sGrpNode)

        lJnts = []
        for i, sBpJnt in enumerate(self._lBpJnts):
            oJntName = naming.oName(sBpJnt)
            oJntName.sType = 'jnt'
            oJntName.sPart = '%s%s' % (oJntName.sPart, self._sName)
            sJnt = joints.createJntOnExistingNode(sBpJnt,
                                                  sBpJnt,
                                                  oJntName.sName,
                                                  sParent=sGrp)
            lJnts.append(sJnt)

        ## create ribbon surface

        ## if no control bpjnt, create controls, cluster ribbon
        lCtrls = []
        if not self._lBpCtrls:
            sRibbon = surfaces.createRibbonFromNodes(naming.oName(
                sType='surface',
                sSide=self._sSide,
                sPart='%s%s' % (self._sPart, self._sName),
                iIndex=self._iIndex).sName,
                                                     lJnts,
                                                     bAuto=True,
                                                     fWidth=2,
                                                     bNormalize=False,
                                                     sParent=sGrpNode)
            cmds.setAttr('%s.v' % sRibbon, 0)
            lCls = surfaces.clusterSurface(sRibbon, sUV='u')
            cmds.rebuildSurface(sRibbon,
                                ch=True,
                                su=len(lJnts) - 1,
                                sv=1,
                                dv=3,
                                du=3)
            for i, sCls in enumerate(lCls):
                oCtrl = controls.create('%s%s' % (self._sPart, self._sName),
                                        sSide=self._sSide,
                                        iIndex=i,
                                        iStacks=self._iStacks,
                                        bSub=self._bSub,
                                        sParent=sGrpCtrl,
                                        sPos=sCls,
                                        sShape='cube',
                                        fSize=4,
                                        lLockHideAttrs=self._lLockHideAttrs)
                cmds.parent(sCls, oCtrl.sOutput)
                lCtrls.append(oCtrl.sName)
        else:
            sRibbon = surfaces.createRibbonFromNodes(naming.oName(
                sType='surface',
                sSide=self._sSide,
                sPart='%s%s' % (self._sPart, self._sName),
                iIndex=self._iIndex).sName,
                                                     self._lBpCtrls,
                                                     bAuto=True,
                                                     fWidth=2,
                                                     bNormalize=False,
                                                     sParent=sGrpNode)
            cmds.setAttr('%s.v' % sRibbon, 0)
            lCls = surfaces.clusterSurface(sRibbon, sUV='u')
            cmds.rebuildSurface(sRibbon,
                                ch=True,
                                su=len(lJnts) - 1,
                                sv=1,
                                dv=3,
                                du=3)
            for i, sCls in enumerate(lCls):
                oJntName = naming.oName(self._lBpCtrls[i])
                iRotateOrder = cmds.getAttr('%s.ro' % self._lBpCtrls[i])
                oCtrl = controls.create('%s%s' % (oJntName.sPart, self._sName),
                                        sSide=oJntName.sSide,
                                        iIndex=oJntName.iIndex,
                                        iStacks=self._iStacks,
                                        bSub=self._bSub,
                                        sParent=sGrpCtrl,
                                        iRotateOrder=iRotateOrder,
                                        sPos=self._lBpCtrls[i],
                                        sShape='cube',
                                        fSize=4,
                                        lLockHideAttrs=self._lLockHideAttrs)
                cmds.parent(sCls, oCtrl.sOutput)
                lCtrls.append(oCtrl.sName)

        ### attach joints
        sGrpFollicle, lFollicles = constraints.follicleConstraint(
            sRibbon, lJnts, bMaintainOffset=True)
        cmds.parent(sGrpFollicle, sGrpNode)

        #### control connect out node
        sConnectOutCtrl = transforms.createTransformNode(naming.oName(
            sType='grp',
            sSide=self._sSide,
            sPart='%s%sRigConnectOutCtrl' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                                         lLockHideAttrs=[
                                                             'tx', 'ty', 'tz',
                                                             'rx', 'ry', 'rz',
                                                             'sx', 'sy', 'sz',
                                                             'v'
                                                         ],
                                                         sParent=sGrpCtrl,
                                                         bVis=True)
        constraints.constraint([lJnts[-1], sConnectOutCtrl],
                               sType='parent',
                               bForce=True,
                               bMaintainOffset=True)

        #### control root connect out node
        sConnectOutRootCtrl = transforms.createTransformNode(naming.oName(
            sType='grp',
            sSide=self._sSide,
            sPart='%s%sRigConnectOutRootCtrl' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                                             lLockHideAttrs=[
                                                                 'tx', 'ty',
                                                                 'tz', 'rx',
                                                                 'ry', 'rz',
                                                                 'sx', 'sy',
                                                                 'sz', 'v'
                                                             ],
                                                             sParent=sGrpCtrl,
                                                             bVis=True)
        constraints.constraint([lJnts[0], sConnectOutRootCtrl],
                               sType='parent',
                               bForce=True,
                               bMaintainOffset=True)

        ## write rig info
        sString_lJnts = self._convertListToString(lJnts)
        sString_lCtrls = self._convertListToString(lCtrls)
        lRigInfo = [
            'ribbonRig', self._sConnectInJnt, self._sConnectInCtrl, lJnts[-1],
            sConnectOutCtrl, sConnectOutRootCtrl, sString_lJnts,
            sString_lCtrls, sRibbon, sGrpCtrl, sGrp
        ]
        lAttrs = [
            'sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt',
            'sConnectOutCtrl', 'sConnectOutRootCtrl', 'lJnts', 'lCtrls',
            'sRibbon', 'sGrpCtrl', 'sModuleNode'
        ]
        self._writeRigInfo(sGrp, lRigInfo, lAttrs)

        self._getRigInfo(sGrp)
Ejemplo n.º 4
0
    def create(self):
        sGrp = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRig' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInJnt)

        sParent_jnt = sGrp
        lJnts = []
        for i, sBpJnt in enumerate(self._lBpJnts):
            oJntName = naming.oName(sBpJnt)
            oJntName.sType = 'jnt'
            oJntName.sPart = '%s%s' % (oJntName.sPart, self._sName)
            sJnt = joints.createJntOnExistingNode(sBpJnt,
                                                  sBpJnt,
                                                  oJntName.sName,
                                                  sParent=sParent_jnt)
            lJnts.append(sJnt)
            sParent_jnt = sJnt

        ## ik handle
        sIkHnd = naming.oName(sType='ikHandle',
                              sSide=self._sSide,
                              sPart=self._sPart,
                              iIndex=self._iIndex).sName
        cmds.ikHandle(sj=lJnts[0], ee=lJnts[-1], sol='ikSCsolver', name=sIkHnd)

        ## control
        if self._bCtrl:
            sGrpCtrl = transforms.createTransformNode(
                naming.oName(sType='grp',
                             sSide=self._sSide,
                             sPart='%s%sCtrl' % (self._sPart, self._sName),
                             iIndex=self._iIndex).sName,
                lLockHideAttrs=[
                    'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
                ],
                sParent=self._sConnectInCtrl)
            iRotateOrder = cmds.getAttr('%s.ro' % lJnts[0])
            oJntName = naming.oName(lJnts[0])
            oCtrl_root = controls.create(oJntName.sPart,
                                         sSide=oJntName.sSide,
                                         iIndex=oJntName.iIndex,
                                         iStacks=self._iStacks,
                                         bSub=self._bSub,
                                         sParent=sGrpCtrl,
                                         sPos=lJnts[0],
                                         iRotateOrder=iRotateOrder,
                                         sShape='cube',
                                         fSize=4,
                                         lLockHideAttrs=self._lLockHideAttrs)
            oJntName = naming.oName(lJnts[-1])
            oCtrl_aim = controls.create(oJntName.sPart,
                                        sSide=oJntName.sSide,
                                        iIndex=oJntName.iIndex,
                                        iStacks=self._iStacks,
                                        bSub=self._bSub,
                                        sParent=sGrpCtrl,
                                        sPos=lJnts[-1],
                                        iRotateOrder=iRotateOrder,
                                        sShape='cube',
                                        fSize=4,
                                        lLockHideAttrs=self._lLockHideAttrs)

            cmds.pointConstraint(oCtrl_root.sOutput, lJnts[0], mo=False)
            #### control connect out node
            sConnectOutCtrl = transforms.createTransformNode(
                naming.oName(sType='grp',
                             sSide=self._sSide,
                             sPart='%s%sRigConnectOutCtrl' %
                             (self._sPart, self._sName),
                             iIndex=self._iIndex).sName,
                lLockHideAttrs=[
                    'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
                ],
                sParent=oCtrl.sOutput,
                bVis=True)
            constraints.constraint([lJnts[-1], sConnectOutCtrl],
                                   sType='parent',
                                   bForce=True,
                                   bMaintainOffset=False)
            sParentIk = oCtrl_aim.sOutput
            lCtrls = [oCtrl_root.sName, oCtrl_aim.sName]
        else:
            sParentIk = self._sConnectInCtrl
            lCtrls = ''

        sGrpIkHndle = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRigIkHndle' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=sParentIk,
            bVis=False)
        cmds.parent(sIkHnd, sGrpIkHndle)

        ## write rig info
        sString_lJnts = self._convertListToString(lJnts)
        sString_lCtrls = self._convertListToString(lCtrls)
        lRigInfo = [
            'ikSCsolverRig', self._sConnectInJnt, self._sConnectInCtrl,
            lJnts[-1], sConnectOutCtrl, sString_lJnts, sString_lCtrls, sIkHnd,
            sGrpCtrl, sGrp
        ]
        lAttrs = [
            'sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt',
            'sConnectOutCtrl', 'lJnts', 'lCtrls', 'sIkHnd', 'sGrpCtrl',
            'sModuleNode'
        ]
        self._writeRigInfo(sGrp, lRigInfo, lAttrs)

        self._getRigInfo(sGrp)
Ejemplo n.º 5
0
    def create(self):
        sGrp = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRig' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInJnt)
        sGrpCtrl = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sCtrl' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInCtrl)
        sGrpNode = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sNode' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sGrpNode)
        ## twist locs
        sMatcherBot, sOffsetBot = transforms.createTransformMatcherNode(
            self._lBpJnts[0], sParent=None)
        sMatcherTop, sOffsetTop = transforms.createTransformMatcherNode(
            self._lBpJnts[-1], sParent=None)

        ## create curve
        lBot = []
        lTop = []
        if self._bOrientTop:
            lTop.append(sMatcherTop)
        if self._bOrientBot:
            lBot.append(sMatcherBot)
        sCrv = curves.createCurveOnNodes(naming.oName(
            sType='curve',
            sSide=self._sSide,
            sPart='%s%s' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                         lBot + self._lBpCtrls + lTop,
                                         iDegree=3,
                                         sParent=sGrpNode)
        cmds.setAttr('%s.v' % sCrv, 0)

        ## create joints
        sParent_jnt = sGrp
        lJnts = []
        for i, sBpJnt in enumerate(self._lBpJnts):
            oJntName = naming.oName(sBpJnt)
            oJntName.sType = 'jnt'
            oJntName.sPart = '%s%s' % (oJntName.sPart, self._sName)
            sJnt = joints.createJntOnExistingNode(sBpJnt,
                                                  sBpJnt,
                                                  oJntName.sName,
                                                  sParent=sParent_jnt)
            lJnts.append(sJnt)
            sParent_jnt = sJnt

        ## create cluster
        lClsHnds = curves.clusterCurve(sCrv)

        ## create contorls
        lCtrls = []
        if not self._lBpCtrls:
            self._lBpCtrls = self._lBpJnts
        for i, sJnt in enumerate(self._lBpCtrls):
            oJntName = naming.oName(sJnt)
            iRotateOrder = cmds.getAttr('%s.ro' % sJnt)
            oCtrl = controls.create('%s%s' % (oJntName.sPart, self._sName),
                                    sSide=oJntName.sSide,
                                    iIndex=oJntName.iIndex,
                                    iStacks=self._iStacks,
                                    bSub=self._bSub,
                                    sParent=sGrpCtrl,
                                    sPos=sJnt,
                                    iRotateOrder=iRotateOrder,
                                    sShape='cube',
                                    fSize=8,
                                    lLockHideAttrs=self._lLockHideAttrs)
            if self._lCtrlOrient:
                transforms.worldOrientTransform(oCtrl.sPasser,
                                                sFoward=self._lCtrlOrient[0],
                                                sUp=self._lCtrlOrient[1])
            if self._bOrientBot:
                cmds.parent(lClsHnds[i + 1], oCtrl.sOutput)
                if i == 0:
                    cmds.parent(lClsHnds[0], oCtrl.sOutput)
            else:
                cmds.parent(lClsHnds[i], oCtrl.sOutput)
            if self._bOrientTop:
                if i == len(self._lBpCtrls) - 1:
                    cmds.parent(lClsHnds[-1], oCtrl.sOutput)
            lCtrls.append(oCtrl.sName)

        ## rebuild curve
        curves.rebuildCurveWithSameCvNum(sCrv)

        ## spline ik handle
        sIkHnd = naming.oName(sType='ikHandle',
                              sSide=self._sSide,
                              sPart='%s%s' % (self._sPart, self._sName),
                              iindex=self._iIndex).sName
        cmds.ikHandle(sj=lJnts[0],
                      ee=lJnts[-1],
                      sol='ikSplineSolver',
                      c=sCrv,
                      ccv=False,
                      pcv=False,
                      name=sIkHnd)
        cmds.makeIdentity(lJnts, apply=True, t=1, r=1, s=1)
        cmds.parent(sIkHnd, sGrpCtrl)
        cmds.setAttr('%s.v' % sIkHnd, 0)

        ## advanced twist
        for i, sCtrl in enumerate([lCtrls[0], lCtrls[-1]]):
            oCtrl = controls.oControl(sCtrl)
            cmds.parent([sOffsetBot, sOffsetTop][i], oCtrl.sOutput)
        cmds.setAttr('%s.dTwistControlEnable' % sIkHnd, 1)
        cmds.setAttr('%s.dWorldUpType' % sIkHnd, 4)
        attributes.connectAttrs([
            '%s.worldMatrix[0]' % sMatcherBot,
            '%s.worldMatrix[0]' % sMatcherTop
        ], ['%s.dWorldUpMatrix' % sIkHnd,
            '%s.dWorldUpMatrixEnd' % sIkHnd],
                                bForce=True)

        #### control connect out node
        sConnectOutCtrl = transforms.createTransformNode(naming.oName(
            sType='grp',
            sSide=self._sSide,
            sPart='%s%sRigConnectOutCtrl' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                                         lLockHideAttrs=[
                                                             'tx', 'ty', 'tz',
                                                             'rx', 'ry', 'rz',
                                                             'sx', 'sy', 'sz',
                                                             'v'
                                                         ],
                                                         sParent=sGrpCtrl,
                                                         bVis=True)
        constraints.constraint([lJnts[-1], sConnectOutCtrl],
                               sType='parent',
                               bForce=True,
                               bMaintainOffset=True)

        #### control root connect out node
        sConnectOutRootCtrl = transforms.createTransformNode(naming.oName(
            sType='grp',
            sSide=self._sSide,
            sPart='%s%sRigConnectOutRootCtrl' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                                             lLockHideAttrs=[
                                                                 'tx', 'ty',
                                                                 'tz', 'rx',
                                                                 'ry', 'rz',
                                                                 'sx', 'sy',
                                                                 'sz', 'v'
                                                             ],
                                                             sParent=sGrpCtrl,
                                                             bVis=True)
        constraints.constraint([lJnts[0], sConnectOutRootCtrl],
                               sType='parent',
                               bForce=True,
                               bMaintainOffset=True)

        ## write rig info
        sString_lJnts = self._convertListToString(lJnts)
        sString_lCtrls = self._convertListToString(lCtrls)
        lRigInfo = [
            'ikSplineRig', self._sConnectInJnt, self._sConnectInCtrl,
            lJnts[-1], sConnectOutCtrl, sConnectOutRootCtrl, sString_lJnts,
            sString_lCtrls, sIkHnd, sGrpCtrl, sGrp
        ]
        lAttrs = [
            'sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt',
            'sConnectOutCtrl', 'sConnectOutRootCtrl', 'lJnts', 'lCtrls',
            'sIkHnd', 'sGrpCtrl', 'sModuleNode'
        ]
        self._writeRigInfo(sGrp, lRigInfo, lAttrs)

        self._getRigInfo(sGrp)
Ejemplo n.º 6
0
	def create(self):
		self._lBpCtrlsSpine = self._lBpCtrls
		self._lBpCtrls = [self._lBpCtrlsPelvis[1]] + self._lBpCtrls

		sGrp = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sRig' %(self._sPart, self._sNameRig), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInJnt)
		sGrpCtrl = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sCtrl' %(self._sPart, self._sNameRig), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInCtrl)
		sGrpNode = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sNode' %(self._sPart, self._sNameRig), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sGrpNode)

		self._sConnectInJnt = sGrp
		self._sConnectInCtrl = sGrpCtrl
		self._sGrpNode = sGrpNode

		super(spineRig, self).create()


		## fk rig

		oSpineFk = fkJointChainRig.fkJointChainRig(
													sName = 'Fk',
													sSide = self._sSide,
													sPart = self._sPart,
													iIndex = self._iIndex,
													lBpJnts = self._lBpCtrlsSpine,
													sConnectInCtrl = self._sConnectInCtrl,
													sConnectInJnt = self._sConnectInJnt,
													bSub = self._bSub,
													iStacks = self._iStacks,
													lLockHideAttrs = self._lLockHideAttrs)

		oSpineFk.create()

		## pelvis rig
		oPelvisFk = fkJointChainRig.fkJointChainRig(
													sName = 'Fk',
													sSide = self._sSide,
													sPart = self._sPartPelvis,
													iIndex = self._iIndex,
													lBpJnts = self._lBpCtrlsPelvis,
													sConnectInCtrl = self._sConnectInCtrl,
													sConnectInJnt = self._sConnectInJnt,
													bSub = self._bSub,
													iStacks = self._iStacks,
													lLockHideAttrs = self._lLockHideAttrs
														)
		oPelvisFk.create()

		## ik spline
		oSpineIk = ikSplineRig.ikSplineRig(
											sName = 'ikSpline',
											sSide = self._sSide,
											sPart = self._sPart,
											iIndex = self._iIndex,
											lBpJnts = self._lBpCtrls,
											sConnectInCtrl = self._sConnectInCtrl,
											sConnectInJnt = self._sConnectInJnt,
											sGrpNode = self._sGrpNode,
											bSub = self._bSub,
											iStacks = self._iStacks,
											lLockHideAttrs = self._lLockHideAttrs,
											lBpCtrls = self._lBpCtrlsSpine[:-1],
											bOrientTop = True,
											bOrientBot = True,
											lCtrlOrient = self._lCtrlOrient,
											)
		oSpineIk.create()

		## constraint and hidde ribbon controls
		for i, sCtrl in enumerate(self._lCtrls):
			oCtrl = controls.oControl(sCtrl)
			cmds.parentConstraint(oSpineIk.lJnts[i], oCtrl.sPasser, mo = False)
			cmds.setAttr('%s.v' %oCtrl.sPasser, 0)

		## constraint ik controls
		## pelvis
		oCtrl = controls.oControl(oSpineIk.lCtrls[0])
		constraints.constraint([oPelvisFk.lJnts[0], oCtrl.sPasser], sType = 'parent', bMaintainOffset = True)

		## spine
		for i, sCtrl in enumerate(oSpineIk.lCtrls[1:]):
			oCtrl = controls.oControl(sCtrl)
			if i == 0:
				constraints.constraint([oSpineFk.lJnts[i], oCtrl.sPasser], sType = 'parent', bMaintainOffset = True)
			else:
				constraints.constraint([oSpineFk.lJnts[i + 1], oCtrl.sPasser], sType = 'parent', bMaintainOffset = True)
		## add ctrl shape
		sCtrlShape = naming.oName(sType = 'ctrl', sSide = self._sSide, sPart = self._sPart, iIndex = self._iIndex).sName
		controls.addCtrlShape(oSpineIk.lCtrls + oSpineFk.lCtrls + oPelvisFk.lCtrls, sCtrlShape, bVis = False)

		cmds.addAttr(sCtrlShape, ln = 'ikCtrlVis', at = 'long', min = 0, max = 1)
		cmds.setAttr('%s.ikCtrlVis' %sCtrlShape, channelBox = True)
		attributes.connectAttrs(['%s.ikCtrlVis' %sCtrlShape], ['%s.v' %oSpineIk.sGrpCtrl], bForce = True)

		## write rig info
		sModuleNodes = '%s,%s,%s' %(oSpineFk.sModuleNode, oPelvisFk.sModuleNode, oSpineIk.sModuleNode)

		sString_lJnts = self._convertListToString(self._lJnts)
		sString_lCtrls = self._convertListToString(oSpineFk.lCtrls + oPelvisFk.lCtrls + oSpineIk.lCtrls)
		lRigInfo = ['spineRig', self._sConnectInJnt, self._sConnectInCtrl, self._sConnectOutJnt, self._sConnectOutCtrl, self._sConnectOutRootCtrl,sString_lJnts, sString_lCtrls, sGrpCtrl, sModuleNodes, sGrp]
		lAttrs = ['sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt', 'sConnectOutCtrl', 'sConnectOutRootCtrl', 'lJnts', 'lCtrls', 'sGrpCtrl', 'lModuleNodes', 'sModuleNode']
		self._writeRigInfo(sGrp, lRigInfo, lAttrs)

		self._getRigInfo(sGrp)
Ejemplo n.º 7
0
    def create(self):
        sGrp = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRig' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInJnt)
        sGrpCtrl = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sCtrl' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=self._sConnectInCtrl)

        sParent_jnt = sGrp
        lJnts = []
        for i, sBpJnt in enumerate(self._lBpJnts):
            oJntName = naming.oName(sBpJnt)
            oJntName.sType = 'jnt'
            oJntName.sPart = '%s%s' % (oJntName.sPart, self._sName)
            sJnt = joints.createJntOnExistingNode(sBpJnt,
                                                  sBpJnt,
                                                  oJntName.sName,
                                                  sParent=sParent_jnt)
            lJnts.append(sJnt)
            sParent_jnt = sJnt

        lCtrls = []
        for i, sBpJnt in enumerate([self._sBpRoot, self._sBpPv,
                                    self._sBpCtrl]):
            oJntName = naming.oName(sBpJnt)
            iRotateOrder = cmds.getAttr('%s.ro' % sBpJnt)
            if i == 2:
                lLockHideAttrs = self._lLockHideAttrs
            else:
                lLockHideAttrs = ['rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']
            oCtrl = controls.create(oJntName.sPart,
                                    sSide=oJntName.sSide,
                                    iIndex=oJntName.iIndex,
                                    iStacks=self._iStacks,
                                    bSub=self._bSub,
                                    sParent=sGrpCtrl,
                                    sPos=sBpJnt,
                                    iRotateOrder=iRotateOrder,
                                    sShape='cube',
                                    fSize=8,
                                    lLockHideAttrs=lLockHideAttrs)
            lCtrls.append(oCtrl.sName)

        ## ik handle
        if self._bOrient:
            sJntEnd_rp = lJnts[-2]
            sIkHnd_sc = naming.oName(sType='ikHandle',
                                     sSide=self._sSide,
                                     sPart='%sSCsolver' % self._sPart,
                                     iIndex=self._iIndex).sName
            cmds.ikHandle(sj=lJnts[-2],
                          ee=lJnts[-1],
                          sol='ikSCsolver',
                          name=sIkHnd_sc)
        else:
            sJntEnd_rp = lJnts[-1]
            sIkHnd_sc = None
        sIkHnd_rp = naming.oName(sType='ikHandle',
                                 sSide=self._sSide,
                                 sPart='%sRPsolver' % self._sPart,
                                 iIndex=self._iIndex).sName
        cmds.ikHandle(sj=lJnts[0],
                      ee=sJntEnd_rp,
                      sol='ikRPsolver',
                      name=sIkHnd_rp)

        #### parent ik handle
        oCtrl = controls.oControl(lCtrls[2])
        sGrpIkHndle = transforms.createTransformNode(
            naming.oName(sType='grp',
                         sSide=self._sSide,
                         sPart='%s%sRigIkHndle' % (self._sPart, self._sName),
                         iIndex=self._iIndex).sName,
            lLockHideAttrs=[
                'tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'
            ],
            sParent=oCtrl.sOutput,
            bVis=False)
        cmds.parent(sIkHnd_rp, sGrpIkHndle)
        if sIkHnd_sc:
            cmds.parent(sIkHnd_sc, sGrpIkHndle)

        #### pole vector
        oCtrl = controls.oControl(lCtrls[1])
        cmds.poleVectorConstraint(oCtrl.sOutput, sIkHnd_rp)
        ## pole vector line
        curves.createCurveLine(naming.oName(sType='curve',
                                            sSide=self._sSide,
                                            sPart='%sPvLineIk' % self._sPart,
                                            iIndex=self._iIndex).sName,
                               [lJnts[1], oCtrl.sOutput],
                               sParent=sGrpCtrl)

        #### root control
        oCtrl = controls.oControl(lCtrls[0])
        cmds.pointConstraint(oCtrl.sOutput, lJnts[0], mo=False)

        #### control connect out node
        sConnectOutCtrl = transforms.createTransformNode(naming.oName(
            sType='grp',
            sSide=self._sSide,
            sPart='%s%sRigConnectOutCtrl' % (self._sPart, self._sName),
            iIndex=self._iIndex).sName,
                                                         lLockHideAttrs=[
                                                             'tx', 'ty', 'tz',
                                                             'rx', 'ry', 'rz',
                                                             'sx', 'sy', 'sz',
                                                             'v'
                                                         ],
                                                         sParent=oCtrl.sOutput,
                                                         bVis=True)
        constraints.constraint([lJnts[-1], sConnectOutCtrl],
                               sType='parent',
                               bForce=True,
                               bMaintainOffset=True)
        ## write rig info
        sString_lJnts = self._convertListToString(lJnts)
        sString_lCtrls = self._convertListToString(lCtrls)
        lRigInfo = [
            'ikRPsolverRig', self._sConnectInJnt, self._sConnectInCtrl,
            lJnts[-1], sConnectOutCtrl, sString_lJnts, sString_lCtrls,
            sIkHnd_rp, sGrpCtrl, sGrp
        ]
        lAttrs = [
            'sModuleType', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt',
            'sConnectOutCtrl', 'lJnts', 'lCtrls', 'sIkHnd', 'sGrpCtrl',
            'sModuleNode'
        ]
        self._writeRigInfo(sGrp, lRigInfo, lAttrs)

        self._getRigInfo(sGrp)
Ejemplo n.º 8
0
	def create(self):
		sGrp = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sRig' %(self._sPart, self._sName), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInJnt)
		sGrpCtrl = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sCtrl' %(self._sPart, self._sName), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = self._sConnectInCtrl)
		sParent_jnt = sGrp
		lJnts = []
		for i, sBpJnt in enumerate(self._lBpJnts):
			oJntName = naming.oName(sBpJnt)
			oJntName.sType = 'jnt'
			sJnt = joints.createJntOnExistingNode(sBpJnt, sBpJnt, oJntName.sName, sParent = sParent_jnt)
			lJnts.append(sJnt)
			sParent_jnt = sJnt
		
		## rig each limb
		iJnts_min = len(lJnts)
		dRigLimbs = {}
		lCtrls = []
		for sMode in self._dRigLimbs.keys():
			dRigLimbs_each = {sMode: {
										'iIndex': 0,
										'class': None,
										'lJnts': None,
											}}
			oLimb = self._dRigLimbs[sMode]['class'](sSide = self._sSide, iIndex = self._iIndex)
			oLimb._lBpJnts = self._lBpJnts
			oLimb._sConnectInJnt = sGrp
			oLimb._sConnectInCtrl = sGrpCtrl
			oLimb.create()
			
			if self._dRigLimbs[sMode].has_key('iIndex'):
				dRigLimbs_each[sMode]['iIndex'] = self._dRigLimbs[sMode]['iIndex']
			else:
				dRigLimbs_each[sMode]['iIndex'] = namingDict.spaceDict[sMode]

			dRigLimbs_each[sMode]['class'] = oLimb

			if hasattr(oLimb, 'lJntsOutput'):
				dRigLimbs_each[sMode]['lJnts'] = oLimb.lJntsOutput
				if len(oLimb.lJntsOutput) < iJnts_min:
					iJnts_min = len(oLimb.lJntsOutput)
			else:
				dRigLimbs_each[sMode]['lJnts'] = oLimb.lJnts
				if len(oLimb.lJnts) < iJnts_min:
					iJnts_min = len(oLimb.lJnts)

			lCtrls += oLimb.lCtrls

			dRigLimbs.update(dRigLimbs_each)

		## add shape node
		sCtrlShape = naming.oName(sType = 'ctrl', sSide = self._sSide, sPart = self._sPart, iIndex = self._iIndex).sName
		controls.addCtrlShape(lCtrls, sCtrlShape, bVis = False)

		## blend constraint joints
		for i in range(0, iJnts_min):
			lDrivers = []
			#dDrivers = {'cog': {'iIndex': 0, 'sOutput': 'ctrl_m_cog'}}
			dDrivers = {}
			for sMode in dRigLimbs.keys():
				dDriver_each = {sMode: {'iIndex': dRigLimbs[sMode]['iIndex'], 'sOutput': dRigLimbs[sMode]['lJnts'][i]}}
				dDrivers.update(dDriver_each)
			constraints.spaceConstraint(dDrivers, lJnts[i], sType = self._sConstraintType, sCtrl = sCtrlShape, bMaintainOffset = False, sName = self._sName, lDefaultVal = None)

		## vis switch
		sCondition = naming.oName(sType = 'condition', sSide = self._sSide, sPart = '%s%s%sSelector' %(self._sPart, self._sName[0].upper(), self._sName[1:]), iIndex = self._iIndex).sName
		cmds.createNode('condition', name = sCondition)
		cmds.connectAttr('%s.%sModeA' %(sCtrlShape, self._sName), '%s.colorIfTrueR' %sCondition)
		cmds.connectAttr('%s.%sModeB' %(sCtrlShape, self._sName), '%s.colorIfFalseR' %sCondition)
		cmds.connectAttr('%s.%sModeBlend' %(sCtrlShape, self._sName), '%s.firstTerm' %sCondition)
		cmds.setAttr('%s.secondTerm' %sCondition, 0.5)
		cmds.setAttr('%s.operation' %sCondition, 4)

		lAttrs = []
		lEnumIndex = []
		for sMode in dRigLimbs.keys():
			lAttrs.append('%s.v' %dRigLimbs[sMode]['class'].sGrpCtrl)
			lEnumIndex.append(dRigLimbs[sMode]['iIndex'])

		attributes.enumToMultiAttrs('outColorR', lAttrs, iEnumRange = len(lEnumIndex), lEnumIndex = lEnumIndex, sEnumObj = sCondition)
		#enumToMultiAttrs(sEnumAttr, lAttrs, iEnumRange = 2, lEnumIndex = None, lValRange = [[0,1]], sEnumObj = None)

		#### control connect out node
		sConnectOutCtrl = transforms.createTransformNode(naming.oName(sType = 'grp', sSide = self._sSide, sPart = '%s%sConnectOutCtrl' %(self._sPart, self._sName), iIndex = self._iIndex).sName, lLockHideAttrs = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'], sParent = sGrpCtrl, bVis = True)
		constraints.constraint([lJnts[-1], sConnectOutCtrl], sType = 'parent', bForce = True, bMaintainOffset = True)

		lCtrls = sCtrlShape

		## write rig info
		sModuleNodes = ''
		sModuleIndex = ''
		for sMode in dRigLimbs.keys():
			sModuleNodes += '%s,' %dRigLimbs[sMode]['class'].sModuleNode
			sModuleIndex += '%d,' %dRigLimbs[sMode]['iIndex']

		sString_lJnts = self._convertListToString(lJnts)
		sString_lCtrls = self._convertListToString(lCtrls)
		lRigInfo = ['blendModeRig', sGrp, self._sConnectInJnt, self._sConnectInCtrl, lJnts[-1], sConnectOutCtrl, sString_lJnts, sString_lCtrls, sGrpCtrl, sModuleNodes[:-1], sModuleIndex[:-1]]
		lAttrs = ['sModuleType', 'sModuleNode', 'sConnectInJnt', 'sConnectInCtrl', 'sConnectOutJnt', 'sConnectOutCtrl', 'lJnts', 'lCtrls', 'sGrpCtrl', 'lModuleNodes', 'lModuleIndex']

		self._writeRigInfo(sGrp, lRigInfo, lAttrs)

		self._getRigInfo(sGrp)