Beispiel #1
0
 def fromList(self,posList = [],orientList = [],autoOrient = 1):
     
     for i in range(len(posList)):
         
         tempName = nameUtils.getUniqueName(self.side,self.baseName,self.type)
         if i == len(posList) - 1:
             tempName = nameUtils.getUniqueName(self.side,self.baseName,self.type)
             
         pm.select(cl = 1)
         
         if autoOrient == 1:
             
             tempJnt = pm.joint(n = tempName,position = posList[i])
             
         else :
             tempJnt = pm.joint(n = tempName,position = posList[i],orientation = orientList[i])
         
         self.chain.append(tempJnt)
     self.__parentJoints()
      
     if autoOrient == 1:
         #pm.joint(self.chain[0].name(),e = 1,oj = 'yzx',secondaryAxisOrient = 'zup',ch = 1)
          
         pm.joint(self.chain[0].name(),e = 1,oj = 'xyz',secondaryAxisOrient = 'zdown',ch = 1)
         #xzy -secondaryAxisOrient ydown -ch -zso;
          
     self.__zeroOrientJoint(self.chain[-1])
Beispiel #2
0
 def buildGuides(self):      
     
     #group
     self.fkGuides = []
     
     #build curve
     self.guideCc = pm.curve(d = 3,p = [[0,9.040668,0.0623416],[0,10.507795,0.181759],[0,11.991982,0.164699],
                             [0,13.322632,-0.108255],[0,14.397388,-0.0570757]],k = [0,0,0,1,2,2,2],
                             n = nameUtils.getUniqueName(self.side,self.baseName + '_cc','gud'))      
     curveInfo = pm.createNode('curveInfo',n = nameUtils.getUniqueName(self.side,self.baseName + '_cc','cvINFO'))
     self.guideCc.getShape().worldSpace.connect(curveInfo.inputCurve)
     self.length = curveInfo.arcLength.get()        
     control.lockAndHideAttr(self.guideCc,['tx','ty','tz','rx','ry','rz','sx','sy','sz','v'])
Beispiel #3
0
 def blendTwoChains(chain1,chain2,resChain,attrHolder,attrName,baseName,side):
     
     blnTArray = []
     blnRArray = []
     blnSArray = []
     
     data = {'blendTranslate':blnTArray,
             'blendRotate':blnRArray,
             'blendScale':blnSArray
             }
     
     if attrHolder.hasAttr(attrName) == 0:
         attrHolder.addAttr(attrName,at = 'float',min = 0,max = 1,dv = 0,k = 1)
         
     for i,b in enumerate(resChain):
         
         blnT = nameUtils.getUniqueName(side,baseName + 'Tra','BCN')    
         blnR = nameUtils.getUniqueName(side,baseName + 'Rot','BCN') 
         blnS = nameUtils.getUniqueName(side,baseName + 'Sca','BCN') 
         
         if not blnT or not blnR or not blnS:
             return
         
         blnNodeT = pm.createNode('blendColors', n = blnT)
         blnNodeR = pm.createNode('blendColors', n = blnR)
         blnNodeS = pm.createNode('blendColors', n = blnS)
         
         chain1[i].t.connect(blnNodeT.color2)
         chain2[i].t.connect(blnNodeT.color1)
         
         chain1[i].r.connect(blnNodeR.color2)
         chain2[i].r.connect(blnNodeR.color1)
         
         chain1[i].s.connect(blnNodeS.color2)
         chain2[i].s.connect(blnNodeS.color1)
     
         blnNodeT.output.connect(b.t)
         blnNodeS.output.connect(b.s)
         blnNodeR.output.connect(b.r)
     
         blnTArray.append(blnNodeT)
         blnRArray.append(blnNodeR)
         blnSArray.append(blnNodeS)
         
         attrHolder.attr(attrName).connect(blnNodeT.blender)
         attrHolder.attr(attrName).connect(blnNodeR.blender)
         attrHolder.attr(attrName).connect(blnNodeS.blender)
     
     return data
Beispiel #4
0
    def __finalizeFkChainShape(self):
        
        reversedList = list(self.controlsArray)
        reversedList.reverse()
          
        #parent shape        
        for num,ctrl in enumerate(self.controlsArray):
            
