Beispiel #1
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 #2
0
    def __bodyCtrl(self):
         
        self.bodyCtrl = control.Control(self.side,self.baseName + 'Main',size = self.bodySize * 1.25,aimAxis = self.ctrlAxis) 
        self.bodyCtrl.circleCtrl()
        
        #move the target object
#         midPos = self.fkGuides[(self.segment - 1) / 2].getTranslation(space = 'world')
#         pm.move(midPos[0],midPos[1],midPos[2] - self.length / 1.5,self.bodyCtrl.controlGrp,a=True)
        
        endPos = self.fkGuides[0].getTranslation(space = 'world')
        pm.move(endPos[0],endPos[1],endPos[2],self.bodyCtrl.controlGrp,a=True)
        
        #lock and hide
        control.lockAndHideAttr(self.bodyCtrl.control,['sx','sy','sz','v'])
        
        #add attr
        control.addFloatAttr(self.bodyCtrl.control,['volume'],0,1)
        control.addFloatAttr(self.bodyCtrl.control,['ik_vis'],0,1)
        self.bodyCtrl.control.ik_vis.set(1)
        
        #bend
        pm.addAttr(self.bodyCtrl.control,ln = '______',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '.______',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['bend_up','bend_mid','bend_lo'],-3600,3600)

        pm.addAttr(self.bodyCtrl.control,ln = '_______',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '._______',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['bend_up_rev','bend_mid_rev','bend_lo_rev'],-3600,3600)
        
        #side
        pm.addAttr(self.bodyCtrl.control,ln = '__________',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '.__________',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['side_up','side_mid','side_lo'],-3600,3600)

        pm.addAttr(self.bodyCtrl.control,ln = '___________',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '.___________',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['side_up_rev','side_mid_rev','side_lo_rev'],-3600,3600)               
        
        #twist
        pm.addAttr(self.bodyCtrl.control,ln = '________',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '.________',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['twist_up','twist_mid','twist_lo'],-3600,3600)

        pm.addAttr(self.bodyCtrl.control,ln = '_________',at = 'enum',en = '0')
        pm.setAttr(self.bodyCtrl.control + '._________',e = 1,channelBox = 1)
        control.addFloatAttr(self.bodyCtrl.control,
                             ['twist_up_rev','twist_mid_rev','twist_lo_rev'],-3600,3600)                 
Beispiel #3
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 #4
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 #5
0
 def boxCreate(self):     
     
     self.cubeList = []
     #bos create
     #local variable
     a = 1
     count = 0
     pm.select(cl = 1)
     
     for joint in self.joints:
         pm.select(joint,add = 1) 
      
     joints = pm.ls(sl=1,type='joint')       
     child = pm.listRelatives(c=1) 
      
     #shader check:
     if not pm.objExists('green'):
         green = pm.shadingNode('lambert', asShader=True,n='green')
         pm.setAttr(green + '.color',0,1,0,type = "double3")
         pm.sets(r=True,nss=True,em=True,n='greenSG') 
         pm.connectAttr('green.outColor','greenSG.surfaceShader',f=True)
          
         red = pm.shadingNode('lambert', asShader=True,n='red')
         pm.setAttr(red + '.color',1,0,0,type = "double3") 
         pm.sets(r=True,nss=True,em=True,n='redSG') 
         pm.connectAttr('red.outColor','redSG.surfaceShader',f=True)
          
         blue = pm.shadingNode('lambert', asShader=True,n='blue')
         pm.setAttr(blue + '.color',0,0,1,type = "double3") 
         pm.sets(r=True,nss=True,em=True,n='blueSG') 
         pm.connectAttr('blue.outColor','blueSG.surfaceShader',f=True)
          
     #rolling:
     for joint in joints:       
         cube = pm.polyCube(n=joint.name() + '_geo_' + str(a),sx=1,sy=1,sz=1)
         self.cubeList.append(cube)
         pm.parent(cube,joint)
         if count < (len(joints)-1):
             tx = pm.getAttr(child[count] + '.tx')
             ty = pm.getAttr(child[count] + '.ty')
             tz = pm.getAttr(child[count] + '.tz')
                      
             abtx = abs(tx)
             abty = abs(ty)
             abtz = abs(tz)
              
             pm.setAttr(cube[0] + '.tx',tx * 0.5)
             pm.setAttr(cube[0] + '.ty',ty * 0.5)
             pm.setAttr(cube[0] + '.tz',tz * 0.5)
             pm.setAttr(cube[0] + '.r',0,0,0)
          
             radius = pm.getAttr(joint + '.radius')
          
             if abtx > 0.001:
                 sx = abtx
             else :    
                 sx = radius
              
             if abty > 0.001:
                 sy = abty
             else :    
                 sy = radius
         
             if abtz > 0.001:
                 sz = abtz
             else :    
                 sz = radius            
          
             pm.setAttr(cube[0] + '.sx',sx)
             pm.setAttr(cube[0] + '.sy',sy)
             pm.setAttr(cube[0] + '.sz',sz)
              
             #set material
             greenFace = pm.select(cube[0] + '.f[0]',cube[0] + '.f[2]')  
             mc.sets(fe = 'greenSG',e=True) 
              
             redFace = pm.select(cube[0] + '.f[1]',cube[0] + '.f[3]') 
             mc.sets(fe = 'redSG',e=True)
              
             blueFace = pm.select(cube[0] + '.f[4]',cube[0] + '.f[5]') 
             mc.sets(fe = 'blueSG',e=True)
  
             #clear history
             pm.select(cube[0])
             pm.makeIdentity(cube[0],t=1,s=1,r=1,a=1)
              
             #get ready for next roll
             a += 1
             count += 1                
              
     for cube in self.cubeList:
         cube[0].s.set(1,self.size,self.size)    
         control.lockAndHideAttr(cube[0],['tx','ty','tz','rx','ry','rz','sx','sy','sz'])
         
     #break the cycle delete the tail       
     pm.delete(self.cubeList[-1])
     self.cubeList.pop()