def createCorJnt(self): ''' Creat a helper joint with selected vertex. ''' vtx = cmds.ls(sl=True)[0] # Create a joint from selected vertex. vtxWldPos = cmds.pointPosition(vtx, world=True) cmds.select(cl=True) cmds.joint(p=(vtxWldPos), n=self.helperJnt) cmds.CompleteCurrentTool() # Constraint for align to the driver joint. geo = vtx.split('.')[0] cmds.delete( cmds.orientConstraint(self.driverJnt, self.helperJnt, mo=False)) # Freeze transform cmds.makeIdentity(self.helperJnt, apply=True) # Add influence. skinClst = mel.eval('findRelatedSkinCluster("%s");' % geo) cmds.skinCluster(skinClst, e=True, dr=4, lw=True, wt=0, ai=self.helperJnt) cmds.setAttr('%s.liw' % self.helperJnt, False)
def jntChain(cls, crv, numOfJnt, increNum, *args): # Initialize un value. unNum = 0 # Delete joint chain if exists it. if cmds.objExists('%s_0_bnd_jnt' % crv): cmds.delete('%s_0_bnd_jnt' % crv) # Build joint chain cls.bndJntLs = [] cmds.select(cl=True) for i in xrange(numOfJnt): jntPos = cmds.pointPosition('%s.un[%f]' % (crv, unNum), w=True) bndJnt = cmds.joint(p=jntPos, n='%s_%d_bnd_jnt' % (crv, i)) cls.bndJntLs.append(bndJnt) unNum += increNum cmds.CompleteCurrentTool() # Orient joints oriJntOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v2=True) if oriJntOpt: cls.orientJntChain(cls.bndJntLs) # cmds.select(cls.bndJntLs, r = True) # cmds.ToggleLocalRotationAxes() # cmds.select(crv, r = True) return cls.bndJntLs
def createBndJnt(cls, crv, numOfJnt, increNum, *args): # Delete bind joints and pointOnSurfaceInfo node if exists it. if cmds.objExists('%s_*_bnd_jnt' % crv): cmds.delete('%s_*_bnd_jnt' % crv) if cmds.objExists('%s_*_bnd_jnt_pOnSurfInfo' % crv): cmds.delete('%s_*_bnd_jnt_pOnSurfInfo' % crv) # Initialize un value. unNum = 0 # Build joint chain cls.bndJntLs = [] cmds.select(cl=True) for i in xrange(numOfJnt): jntPos = cmds.pointPosition('%s.un[%f]' % (crv, unNum), w=True) bndJnt = cmds.joint(p=jntPos, n='%s_%d_bnd_jnt' % (crv, i)) cls.bndJntLs.append(bndJnt) unNum += increNum cmds.CompleteCurrentTool() # Unparent curve bind joints. for crvBndJnt in cls.bndJntLs: if cmds.listRelatives(crvBndJnt, p=True): cmds.parent(crvBndJnt, w=True) else: pass # Orient curve bind joints oriJntOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v2=True) if oriJntOpt: cls.orientJnt(cls.bndJntLs, cls.ribbon, 'bndJnt') return cls.bndJntLs
def ctrlLayout(cls, crv, numOfCtrl, numOfSpan, increNum, *args): # Initialize un value. unNum = 0 reCrvOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v1=True) if reCrvOpt: # Rebuild curve's control points uniformly for even joint distribution. cmds.rebuildCurve(crv, ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=numOfSpan, d=3, tol=0) # Delete curve bind joint chain if exists it. if cmds.objExists('%s_*_crv_bnd_jnt' % crv): cmds.delete('%s_*_crv_bnd_jnt' % crv) # Build joint chain hierarchy for orient joints. cmds.select(cl=True) cls.crvBndJntLs = [] for i in xrange(numOfCtrl): crvBndJntPos = cmds.pointPosition('%s.un[%f]' % (crv, unNum), w=True) crvBndJnt = cmds.joint(p=crvBndJntPos, n='%s_%d_crv_bnd_jnt' % (crv, i), radius=10) cls.crvBndJntLs.append(crvBndJnt) unNum += increNum cmds.CompleteCurrentTool() # Orient curve bind joints oriJntOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v2=True) if oriJntOpt: cls.orientJntChain(cls.crvBndJntLs) # Unparent curve bind joints. for crvBndJnt in cls.crvBndJntLs: if cmds.listRelatives(crvBndJnt, p=True): cmds.parent(crvBndJnt, w=True) else: pass return cls.crvBndJntLs
selLs = cmds.ls(sl = True) cmds.editDisplayLayerMembers('jointLayer', selLs) # Create Joint on Object and Bind # selLs = cmds.ls(sl = True) for sel in selLs: # Create joint selWsPos = cmds.xform(sel, q = True, rp = True, ws = True) cmds.select(cl = True) bndJnt = cmds.joint(n = sel + '_bnd_jnt', p = selWsPos) cmds.CompleteCurrentTool() # Bind cmds.skinCluster(bndJnt, sel, mi = 3, dr = 4.5, tsb = True, omi = False, nw = 1) selLs = cmds.ls(sl = True) srcJnt = selLs[0] trgGeos = selLs[1:]
def ctrlLayout(cls, crv, numOfCtrl, numOfSpan, increNum, *args): # Initialize un value. unNum = 0 reCrvOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v1=True) if reCrvOpt: # Rebuild curve's control points uniformly for even joint distribution. cmds.rebuildCurve(crv, ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=numOfSpan, d=3, tol=0) else: crvNumOfSpan = cmds.getAttr('%s.spans' % crv) numOfSpan = crvNumOfSpan # Delete ribbon if exists if cmds.objExists('%s_ribbon' % crv): cmds.delete('%s_ribbon' % crv) # Create ribbon cls.ribbon = cls.ribbonFromCrv(crv, numOfSpan) # Delete ribbon bind joint chain if exists it. if cmds.objExists('%s_*_rbBnd' % crv): cmds.delete('%s_*_rbBnd' % crv) # Build joint chain hierarchy for orient joints. cmds.select(cl=True) cls.rbBndJntLs = [] for i in xrange(numOfCtrl): rbBndJntPos = cmds.pointPosition('%s.un[%f]' % (crv, unNum), w=True) rbBndJnt = cmds.joint(p=rbBndJntPos, n='%s_%d_rbBnd' % (crv, i), radius=5) cls.rbBndJntLs.append(rbBndJnt) unNum += increNum cmds.CompleteCurrentTool() # Unparent ribbon bind joints. for rbBndJnt in cls.rbBndJntLs: if cmds.listRelatives(rbBndJnt, p=True): cmds.parent(rbBndJnt, w=True) else: pass # Orient ribbon bind joints oriJntOpt = cmds.checkBoxGrp(cls.uiWdgDic['preChkBoxGrp'], q=True, v2=True) if oriJntOpt: cls.orientJnt(cls.rbBndJntLs, cls.ribbon, 'rbBndJnt') return cls.rbBndJntLs