#             for shape in ctrl.control.getShapes():
#                 pm.parent(shape,self.chain[num],r=1,s=1)

            pm.parent(ctrl.control.getShape(),self.chain[num],r=1,s=1)                        
            
            #stretch
            #Add attr
            pm.addAttr(self.chain[num],ln = 'stretch',at = 'double',dv = 0)
            pm.setAttr(self.chain[num] + '.stretch',e = 1,k = 1)
            
            #create node
            fkStrectchPMANodeName = nameUtils.getUniqueName(self.side,'fkStrectch','MDN')
            fkStrectchPMANode = pm.createNode('plusMinusAverage',n = fkStrectchPMANodeName)
            
            #connect
            oriTx = self.chain[num].tx.get()
            fkStrectchPMANode.input3D[0].input3Dx.set(oriTx)
            self.chain[num].stretch.connect(fkStrectchPMANode.input3D[1].input3Dx)
            fkStrectchPMANode.operation.set(1)
            fkStrectchPMANode.output3Dx.connect(self.chain[num].tx)
            
            #lock and hide
            control.lockAndHideAttr(self.chain[num],["tx","ty","tz","sy","sz","sx"])
            
        #delete grp   
        for i in range(len(reversedList)):
            pm.delete(reversedList[i].controlGrp)         
Beispiel #5
0
    def build(self):
        
        #build Trv
        self.guideTrv = pm.joint(p = [0,0,0],n = nameUtils.getUniqueName(self.side,self.baseName,'trv'))
        moPathName = nameUtils.getUniqueName(self.side,self.baseName,'MOP')
        moPathNode = pm.pathAnimation(self.guideCc,self.guideTrv,fractionMode = 1,follow = 1,followAxis = 'x',upAxis = 'y',worldUpType = 'vector',
                                      worldUpVector = [0,1,0],inverseUp = 0,inverseFront = 0,bank = 0,startTimeU = 1,endTimeU = 24,n = moPathName)
        pm.delete(moPathNode + '.uValue')        
#         pm.disconnectAttr(moPathNode + '_uValue.output',moPathNode + '.uValue')
        
        #set Trv Loc:
        self.trvPosList = []
        for num in range(0,self.segment):
            trvDis = num * (1 / float(self.segment-1))
            pm.setAttr(moPathNode + '.uValue',trvDis)
            trvPos = self.guideTrv.getTranslation(space = 'world')
            self.trvPosList.append(trvPos)

        #set loc
        #set loc grp
        for i,p in enumerate(self.trvPosList):
            trvName = nameUtils.getUniqueName(self.side,self.baseName + 'Fk','gud')
            loc = pm.spaceLocator(n = trvName)
            loc.t.set(p)
            self.fkGuides.append(loc)
            loc.setParent(self.guideGrp)
            
        tempGuides = list(self.fkGuides)
        tempGuides.reverse()
        
        #set loc grp
        for i in range(len(tempGuides)):
            if i != (len(tempGuides) - 1):
                pm.parent(tempGuides[i],tempGuides[i + 1])            
        
        name = nameUtils.getUniqueName(self.side,self.baseName + '_Gud','grp')        
        self.guideGrp = pm.group(em = 1,n = name)
        self.guideCc.setParent(self.guideGrp)
        self.fkGuides[0].setParent(self.guideGrp)
        self.guideTrv.setParent(self.guideGrp)
        self.guideGrp.v.set(0)
        
        self.__bodyCtrl()
        self.__fkJj()
        self.__ikJj()
        self.__squashStretch()
        self.__combine()
Beispiel #6
0
 def __measure(self,*arg):
     
     sizeOneCtrl = control.Control('m','measureSizeOne',1,'y')
     sizeOneCtrl.circleCtrl()
     sizeFiveCtrl = control.Control('m','measureSizeFive',5,'y')
     sizeFiveCtrl.circleCtrl()
     sizeTenCtrl = control.Control('m','measureSizeTen',10,'y')
     sizeTenCtrl.circleCtrl()
     sizeTwentyCtrl = control.Control('m','measureSizeTwenty',20,'y')
     sizeTwentyCtrl.circleCtrl()
     
     tempGrp = pm.group(empty = 1,n = nameUtils.getUniqueName('m','measure','grp'))
     sizeOneCtrl.controlGrp.setParent(tempGrp)
     sizeFiveCtrl.controlGrp.setParent(tempGrp)
     sizeTenCtrl.controlGrp.setParent(tempGrp)
     sizeTwentyCtrl.controlGrp.setParent(tempGrp)              
