예제 #1
0
 def connectControlBoard(self, controlBoard):
     bb = self.blendBoard
     utils.msgConnect(self.node + '.controlBoard', controlBoard + '.faceModule')
     if bb:
         for attr in cmds.listAttr(bb, k=1):
             bbAttr = bb + '.' + attr
             if cmds.listConnections(bbAttr):
                 cbAttr = controlBoard + '.' + attr
                 if utils.attrExists(cbAttr):
                     cmds.connectAttr(cbAttr, bbAttr, f=1)
예제 #2
0
    def buildBlendBoard(self, fpath):
        try:
            cmds.undoInfo(openChunk=True)

            #TODO: rebuild and keep all connections and attrs
            if self.blendBoard:
                cmds.delete(self.blendBoard)

            lines = []
            if os.path.exists(fpath):
                f = open(fpath, 'r')
                lines = f.readlines()
                f.close()
            self.blendBoard = cmds.spaceLocator(name='blendBoard')[0]
            cmds.addAttr(self.blendBoard, longName='uType', dataType='string')
            cmds.setAttr(self.blendBoard + '.uType', 'blendBoard', type='string')
            utils.msgConnect(self.node + '.blendBoard', self.blendBoard + '.faceModule')

            #store input file path
            cmds.addAttr(self.blendBoard, longName='inputFile', dataType='string')
            cmds.setAttr(self.blendBoard + '.inputFile', fpath, type='string')

            #make purdy
            cmds.setAttr("blendBoard.tx", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.ty", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.tz", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.rx", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.ry", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.rz", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.sx", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.sy", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.sz", l=1, k=0, channelBox=0)
            cmds.setAttr("blendBoard.v", l=1, k=0, channelBox=0)

            #make pose attrs
            for line in lines:
                line = line.strip()
                if line != '':
                    print line
                    if '##' in line:
                        cmds.addAttr(self.blendBoard,enumName='#####', longName=line.replace('##',''), at='enum', k=1)
                        cmds.setAttr(self.blendBoard + '.' + line.replace('##',''), lock=1)
                    else:
                        cmds.addAttr(self.blendBoard, longName=line, at='float', min=0, max=1, k=1)

            cmds.undoInfo(closeChunk=True)
        except Exception as e:
            exc_type, exc_value, exc_tb = sys.exc_info()
            for line in traceback.format_exception(exc_type, exc_value, exc_tb):
                print line
            cmds.undoInfo(closeChunk=True)
예제 #3
0
    def connectSdksToFinalSkeleton(self):
        jmLocked = cmds.lockNode('JointMover', lock=1, q=1)[0]
        if jmLocked:
            cmds.lockNode('JointMover', lock=0)
        for mover in self.activeJointMovers:
            #TODO: this won't work with multiple heads
            #hate to use name string here, but there's only one skeleton
            sdk = cmds.listConnections(mover + '.sdk')[0]
            joint = mover.replace('_mover','')
            tweak = cmds.listRelatives(sdk, children=1, typ='transform')[0]
            cmds.parentConstraint(tweak, joint, mo=1)
            cmds.scaleConstraint(tweak, joint)

            #to get away from sting names later
            #TODO: detect locks and only unlock/relock if the item was locked
            moverLocked = cmds.lockNode(mover, lock=1, q=1)[0]
            if moverLocked:
                cmds.lockNode(mover, lock=0)
            utils.msgConnect(mover + '.deformingJoint', joint + '.mover')
            if moverLocked:
                cmds.lockNode(mover, lock=1)
        if jmLocked:
            cmds.lockNode('JointMover', lock=1)
예제 #4
0
 def sdks(self, sdks):
     for sdk in sdks:
         utils.msgConnect(self.node + '.sdks', sdk + '.facialNode')
예제 #5
0
 def jointMovers(self, movers):
     for m in movers:
         utils.msgConnect(self.node + '.jointMovers', m + '.facialNode')
예제 #6
0
 def blendBoard(self, bBoard):
     utils.msgConnect(self.node + '.blendBoard', bBoard + '.faceNode')
예제 #7
0
 def faceMask(self, maskNode):
     utils.msgConnect(self.node + '.faceMask', maskNode + '.faceNode')
예제 #8
0
 def renderMeshes(self, meshes):
     for mesh in meshes:
         utils.msgConnect(self.node + '.renderMeshes', mesh + '.faceNode')
