当前位置: 首页>>代码示例>>Python>>正文


Python cmds.skinPercent函数代码示例

本文整理汇总了Python中maya.cmds.skinPercent函数的典型用法代码示例。如果您正苦于以下问题:Python skinPercent函数的具体用法?Python skinPercent怎么用?Python skinPercent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了skinPercent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: skinWeights

def	skinWeights(x=None, export=None, f=None, fileName=None):
# Import/export skin weights from/to a file
# x/export: 0 for import, 1 for export
# f/fileName: filename under default project directory

	x = x or export

	if not (f or fileName):
		raise Exception, "Missing argument: fileName"
		
	if fileName:
		f = fileName
	
	obj = cmds.ls(sl=1)
	if not obj:
		raise Exception, "No object selected"

	obj = obj[0]

	node = None
	for n in cmds.listHistory(obj, f=0, bf=1):
		if cmds.nodeType(n) == 'skinCluster':
			node = n
			break
	if not node:
		raise Exception, "no skin cluster found"

	mode = "r"
	if x:
		mode = "w"
	f = open(cmds.internalVar(uwd=1) + f, mode)

	allTransforms = cmds.skinPercent(node, cmds.ls(cmds.polyListComponentConversion(obj, tv=1), fl=1), q=1, t=None)

	for vertex in cmds.ls(cmds.polyListComponentConversion(obj,tv=1), fl=1):
		if x:
			transforms = cmds.skinPercent(node, vertex, ib=1e-010, q=1, t=None)
			weights = cmds.skinPercent(node, vertex, ib=1e-010, q=1, v=1)
			s = ""
			for i in range(len(transforms)):
				s += str(weights[i])+"@"+transforms[i]+" "
			f.write(s+"\n")
		else:
			weights = {}
			for t in allTransforms:
				weights[t] = float(0)

			readWeights = f.readline().strip().split(" ")

			for i in readWeights:
				w = i.split("@")
				if w[1] in weights:
					weights[w[1]] = float(w[0])

			w = []
			for i in weights.iteritems():
				w.append(i)
			cmds.skinPercent(node, vertex, tv=w)

	f.close()
开发者ID:cgriders,项目名称:jcScripts,代码行数:60,代码来源:character.py

示例2: normalizeWeights

    def normalizeWeights(self, selName, infNames, clusterNode):
        """
        Remove non-zero weighting:
        Temporarily removing weight normalization allows for a weight prune
        Weight pruning is done to remove all non-zero weighting
        Non-zero weighting is removed to compress object data (faster speed) and file size
        """
        clusterName = clusterNode.name()

        # Unlock influences first
        for inf in infNames:
            cmds.setAttr("%s.liw" % inf, 0)

        # Temporarily turn off normalize
        normalizeSetting = cmds.getAttr("%s.normalizeWeights" % clusterName)

        if normalizeSetting != 0:
            cmds.setAttr("%s.normalizeWeights" % clusterName, 0)

        # Prune non-zero weights
        cmds.skinPercent(clusterName, selName, nrm=False, prw=100)
        # Turn normalize back on
        if normalizeSetting != 0:
            # cmds.setAttr('%s.normalizeWeights' % clusterName, normalizeSetting)
            cmds.setAttr("%s.normalizeWeights" % clusterName, normalizeSetting)
开发者ID:carlkeifer3,项目名称:tbRigKit,代码行数:25,代码来源:tbSaveWeights.py

示例3: clampInfluences

 def clampInfluences(self, mesh, maxInf, debug=0, force=False):
     '''
     Sets max influences on skincluster of mesh / cutting off smallest ones
     '''
     skinClust = self.findRelatedSkinCluster(mesh)
 
     lockedInfluences = self.checkLockedInfluences(skinClust)
     doit = True
     if lockedInfluences:
         if force:
             self.unlockLockedInfluences(skinClust)
             cmds.warning('Locked influences were unlocked on skinCluster')
         else:
             doit = False
     
     if doit:
         verts = self.checkMaxSkinInfluences(mesh, maxInf)
         
         print 'pruneVertWeights>> Pruning', len(verts), 'vertices'
         
         for v in verts:
             infs = cmds.skinPercent(skinClust, (mesh + ".vtx[" + str(v) + "]"), q=1, v=1)
             active = []
             for inf in infs:
                 if inf > 0.0: active.append(inf)
             active = list(reversed(sorted(active)))
             if debug: print 'Clamping vertex', v, 'to', active[maxInf]
             cmds.skinPercent(skinClust, (mesh + ".vtx[" + str(v) + "]"), pruneWeights=(active[maxInf]*1.001))
     else:
         cmds.warning('Cannot clamp influences due to locked weights on skinCluster')