Beispiel #7
0
    def __combine(self):
        
        #spine cc
        hip = self.spineCc[0].getParent()
        mid = self.spineCc[1].getParent()
        chest = self.spineCc[2].getParent()
        
        chest.setParent(self.spineFkRevBlendChain.chain[-1])
        hip.setParent(self.spineFkRevBlendChain.chain[0])
        mid.setParent(self.spineFkRevBlendChain.chain[(self.segment - 1) / 2])
        hipPos = self.spineCc[0].getTranslation(space = 'world')

        pm.move(hipPos[0],hipPos[1],hipPos[2],self.bodyCtrl.control + '.rotatePivot')
        pm.move(hipPos[0],hipPos[1],hipPos[2],self.bodyCtrl.control + '.scalePivot')
        
        #create chestGRP
        self.chestGrp = pm.group(em = 1,n = nameUtils.getUniqueName('m','chest','grp'))
        self.chestGrp.setParent(self.spineFkRevBlendChain.chain[-1])
        pm.parentConstraint(self.spineCc[2],self.chestGrp, mo = True)
Beispiel #8
0
    def __squashStretch(self):
        
        #perpare Name
        startLocName = nameUtils.getUniqueName(self.side,self.baseName + '_StretchStart','loc')
        endLocName = nameUtils.getUniqueName(self.side,self.baseName + '_StretchEnd','loc')
        distanceBetweenNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','dist')
        multipleNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','MDN')
        conditionNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','COND')
        colorRedRemapValueName = nameUtils.getUniqueName(self.side,self.baseName + 'Red','RV')        
        colorGreenRemapValueName = nameUtils.getUniqueName(self.side,self.baseName + 'Green','RV')
#         expressionNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','EXP')
        stretchSwitchNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','BCN')
        
        #remap Node for ikJj scale
        remapNodeRed = pm.createNode('remapValue',n = colorRedRemapValueName)
        remapNodeGreen = pm.createNode('remapValue',n = colorGreenRemapValueName)
        remapNodeNum = ((self.segment - 1) / 2) + 1
        remapList = []
        for num in range(0,remapNodeNum):
            remapNodeName = nameUtils.getUniqueName(self.side,self.baseName + '_Stretch','RV')
            remapNode = pm.createNode('remapValue',n = remapNodeName)
            remapList.append(remapNode)
        
        #createNode
        distBetweenNode = pm.createNode('distanceBetween',n = distanceBetweenNodeName)
        multipleNode = pm.createNode('multiplyDivide',n = multipleNodeName)
        conditionNode = pm.createNode('condition',n = conditionNodeName)
        stretchSwitchNode = pm.createNode('blendColors',n = conditionNodeName)
        
        #set command
        self.stretchStartLoc = pm.spaceLocator(n = startLocName)
        self.stretchStartLoc.v.set(0)
        self.stretchEndLoc = pm.spaceLocator(n = endLocName)
        self.stretchEndLoc.v.set(0)
        
        #align loc
        startPos = self.ribbonJc[0].worldMatrix.get()
        endPos = self.ribbonJc[-1].worldMatrix.get()
        pm.xform(self.stretchStartLoc,matrix = startPos)
        pm.xform(self.stretchEndLoc,matrix = endPos)
        self.stretchStartLoc.setParent(self.spineCc[0])
        self.stretchEndLoc.setParent(self.spineCc[-1])
        
        #connect
        #stretch
        self.stretchStartLoc.worldPosition[0].connect(distBetweenNode.point1) 
        self.stretchEndLoc.worldPosition[0].connect(distBetweenNode.point2) 
        self.stretchLength = distBetweenNode.distance.get()
        self.bodyCtrl.control.volume.connect(stretchSwitchNode.blender)
        stretchSwitchNode.color1R.set(1)
        multipleNode.outputX.connect(stretchSwitchNode.color2R)
        
        #multiple    
        distBetweenNode.distance.connect(multipleNode.input1X)
        multipleNode.input2X.set(self.stretchLength)
        multipleNode.operation.set(2)
        
        #remap    
        for num,remapNode in enumerate(remapList):
            stretchSwitchNode.outputR.connect(remapNode.inputValue)
            remapNode.inputMax.set(2)
            remapNode.outputMin.set(3)
            remapNode.outputMax.set(-1)
            if (self.segment - num - 1) != num:
                remapNode.outValue.connect(self.spineIkBlendJoint[num].sx)
                remapNode.outValue.connect(self.spineIkBlendJoint[num].sz)
                remapNode.outValue.connect(self.spineIkBlendJoint[self.segment - num - 1].sx)
                remapNode.outValue.connect(self.spineIkBlendJoint[self.segment - num - 1].sz)
                
            else:
                remapNode.outValue.connect(self.spineIkBlendJoint[num].sx)
                remapNode.outValue.connect(self.spineIkBlendJoint[num].sz)
                
            remapNode.value[0].value_FloatValue.set(num * float(1 / float(self.segment - 1)))
            remapNode.value[0].value_Position.set(0)   
            remapNode.value[1].value_FloatValue.set(float(1 - (num * float(1 / float(self.segment - 1)))))
            remapNode.value[1].value_Position.set(1)                                                        
            remapNode.value[2].value_FloatValue.set(0.5)
            remapNode.value[2].value_Position.set(0.5)
            remapNode.value[2].value_Interp.set(1)
                                 
        #create shader
        materials = pm.shadingNode('blinn',asShader = 1,n = nameUtils.getUniqueName(self.side,self.baseName + 'Stretch','MAT'))
        shadingGroup = pm.sets(renderable = 1,noSurfaceShader = 1,empty = 1,name = nameUtils.getUniqueName(self.side,self.baseName + 'Stretch','SG'))
        materials.outColor.connect(shadingGroup.surfaceShader)

        #condition node
        multipleNode.outputX.connect(conditionNode.firstTerm)
        conditionNode.secondTerm.set(1)
        conditionNode.operation.set(2)
        conditionNode.colorIfTrueR.set(0)
        conditionNode.colorIfFalseR.set(0)        
        conditionNode.colorIfTrueG.set(0)
        conditionNode.colorIfFalseG.set(0)
        conditionNode.colorIfTrueB.set(0)
        conditionNode.colorIfFalseB.set(0)
        
        #bug spotted!!!
        '''
        color cannot change interactively
        '''
        
        stretchSwitchNode.outputR.connect(remapNodeRed.inputValue)
        stretchSwitchNode.outputR.connect(remapNodeGreen.inputValue)
        remapNodeRed.inputMin.set(1)
        remapNodeRed.inputMax.set(2)
        remapNodeRed.outputMin.set(0)
        remapNodeRed.outputMax.set(1)
        remapNodeGreen.inputMin.set(0)
        remapNodeGreen.inputMax.set(1)
        remapNodeGreen.outputMin.set(1)
        remapNodeGreen.outputMax.set(0)   
        remapNodeRed.outValue.connect(conditionNode.colorIfTrueR)   
        remapNodeGreen.outValue.connect(conditionNode.colorIfFalseG)    