예제 #9
0
    def createJointMover(self, name=None, pos=(0,0,0), matrix=None, scale=1, toroidRatio=0.02, ss=0, facialNode=None):
        try:
            cmds.undoInfo(openChunk=True)
            if not name:
                name = 'test'
            radius = 1

            #create mask attachment node
            maskAttach = cmds.spaceLocator(name=name+'_mover_maskAttach')[0]

            #create jeremy-joint-mover-stack
            topNode = cmds.group(name=name+'_mover_grp', em=1)
            mover = utils.createCircleControl(name=name+'_mover', radius=2, type='toroid', heightRatio=toroidRatio)
            #offset = utils.createCircleControl(name=name+'_mover_offset', radius=1.5, color='xyz', type='toroid', heightRatio=toroidRatio)
            offset = cmds.group(name=name+'_mover_offset', em=1)
            lra_grp = cmds.group(name=name+'_lra_grp', em=1)
            lra = utils.createLRA(name=name + '_LRA', length=2, thickness=0.05, arrowRadiusMult=3)
            cmds.parent(mover, topNode)
            cmds.parent(offset, mover)
            cmds.parent(lra_grp, offset)
            cmds.parent(lra, lra_grp)
            cmds.displaySmoothness(mover, f=1)
            if scale is not 1:
                cmds.scale(scale, scale, scale, topNode)
                cmds.makeIdentity(topNode, apply=1, t=0, r=0, s=1, n=0, pn=1)
            if not ss:
                cmds.select(topNode)
            cmds.parentConstraint(maskAttach, topNode)

            #create SDK pose stack
            sdkOffset = cmds.group(name=name+'_SDK_grp', em=1)
            sdk = utils.createLRA(name=name + '_SDK', length=2, color=False, thickness=0.05, arrowRadiusMult=3)
            tweak = cmds.group(name=name+'_TWEAK', em=1)
            if scale is not 1:
                cmds.scale(scale, scale, scale, sdk)
                cmds.makeIdentity(sdk, apply=1, t=0, r=0, s=1, n=0, pn=1)
            cmds.parent(tweak, sdk)
            cmds.parent(sdk, sdkOffset)
            cmds.parentConstraint(lra, sdkOffset)
            utils.toggleShapeSelection(sdk, False)

            #cleanup outliner
            if cmds.objExists('maskAttachNodes'):
                cmds.parent(maskAttach, 'maskAttachNodes')
            if cmds.objExists('sdkNodes'):
                cmds.parent(sdkOffset, 'sdkNodes')
            if cmds.objExists('jointMovers'):
                cmds.parent(topNode, 'jointMovers')

            #make internal attrs/connections
            utils.msgConnect(mover + '.lra', lra + '.jointMover')
            utils.msgConnect(mover + '.attachNode', maskAttach + '.jointMover')
            utils.msgConnect(mover + '.sdk', sdk + '.jointMover')

            #make external attrs/connections
            if facialNode:
                locs = None

                #mark attachLocations
                try:
                    locs = self.mask.attachLocations
                    locs.extend(maskAttach)
                    self.mask.attachLocations = locs
                except Exception as e:
                    print(traceback.format_exc())

                #hang the jm off the facial node
                utils.msgConnect(self.node + '.jointMovers', mover + '.facialNode')

                #mark jointMovers
                jm = self.jointMovers
                jm.append(mover)
                self.jointMovers = jm

                #mark sdks
                s = self.sdks
                s.append(sdk)
                self.sdks = s

            #stamp with alignment type
            cmds.addAttr(sdk, ln='alignmentType', enumName='mask surface:manual',  k=1, at='enum')

            cmds.undoInfo(closeChunk=True)
            cmds.select(maskAttach)
            return [topNode, lra, offset, maskAttach]
        except Exception as e:
            cmds.undoInfo(closeChunk=True)
            import sys
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(e, fname, exc_tb.tb_lineno)
예제 #10
0
 def controls(self, controls):
     for c in controls:
         utils.msgConnect(self.node + '.controls', c + '.facialNode')
예제 #11
0
 def attachLocations(self, locs):
     for loc in locs:
         utils.msgConnect(self.node + '.attachLocations', loc + '.maskNode')
예제 #12
0
 def faceModule(self, faceM):
     utils.msgConnect(faceM + '.maskNode', self.node + '.faceModule')
예제 #13
0
 def maskGeo(self, maskG):
     utils.msgConnect(self.node + '.maskGeo', maskG + '.maskNode')