开发者ID:chrisevans3d,项目名称:skinWrangler,代码行数:30,代码来源:skinWrangler.py

示例4: setInfluenceWeightsSlow

def setInfluenceWeightsSlow(skinCluster,influence,weightList,normalize=True,componentList=[]):
	'''
	'''
	# Verify skinCluster
	if not isSkinCluster(skinCluster):
		raise Exception('Invalid skinCluster "' + skinCluster + '" specified!')
	
	# Check influence
	if not mc.objExists(influence):
		raise Exception('Influence object "'+influence+'" does not exists!')
	if not mc.skinCluster(skinCluster,q=True,inf=True).count(influence):
		raise Exception('Influence "'+influence+'" not connected to skinCluster "'+skinCluster+'"!')
	
	# Get geometry
	affectedGeo = glTools.utils.deformer.getAffectedGeometry(skinCluster).keys()[0]
	
	# Check component list
	if not componentList: componentList = glTools.utils.component.getComponentStrList(affectedGeo)
	componentIndexList = glTools.utils.component.getComponentIndexList(componentList)
	componentIndexList = componentIndexList[componentIndexList.keys()[0]]
	
	# Check component and weight list lengths
	if len(componentIndexList) != len(weightList):
		raise Exception('List length mis-match!')
	
	# Set weight values
	for i in range(len(componentIndexList)):
		comp = glTools.utils.component.getComponentStrList(affectedGeo,[componentIndexList[i]])[0]
		mc.skinPercent(skinCluster,comp,tv=(influence,weightList[i]),normalize=normalize)
开发者ID:auqeyjf,项目名称:pubTool,代码行数:29,代码来源:skinCluster.py

示例5: add_skinCluster_weights

def add_skinCluster_weights (vertexIDs, src_mesh, dst_mesh, mask_joint=None):
    src_skin = get_skinCluster(src_mesh)
    dst_skin = get_skinCluster(dst_mesh)
    
    src_skinCls_matrix_dict = loads_skinCluster_matrix(src_mesh)
    dst_skinCls_matrix_dict = loads_skinCluster_matrix(dst_mesh)
    
    cmds.skinCluster(dst_skin, e=True, normalizeWeights=False)
    
    for vertexID in vertexIDs:
        if not mask_joint: #if no mask joint defined, overwrite weight onto dst mesh
            cmds.skinPercent( dst_skin, "%s.vtx[%s]"%(dst_mesh, vertexID), pruneWeights=100)
            maskValue = 1
        else:
            mask_jointIndex = dst_skinCls_matrix_dict[mask_joint]
            maskValue = cmds.getAttr("%s.wl[%s].w[%s]" %(dst_skin, vertexID, mask_jointIndex))
            cmds.setAttr("%s.wl[%s].w[%s]" %(dst_skin, vertexID, mask_jointIndex), 0)
                        
        for src_joint, src_jointIndex in src_skinCls_matrix_dict.iteritems():
            weight = cmds.getAttr("%s.wl[%s].w[%s]" %(src_skin, vertexID, src_jointIndex)) * maskValue
            if weight != 0.0:
                dst_jointIndex = dst_skinCls_matrix_dict[src_joint]
                cmds.setAttr("%s.wl[%s].w[%s]" %(dst_skin, vertexID, dst_jointIndex), weight)

    cmds.skinCluster(dst_skin, e=True, normalizeWeights=True)
开发者ID:adamfok,项目名称:afok_toolset,代码行数:25,代码来源:utils_skinCluster.py

示例6: readDirtyInfInfo

def readDirtyInfInfo(*args):
    sel = cmds.ls(sl=True, fl=True)
    obj = sel[0].split('.')[0]
    shape = cmds.listRelatives(obj, shapes=True)[0]
    skinCluster = mm.eval('findRelatedSkinCluster("' + shape + '")')
    infLst = cmds.skinCluster(skinCluster, query=True, inf=True)
    cmds.setAttr(skinCluster + '.normalizeWeights', 0)

    filePath = os.path.join(os.getenv('HOME'), 'Desktop/tmpWgtExport.txt')
    f = open(filePath, 'r')
    lines = f.readlines()

    cvCnt = 0
    if len(sel) == len(lines):
        for cv in sel:
            wgtLst = cmds.skinPercent(skinCluster, cv, query=True, v=True)
            # set turn off normalization and set all weights to zero
            for i in range(0, len(infLst), 1):
                cmds.skinPercent(skinCluster, cv, tv=(infLst[i], 0))

            rLine = eval(lines[cvCnt])
            for i in range(0, len(rLine), 1):
                cmds.skinPercent(skinCluster, cv, tv=(rLine[i][0], rLine[i][1]))
            f.close()
            cvCnt += 1
        cmds.setAttr(skinCluster + '.normalizeWeights', 1)
    else:
        print 'Maya selection count doesn\'t match exported file component count.'