#         print materials +  '.incandescenceR = ' + conditionNode + '.outColorR'
#         print materials +  '.incandescenceG = ' + conditionNode + '.outColorG'
#         print materials +  '.incandescenceB = ' + conditionNode + '.outColorB'
        conditionNode.outColor.outColorR.connect(materials.incandescence.incandescenceR)
        conditionNode.outColor.outColorG.connect(materials.incandescence.incandescenceG)
        conditionNode.outColor.outColorB.connect(materials.incandescence.incandescenceB)
Beispiel #9
0
    def __ikJj(self):    
        
        self.ikJj = []
        #create IKRibbonSpine
        #ribbon spine info:
        curveInfo = [0,(self.segment - 1) / 4,(self.segment - 1) / 2,
                     ((self.segment - 1) / 2 + (self.segment - 1)) / 2,
                     (self.segment - 1)]
        ribbonCurve = []
        self.folList = []
        
        #create curve
        for jjInfo in curveInfo:
            ribonJjPos = self.spineFkBlendChain.chain[jjInfo].getTranslation(space = 'world') 
            ribbonCurve.append(ribonJjPos)
        
        #set ribbon offset
        offset = float(self.length * 0.05)
        
        #set ribbon cur
        ribbonCurveL = pm.curve(d = 3,p = [ribbonCurve[0],ribbonCurve[1],ribbonCurve[2],ribbonCurve[3],ribbonCurve[4]],
                                k = [0,0,0,1,2,2,2],n = nameUtils.getUniqueName(self.side,self.baseName + '_ribbonL','gud'))

        pm.move(offset,0,0,ribbonCurveL)         

        ribbonCurveR = pm.curve(d = 3,p = [ribbonCurve[0],ribbonCurve[1],ribbonCurve[2],ribbonCurve[3],ribbonCurve[4]],
                                k = [0,0,0,1,2,2,2],n = nameUtils.getUniqueName(self.side,self.baseName + '_ribbonR','gud')) 
         
        pm.move(-offset,0,0,ribbonCurveR)     
        
        ribbonCurveR.setParent(self.guideGrp)
        ribbonCurveL.setParent(self.guideGrp)
        
        #create ribbon surf
        ribbonGeo = pm.loft(ribbonCurveR,ribbonCurveL,ch = 0,u = 1,c = 0,ar = 1,d = 3,ss = 1, rn = 0,po = 0,rsn = 1,
                             n = nameUtils.getUniqueName(self.side,self.baseName + '_ribbon','surf'))
        
        ribbonClusList = []
        self.ribbonJc = []
        self.spineCc = []
        
        #get loc pos
        for num,loc in enumerate(self.fkGuides):
            startLoc = self.fkGuides[0]
            midLoc = self.fkGuides[(len(self.fkGuides) - 1) / 2]
            endLoc = self.fkGuides[-1]
             
            startLocPos = pm.xform(startLoc,ws = 1,t = 1,q = 1)[1]
            midLocPos = pm.xform(midLoc,ws = 1,t = 1,q = 1)[1]
            endLocPos = pm.xform(endLoc,ws = 1,t = 1,q = 1)[1]
        
        #get Jc pos
        for num in [0,2,4]:
            pos = pm.select(ribbonGeo[0] + '.cv[' + str(num) + '][0:3]',r = 1)
            clus = pm.cluster()
            pm.rename(clus[1],nameUtils.getUniqueName(self.side,self.baseName + '_ribbon','cls'))
            ribbonClusList.append(clus)
            pm.select(cl = 1)
             
        #set cvpos
        for vert in [1,3]:
            for row in range(0,4):
                cvNum = pm.select(ribbonGeo[0] + '.cv[' + str(vert) + '][' + str(row) + ']',r = 1)
                oriPos = pm.xform(cvNum,ws = 1,t = 1,q = 1)
                if vert == 1:
                    pm.xform(cvNum,ws = 1,t = (oriPos[0],(startLocPos + midLocPos) / 2,oriPos[2]))
                elif vert == 3:
                    pm.xform(cvNum,ws = 1,t = (oriPos[0],(endLocPos + midLocPos) / 2,oriPos[2])) 
             
        #set Jc and Jc ctrl    
        for num,x in enumerate(ribbonClusList):
            jc = pm.joint(p = x[1].getRotatePivot(),
                          n = nameUtils.getUniqueName(self.side,self.baseName + self.nameList[num],'jc'),
                          radius = self.length / 3)
            self.ribbonJc.append(jc)
            pm.select(cl = 1)
            pm.delete(ribbonClusList[num])
            pm.select(cl = 1)
            cc = control.Control(self.side,self.baseName + self.nameList[num],size = self.ikSize,aimAxis = self.ctrlAxis)
            cc.circleCtrl()
            pm.makeIdentity(cc.control,apply = True,t=0,r=1,s=0,n=0,pn=1)
#             self.bodyCtrl.control.ik_vis.connect(cc.controlGrp.v)
            self.bodyCtrl.control.ik_vis.connect(cc.control.getShape().v)
            self.spineCc.append(cc.control)
            control.lockAndHideAttr(cc.control,['sx','sy','sz','v'])
            pm.xform(cc.controlGrp,ws = 1,matrix = jc.worldMatrix.get())
        
        #skin Jc
        for num,jc in enumerate(self.ribbonJc):
            jc.setParent(self.spineCc[num])

        ribbonSkin = pm.skinCluster(self.ribbonJc[0],self.ribbonJc[1],self.ribbonJc[2],ribbonGeo[0],
                       tsb = 1,ih = 1,mi = 3,dr = 4,rui = 1,n = nameUtils.getSkinName())
        
        #skin 
        pm.skinPercent(ribbonSkin,ribbonGeo[0] + '.cv[0][0:3]', transformValue=[(self.ribbonJc[0],1)])
        pm.skinPercent(ribbonSkin,ribbonGeo[0] + '.cv[1][0:3]', transformValue=[(self.ribbonJc[1],0.5),(self.ribbonJc[0],0.5)])
        pm.skinPercent(ribbonSkin,ribbonGeo[0] + '.cv[2][0:3]', transformValue=[(self.ribbonJc[1],1)])
        pm.skinPercent(ribbonSkin,ribbonGeo[0] + '.cv[3][0:3]', transformValue=[(self.ribbonJc[1],0.5),(self.ribbonJc[2],0.5)])
        pm.skinPercent(ribbonSkin,ribbonGeo[0] + '.cv[4][0:3]', transformValue=[(self.ribbonJc[2],1)])    
        
        #set fol
        #create / rename fol
        self.folGrp = pm.group(em = 1,n = nameUtils.getUniqueName(self.side,self.baseName + 'Fol','grp')) 
        
        for fol in range(0,self.segment):
            
            #createNodeName
            follicleTransName = nameUtils.getUniqueName(self.side,self.baseName,'fol')
            follicleShapeName = nameUtils.getUniqueName(self.side,self.baseName,'folShape')
            
            #createNode
            follicleShape = pm.createNode('follicle',n = follicleShapeName)
            follicleTrans = pm.listRelatives(follicleShape, parent=True)[0]
            follicleTrans = pm.rename(follicleTrans, follicleTransName)
            
            # connect the surface to the follicle
            if ribbonGeo[0].getShape().nodeType() == 'nurbsSurface':
                pm.connectAttr((ribbonGeo[0] + '.local'), (follicleShape + '.inputSurface'))
                
            #Connect the worldMatrix of the surface into the follicleShape
            pm.connectAttr((ribbonGeo[0].getShape() + '.worldMatrix[0]'), (follicleShape + '.inputWorldMatrix'))
            
            #Connect the follicleShape to it's transform
            pm.connectAttr((follicleShape + '.outRotate'), (follicleTrans + '.rotate'))
            pm.connectAttr((follicleShape + '.outTranslate'), (follicleTrans + '.translate'))
            
            #Set the uValue and vValue for the current follicle
            pm.setAttr((follicleShape + '.parameterV'), 0.5)
            pm.setAttr((follicleShape + '.parameterU'), float(1.0 / float(self.segment - 1)) * fol)

            #Lock the translate/rotate of the follicle
            pm.setAttr((follicleTrans + '.translate'), lock=True)
            pm.setAttr((follicleTrans + '.rotate'), lock=True)
            pm.setAttr((follicleShape + '.degree'),1)
            
            #parent
            self.folList.append(follicleTrans)
            follicleTrans.setParent(self.folGrp)
        
        #rebuild fol pos
        self.spineIkBlendJoint = []
        self.stretchCube = []
        for num,fol in enumerate(self.folList):
            jj = pm.joint(p = (0,0,0),n = nameUtils.getUniqueName(self.side,self.baseName,'jj'),
                          radius = self.length / 5)
            self.spineIkBlendJoint.append(jj)
            jj.setParent(fol)
            tempCube = pm.polyCube(ch = 1,o = 1,w = float(self.length / 5),h = float(self.length / 10),
                                   d = float(self.length / 5),cuv = 4,n = nameUtils.getUniqueName(self.side,self.baseName,'cube'))
            tempCube[0].setParent(jj)
            tempCube[0].v.set(0)
            self.stretchCube.append(tempCube[0])
            jj.translateX.set(0)
            jj.translateY.set(0)
            jj.translateZ.set(0)
            self.ikJj.append(jj)
            
        #create spine grp
        self.spineIkGrp = pm.group(self.spineCc[0].getParent(),self.spineCc[1].getParent(),self.spineCc[2].getParent(),self.folGrp,ribbonGeo[0],
                                   n = nameUtils.getUniqueName(self.side,self.baseName + 'Ik','grp'))
        ribbonGeo[0].inheritsTransform.set(0)
        self.folGrp.inheritsTransform.set(0)
        
        #clean
        self.spineIkGrp.setParent(self.bodyCtrl.control)
        
        #temp
        self.spineIkGrp.v.set(1)
        
        '''put chest ctrl under chest cc'''
        '''put leg under hip cc'''