开发者ID:boochos,项目名称:work,代码行数:28,代码来源:atom_dirty_lib.py

示例7: setInfluenceWeight

def setInfluenceWeight(skn, mesh, influenceName, weightList):
    '''
    Set weights on influence using a float list
    '''
    for vertId in range(len(weightList)):
        if weightList[vertId]:
            mc.skinPercent(skn, mesh+'.vtx[%d]'%vertId, transformValue=[influenceName, weightList[vertId]])
开发者ID:darkuress,项目名称:arFace,代码行数:7,代码来源:copySkinLayers.py

示例8: doIt

    def doIt(self,argList):
        polygons = cmds.filterExpand(sm=12)
        if not polygons:
            print 'Please select a polygon.'
            return

        paths = cmds.fileDialog2(dialogStyle=2, fileMode = 3, okCaption = "Save", cancelCaption = "Cancel")
        if not paths:
            return

        for p in range(0, len(polygons)):
            polygon = polygons[p]
            related_cluster = mel.eval('findRelatedSkinCluster '+polygon)
            if related_cluster == '':
                print 'Please bind skin for this polygon.' + polygon
                continue

            path = paths[0]
            joints = cmds.skinPercent(related_cluster, polygon+'.vtx[0]', q = True, t = None);
            f = open(path+'/'+polygon+'.weights', 'w')

            vertices = cmds.getAttr(polygon+'.vrts', multiIndices = True);
            for i in range(0, len(vertices)):
                infs = cmds.skinPercent(related_cluster, polygon+'.vtx['+str(vertices[i])+']', q = True, v = True)
                pos = cmds.xform(polygon+'.vtx['+str(vertices[i])+']', q=1, ws=1, t=1)
                f.write('vp ' + str(pos[0])+' '+str(pos[1])+' '+str(pos[2]) + '\n')
                f.write('vinf');
                for j in range(0, len(infs)):
                    f.write(' ' + joints[j] + ' ' + str(infs[j]))
                f.write('\n')
            f.close()

        print 'Export Complete.'
开发者ID:teststaybaka,项目名称:Maya_Plugin_SkinMapExporterImporter,代码行数:33,代码来源:skinExporter_Importer_Space.py

示例9: setVertWts

 def setVertWts(self,*args):
     sel = cmds.ls(sl=True,fl=True)
     mesh = sel[0].split('.')[0]
     self.skClstr = mel.eval('findRelatedSkinCluster("%s")'%mesh)        
     for vert in sel:
         for val,inf in zip(self.srcVals,self.infs):
             cmds.skinPercent( self.skClstr, vert, transformValue=[(inf,val)] )
开发者ID:Mauricio3000,项目名称:MSH_Maya,代码行数:7,代码来源:ms_skinTools.py

示例10: weightZero

def weightZero(skinClusterName, deformerName):
    scNormalWeights = skinClusterName + '.normalizeWeights'
    cmds.setAttr(scNormalWeights, 1)
    cmds.skinPercent(skinClusterName, transformValue=[ (deformerName, 1.0)])
    cmds.setAttr(scNormalWeights, 0)
    cmds.skinCluster(skinClusterName, edit = True, fnw = True)
    cmds.skinPercent(skinClusterName, transformValue=[ (deformerName, 0.0)])
开发者ID:tkabelan,项目名称:python_miscellaneous,代码行数:7,代码来源:weightExport_batch_pipelineCode.py

示例11: cache

 def cache(s, meshes=None):
     """
     Store joints influence on objects for quick checking later
     """
     if meshes:
         # Cache Joints and Meshes
         for mesh in meshes:
             skin = mel.eval("findRelatedSkinCluster %s" % mesh)
             if skin:
                 joints = cmds.skinPercent(skin, "%s.vtx[0]" % mesh, q=True, t=None)
                 for vert in range(cmds.getAttr("%s.weightList" % skin, size=True)):
                     for i, v in enumerate(cmds.skinPercent(skin, "%s.vtx[%s]" % (mesh, vert), q=True, v=True)):
                         joint = joints[i]
                         if 0.2 < v:
                             # Sort by joints
                             s.joints[joint] = s.joints.get(joint, [])
                             s.joints[joint].append("%s.vtx[%s]" % (mesh, vert))
                             # Sort by meshes
                             s.meshes[mesh] = s.meshes.get(mesh, {})
                             s.meshes[mesh][joint] = s.meshes[mesh].get(joint, {})
                             s.meshes[mesh][joint][vert] = v
         # Speed up Cache
         if s.joints:
             s.select.ignore = True
             for j in s.joints:
                 cmds.select(s.joints[j], r=True)
                 s.joints[j] = cmds.filterExpand(ex=False, sm=31)
             cmds.select(clear=True)
     else:
         s.meshes = {}
         s.joints = {}
     pass