Beispiel #10
0
    def __fkJj(self):
        
        #create fk jj
        self.spineFkRevBlendChain = []        
        self.guideSpineFkPos = [x.getTranslation(space = 'world') for x in self.fkGuides]
        self.guideSpineFkRot = [x.getRotation(space = 'world') for x in self.fkGuides]
        
        self.spineFkBlendChain = boneChain.BoneChain(self.baseName,self.side,type = 'fk')
        self.spineFkBlendChain.fromList(self.guideSpineFkPos,self.guideSpineFkRot,autoOrient = 1)
        
        #create revFk MDN node
        fkMultipleNodeList = []
        fkPlusMinusAverageList = []
        for num,fkJj in enumerate(self.spineFkBlendChain.chain):
            fkMultipleNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'Fk','MDN')
            fkMultipleNode = pm.createNode('multiplyDivide',n = fkMultipleNodeName)
            fkMultipleNodeList.append(fkMultipleNode)
            
            fkPlusMinusAverageNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'Fk','PMA')
            fkPlusMinusAverageNode = pm.createNode('plusMinusAverage',n = fkPlusMinusAverageNodeName)
            fkPlusMinusAverageNode.operation.set(1)
            fkPlusMinusAverageList.append(fkPlusMinusAverageNode)         

            fkJj.rx.connect(fkMultipleNode.input1X)
            fkJj.ry.connect(fkMultipleNode.input1Y)
            fkJj.rz.connect(fkMultipleNode.input1Z)
            
            fkMultipleNode.input2X.set(-1)
            fkMultipleNode.input2Y.set(-1)
            fkMultipleNode.input2Z.set(-1)
            
            fkMultipleNode.outputX.connect(fkPlusMinusAverageNode.input3D[0].input3Dx)
            fkMultipleNode.outputY.connect(fkPlusMinusAverageNode.input3D[0].input3Dy)
            fkMultipleNode.outputZ.connect(fkPlusMinusAverageNode.input3D[0].input3Dz)
                
        #clean up
        self.spineFkGrp = pm.group(self.spineFkBlendChain.chain[0],
                                   n = nameUtils.getUniqueName(self.side,self.baseName + 'Fk','grp'))
        
        self.spineFkGrp.setParent(self.bodyCtrl.control)
        
        #create revFk
        self.guideSpineRevFkPos = [x.getTranslation(space = 'world') for x in self.fkGuides]
        self.guideSpineRevFkRot = [x.getRotation(space = 'world') for x in self.fkGuides]
 
        self.spineFkRevBlendChain = boneChain.BoneChain(self.baseName + 'Rev',self.side,type = 'fk')
        self.spineFkRevBlendChain.fromList(self.guideSpineRevFkPos,self.guideSpineRevFkRot,autoOrient = 1)  
        
        #reroot skl
        pm.select(self.spineFkRevBlendChain.chain[-1])
        pm.runtime.RerootSkeleton()     
        self.spineFkRevBlendChain.chain[-1].setParent(self.spineFkBlendChain.chain[-1])

        #set Rotate
        #nodename
        multiplefkBendNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkBend','MDN')
        multiplefkRevBendNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkRevBend','MDN')
        multiplefkTwistNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkTwist','MDN')
        multiplefkRevTwistNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkRevTwist','MDN')
        multiplefkSideNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkSide','MDN')
        multiplefkRevSideNodeName = nameUtils.getUniqueName(self.side,self.baseName + 'FkRevSide','MDN')                
          
        #nodecreate
        multiplefkBendNode = pm.createNode('multiplyDivide',n = multiplefkBendNodeName)
        multiplefkRevBendNode = pm.createNode('multiplyDivide',n = multiplefkRevBendNodeName)
        multiplefkTwistNode = pm.createNode('multiplyDivide',n = multiplefkTwistNodeName)
        multiplefkRevTwistNode = pm.createNode('multiplyDivide',n = multiplefkRevTwistNodeName)
        multiplefkSideNode = pm.createNode('multiplyDivide',n = multiplefkSideNodeName)
        multiplefkRevSideNode = pm.createNode('multiplyDivide',n = multiplefkRevSideNodeName)        
         
        #connect
        #bend
        self.bodyCtrl.control.bend_lo.connect(multiplefkBendNode.input1X)
        self.bodyCtrl.control.bend_mid.connect(multiplefkBendNode.input1Y)
        self.bodyCtrl.control.bend_up.connect(multiplefkBendNode.input1Z)
        self.bodyCtrl.control.bend_lo_rev.connect(multiplefkRevBendNode.input1X)
        self.bodyCtrl.control.bend_mid_rev.connect(multiplefkRevBendNode.input1Y)
        self.bodyCtrl.control.bend_up_rev.connect(multiplefkRevBendNode.input1Z)
         
        multiplefkBendNode.input2X.set(-1)
        multiplefkBendNode.input2Y.set(-1)
        multiplefkBendNode.input2Z.set(-1)
        multiplefkBendNode.operation.set(1)
         
        multiplefkRevBendNode.input2X.set(-1)
        multiplefkRevBendNode.input2Y.set(-1)
        multiplefkRevBendNode.input2Z.set(-1)
        multiplefkRevBendNode.operation.set(1)        
         
        #twist
        self.bodyCtrl.control.twist_lo.connect(multiplefkTwistNode.input1X)
        self.bodyCtrl.control.twist_mid.connect(multiplefkTwistNode.input1Y)
        self.bodyCtrl.control.twist_up.connect(multiplefkTwistNode.input1Z)
        self.bodyCtrl.control.twist_lo_rev.connect(multiplefkRevTwistNode.input1X)
        self.bodyCtrl.control.twist_mid_rev.connect(multiplefkRevTwistNode.input1Y)
        self.bodyCtrl.control.twist_up_rev.connect(multiplefkRevTwistNode.input1Z)
         
        multiplefkTwistNode.input2X.set(-1)
        multiplefkTwistNode.input2Y.set(-1)
        multiplefkTwistNode.input2Z.set(-1)
        multiplefkTwistNode.operation.set(1)
         
        multiplefkRevTwistNode.input2X.set(-1)
        multiplefkRevTwistNode.input2Y.set(-1)
        multiplefkRevTwistNode.input2Z.set(-1)
        multiplefkRevTwistNode.operation.set(1)        
         
        #side
        self.bodyCtrl.control.side_lo.connect(multiplefkSideNode.input1X)
        self.bodyCtrl.control.side_mid.connect(multiplefkSideNode.input1Y)
        self.bodyCtrl.control.side_up.connect(multiplefkSideNode.input1Z)
        self.bodyCtrl.control.side_lo_rev.connect(multiplefkRevSideNode.input1X)
        self.bodyCtrl.control.side_mid_rev.connect(multiplefkRevSideNode.input1Y)
        self.bodyCtrl.control.side_up_rev.connect(multiplefkRevSideNode.input1Z)
         
        multiplefkSideNode.input2X.set(-1)
        multiplefkSideNode.input2Y.set(-1)
        multiplefkSideNode.input2Z.set(-1)
        multiplefkSideNode.operation.set(1)
         
        multiplefkRevSideNode.input2X.set(-1)
        multiplefkRevSideNode.input2Y.set(-1)
        multiplefkRevSideNode.input2Z.set(-1)
        multiplefkRevSideNode.operation.set(1)                     
         
        #fk
        for num,chain in enumerate(self.spineFkBlendChain.chain):
            #lo
            if 1 <= num <= (self.segment / 3):
                multiplefkBendNode.outputX.connect(chain.rz)
                multiplefkSideNode.outputX.connect(chain.ry)
                multiplefkTwistNode.outputX.connect(chain.rx)
            #mid    
            elif (self.segment / 3) < num < ((self.segment / 3) * 2):
                multiplefkBendNode.outputY.connect(chain.rz)
                multiplefkSideNode.outputY.connect(chain.ry)
                multiplefkTwistNode.outputY.connect(chain.rx)
            #up    
            elif ((self.segment / 3) * 2) <= num < (self.segment - 1):
                multiplefkBendNode.outputZ.connect(chain.rz)
                multiplefkSideNode.outputZ.connect(chain.ry)
                multiplefkTwistNode.outputZ.connect(chain.rx)
            
        #revFk        
#         self.spineFkRevBlendChain.chain.reverse()
        for num,chain in enumerate(self.spineFkRevBlendChain.chain):
            #lo
            if 1 <= num <= (self.segment / 3 - 1):
                multiplefkRevBendNode.outputX.connect(fkPlusMinusAverageList[num].input3D[1].input3Dz)
                multiplefkRevSideNode.outputX.connect(fkPlusMinusAverageList[num].input3D[1].input3Dy)
                multiplefkRevTwistNode.outputX.connect(fkPlusMinusAverageList[num].input3D[1].input3Dx)
                 
                fkPlusMinusAverageList[num].output3D.output3Dz.connect(chain.rz)
                fkPlusMinusAverageList[num].output3D.output3Dy.connect(chain.ry)
                fkPlusMinusAverageList[num].output3D.output3Dx.connect(chain.rx)
                 
            #mid              
            elif (self.segment / 3 - 1) < num < ((self.segment / 3) * 2):
                multiplefkRevBendNode.outputY.connect(fkPlusMinusAverageList[num].input3D[1].input3Dz)
                multiplefkRevSideNode.outputY.connect(fkPlusMinusAverageList[num].input3D[1].input3Dy)
                multiplefkRevTwistNode.outputY.connect(fkPlusMinusAverageList[num].input3D[1].input3Dx)
                 
                fkPlusMinusAverageList[num].output3D.output3Dz.connect(chain.rz)
                fkPlusMinusAverageList[num].output3D.output3Dy.connect(chain.ry)
                fkPlusMinusAverageList[num].output3D.output3Dx.connect(chain.rx)
                 
            #up    
            elif ((self.segment / 3) * 2) <= num < (self.segment - 1):
                multiplefkRevBendNode.outputZ.connect(fkPlusMinusAverageList[num].input3D[1].input3Dz)
                multiplefkRevSideNode.outputZ.connect(fkPlusMinusAverageList[num].input3D[1].input3Dy)
                multiplefkRevTwistNode.outputZ.connect(fkPlusMinusAverageList[num].input3D[1].input3Dx)
                 
                fkPlusMinusAverageList[num].output3D.output3Dz.connect(chain.rz)     
                fkPlusMinusAverageList[num].output3D.output3Dy.connect(chain.ry)
                fkPlusMinusAverageList[num].output3D.output3Dx.connect(chain.rx)