开发者ID:internetimagery,项目名称:RigTool,代码行数:32,代码来源:__init__.py

示例12: scaleMin

	def scaleMin( self , arg=None ) :
		
		val = self.getScaleVal()
		
		vtcs = mc.ls( sl=True , fl=True )
		
		for vtc in vtcs :
			
			geo = vtc.split( '.' )[0]
			skn = mm.eval( 'findRelatedSkinCluster( "%s" )' % geo )
			
			mc.setAttr( '%s.normalizeWeights' % skn , False )
			
			infs = mc.skinCluster( skn , q=True , inf=True )
			skinVals = mc.skinPercent( skn , vtc , q = True , v = True )
			
			maxVal = sorted( skinVals )[-1]
			
			minVal = 1
			for skinVal in skinVals :
				if skinVal and skinVal < minVal :
					minVal = skinVal
			
			minId = skinVals.index( minVal )
			maxId = skinVals.index( maxVal )
			
			newMin = minVal * val
			newMax = maxVal + ( minVal - newMin )
			
			mc.skinPercent( skn , vtc , tv = ( infs[minId] , newMin ) )
			mc.skinPercent( skn , vtc , tv = ( infs[maxId] , newMax ) )
			
			mc.setAttr( '%s.normalizeWeights' % skn , True )
开发者ID:myCodeTD,项目名称:pkmel,代码行数:33,代码来源:weightScaler.py

示例13: oldSkooFaceRigWeightImport

def oldSkooFaceRigWeightImport(path):

    pickleFile = open(path, 'r')
    Import_Info = pickle.load(pickleFile)
    pickleFile.close()
    sknClstr = Import_Info.skinCluster
    cmds.setAttr(sknClstr + '.normalizeWeights', 0)
    points = cmds.getAttr('faceDriver_Crv.spans')
    # Iterate through each point on the faceDriver_Crv
    for i in range(0, points, 1):
        cv = OldSkooPointInfo('faceDriver_Crv.cv[' + str(i) + ']')
        closestPoint = getMapPnt(Import_Info.influenceInfoDict.keys(), cv)
        if Import_Info.influenceInfoDict.has_key(closestPoint[0]):
            setInfList = Import_Info.influenceInfoDict[closestPoint[0]][0]
            setWgtList = Import_Info.influenceInfoDict[closestPoint[0]][1]

            infLst = cmds.skinPercent(sknClstr, cv.name, ib=1e-4, query=True, transform=None)
            # Set the weights to 0
            for i in infLst:
                cmds.skinPercent(sknClstr, cv.name, tv=[i, 0])

            for i, inf in enumerate(setInfList):
                cmds.skinPercent(sknClstr, cv.name, tv=[inf, setWgtList[i]])
        else:
            print '-- point missed: %s, closest point: %s' % (cv.name, closestPoint[0])
    cmds.setAttr(sknClstr + '.normalizeWeights', 1)
开发者ID:boochos,项目名称:work,代码行数:26,代码来源:atom_olSkoolFix_lib.py

示例14: test_import_skin_sets_correct_data

 def test_import_skin_sets_correct_data(self):
     file_path = self.get_temp_filename('temp.skin')
     skinio.export_skin(file_path, self.shape)
     cmds.skinPercent(self.skin, '{0}.vtx[0]'.format(self.shape),
                      transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)])
     skinio.import_skin(file_path)
     self.test_skincluster_data_is_correct()
开发者ID:SplineO,项目名称:cmt,代码行数:7,代码来源:test_cmt_skinio.py

示例15: setWeightFn

 def setWeightFn(self):
     if self.currentInf:
         if len(self.currentInf) > 1:
             cmds.warning('skinWrangler: Set Weight does not work with multi-selection because I am too lazy at the moment to write my own normalization code.')
         else:
             cmds.skinPercent(self.currentSkin, self.currentVerts, tv=[self.currentInf[0], self.setWeightSpin.value()])
         self.refreshUI()
     else: cmds.warning('[skinWrangler] No influences/joints selected')
开发者ID:chrisevans3d,项目名称:skinWrangler,代码行数:8,代码来源:skinWrangler.py


注:本文中的maya.cmds.skinPercent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。