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


Python cmds.skinCluster函数代码示例

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


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

示例1: reset

def reset(geometry):
	'''
	Reset the skin cluster attached to the specified object
	@param geometry: Object whose attached skinCluster will be reset
	@type geometry: str
	'''
	# Delete bind pose nodes
	deleteBindPose()
	
	# Determine skinCluster
	skinCluster = findRelatedSkinCluster(geometry)
	
	# Detach skinCluster
	mc.skinCluster(geometry,e=True,ubk=True)
	
	# Get influence list
	influenceList = mc.skinCluster(skinCluster,q=True,inf=True)
	
	# Get MaxInfluence settings
	maxInfluences = mc.getAttr(skinCluster+'.maxInfluences')
	useMaxInfluences = mc.getAttr(skinCluster+'.maintainMaxInfluences')
	
	# Rebuild skinCluster
	skinCluster = mc.skinCluster(geometry,influenceList,dr=4,mi=maxInfluences,omi=useMaxInfluences,tsb=True)
	
	# Delete bind pose nodes
	deleteBindPose()
	
	# Return skinCluster
	return skinCluster
开发者ID:auqeyjf,项目名称:pubTool,代码行数:30,代码来源:skinCluster.py

示例2: bind_mesh

def bind_mesh():
    # メッセージ
    cmds.inViewMessage(
        amg="ウエイト調整後、<hl>「アニメーションをインポート」</hl>を押し、animデータを選択して下さい。", pos="midCenter", fade=True, fit=1, fst=4000, fts=20
    )

    cmds.select("Root_M", add=True, hi=True)

    # 正規表現、_controllerのジョイントを省く
    deselectObj = cmds.ls(sl=True)

    count = 0
    matchTxtEnd = re.compile("(_)(.*?)(controller)(.*)")

    for n in deselectObj:
        matchTrueEnd = matchTxtEnd.search(deselectObj[count])

        if matchTrueEnd != None:
            cmds.select(deselectObj[count], deselect=True)

        count += 1

    cmds.select("Mesh", add=True, hi=True)
    cmds.select("Mesh", deselect=True)

    cmds.skinCluster(maximumInfluences=3, dropoffRate=4, tsb=True)
开发者ID:akkey,项目名称:maya,代码行数:26,代码来源:LightSkeleton.py

示例3: joint

 def joint(self):
     """
     Getting vertax info and saves weights into txt file
     """
     
     # Getting selected name of mesh and vertex
     #self.name_mesh = cmds.ls(sl=True)  
     #self.name_vertex = cmds.ls(sl=True)
     #self.name_vertex = cmds.ls(self.name_mesh + '.vtx[*]')
     
     # Getting number and name of vertex 
     try :
         splited_vertex = string.split(self.name_vertex[0], ':')
         self.number_of_vertex = int(splited_vertex[-1][0:-1]) + 1
         self.name_splited_vertex = string.split(self.name_vertex[0], '[')               
 
     # Check if vertex is selected
     except :
         print "please select vertex"
         
     # Getting joint from skinned mesh
     try :
         self.name_skincluster = cmds.skinCluster(self.name_mesh, q=True, dt=True)
         self.name_skincluster = self.name_skincluster[-1][0:-7]
         self.name_joint = cmds.skinCluster(self.name_mesh, q=True, inf=True)
         return self.name_joint                 
 
     # Check if proper mesh is selected
     except :
         print "please select skinned mesh"
开发者ID:darkuress,项目名称:arFace,代码行数:30,代码来源:copyWeight.py

示例4: create_ik_setup

    def create_ik_setup(self):
        """Creates the IK setup."""
        ik = cmds.ikHandle(sj=self.result_jnts[0], ee=self.result_jnts[-1], sol='ikSplineSolver', ns=1)
        cmds.rename(ik[1], '%s_%s_%s' % (self.side, 'neck', self.nc.effector))
        curve = cmds.rename(ik[2], '%s_%s_%s' % (self.side, 'neck', self.nc.curve))
        cmds.setAttr('%s.inheritsTransform' % curve, 0)
        ik = cmds.rename(ik[0], '%s_%s_%s' % (self.side, 'neck', self.nc.ikhandle))
        cmds.select(self.additional_jnts, curve)
        cmds.skinCluster(tsb=True)
        cmds.parent(ik, self.top_grp)

        cmds.setAttr('%s.dTwistControlEnable' % ik, 1)
        cmds.setAttr('%s.dWorldUpType' % ik, 4)
        cmds.setAttr('%s.dWorldUpAxis' % ik, 4)
        cmds.setAttr('%s.dWorldUpVectorY' % ik, -1)
        cmds.setAttr('%s.dWorldUpVectorEndY' % ik, 1)
        cmds.setAttr('%s.dWorldUpVectorEndZ' % ik, -1)
        cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[0], '%s.dWorldUpMatrix' % ik, f=True)
        cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[1], '%s.dWorldUpMatrixEnd' % ik, f=True)
        self.head_grp = cmds.group(self.controls['head'])
        self.head_grp = cmds.rename(self.head_grp, '%s_head_CTL_%s' % (self.side, self.nc.group))
        cmds.parent(self.head_grp, self.top_grp)
        self.c.move_pivot_to(self.guides['neckEnd'][0], self.guides['neckEnd'][1], self.guides['neckEnd'][2], self.head_grp)
        cmds.parentConstraint(self.controls['head'], self.additional_jnts[-1], mo=True, weight=1)
        cmds.orientConstraint(self.controls['head_rot'], self.result_jnts[-1], mo=True, weight=1)
开发者ID:jonntd,项目名称:Rigganator,代码行数:25,代码来源:dragonneck.py

示例5: bindCurve

def bindCurve(crv=None):
    '''
    Creates a joint for each cv in the supplied or selected curve
    performs a smooth bind on the curve to the joints
    returns a list of the newly created joints
    
    '''
    # Validation of args
    if not crv:
        if len(cmds.ls(sl=1)) == 1:
            crv = cmds.ls(sl=1)[0]
        else:
            return common.showDialog( 'Argument Error', 'Please supply or select a nurbs curve' )
        
    jointList = []
        
    cvs = cmds.getAttr("%s.cv[*]" % crv)
    
    for cv in range(len(cvs)):
        cmds.select(clear=1)
        j = cmds.joint(p=cvs[cv], name='%s_%s_jnt' %(crv, cv+1))
        jointList.append(j)
        
    cmds.skinCluster(jointList, crv, tsb=1, name='%s_skinCluster' % crv)
    
    return jointList
开发者ID:duncanrudd,项目名称:rooftops,代码行数:26,代码来源:curve.py

示例6: copy_bind_from_ng_file

def copy_bind_from_ng_file(file):
    """ Copies skinCluster from ngSkinTools JSON file to make the same skinCluster before importing weights.
    Args:
        file (str): file...
    Returns [str]: list of joints that we used
    Usage:
        a=copy_bind_from_ng_file('/mpc/mayors1/scanaEnergyBears_5600278/build/char_linda_blackbear/maya/scenes/rig/andres-w/build/scripts/char_harry_blackbear_body_lodA_weights.json')
    """
    influences = []
    missing_influences = []
    with open(file) as f:
        data = f.read()
        json_data = json.loads(data)
        f.close()
        for value in json_data['influences']:
            influence = json_data['influences'][value]['path'].split('|')[-1]
            if mc.objExists(influence):
                influences.append(influence)
            else:
                missing_influences.append(influence)
                
        print 'Missing Influences from your file:'
        print missing_influences
        
        result = cmds.confirmDialog(b=['OK','CANCEL'], m='You have %d missing influences...continue adding skin cluster from file?' % (len(missing_influences)))
        if result == 'OK':
            mc.skinCluster(influences, mc.ls(sl=True)[0], tsb=True)
    return influences
开发者ID:AndresMWeber,项目名称:aw,代码行数:28,代码来源:aw_ngSkinTools.py

示例7: 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

示例8: skin_dragon

    def skin_dragon(self):
        """@todo: insert doc for skin_dragon"""
        cmds.setAttr('L_foot_CTL.tx', 3.061)
        cmds.setAttr('R_foot_CTL.tx', -3.061)

        data = 'C:/PROJECTS/GOT_Dragon/data/'

        done = list()
        for weight in os.listdir(data):
            cmds.select(clear=True)
            if weight in done:
                continue
            name = weight.split('_weights')[0]
            if not cmds.objExists('Drache:%s' % name):
                continue
            weight = self.get_latest_version(weight, data)
            self.select_result_jnts(name)
            cmds.select('Drache:%s' % name, add=True)
            skin = cmds.skinCluster(tsb=True, sm=True)[0]
            cmds.deformerWeights(weight, im=True, method='index', deformer=skin, path=data)
            cmds.skinCluster(skin, e=True, forceNormalizeWeights=True)
            cmds.select('Drache:%s' % name)
            done.append(weight)
            #mel.eval('removeUnusedInfluences;')
        # end for weight in os.listdir(data)

        cmds.setAttr('L_foot_CTL.tx', 0)
        cmds.setAttr('R_foot_CTL.tx', 0)
开发者ID:jonntd,项目名称:Rigganator,代码行数:28,代码来源:dragon.py

示例9: copy

def copy():

    skin_cluster = None
    mesh_name = None
    selection = cmds.ls(sl=True)
    if selection:
        mesh_name = selection[0]
        shape = cmds.listRelatives(selection[0])
        skin_clusters = cmds.listConnections(shape[0], type='skinCluster')
        if skin_clusters:
            skin_cluster = skin_clusters[0]
        else:
            cmds.error('No skin cluster present')
    else:
        cmds.error('No valid selection')

    bones = cmds.skinCluster(skin_cluster, q=True, inf=True)
    num_verts = cmds.polyEvaluate(mesh_name, v=True)
    data = dict()

    for bone in bones:
        data[bone] = []
        for id in range(num_verts):

            data[bone].append(cmds.skinPercent(skin_cluster, '{0}.vtx[{1}]'.format(mesh_name, id), q=True, t=bone))

    pickled_list = pickle.dumps(data)
    cmds.scrollField('jt_copy_skin_values_field', e=True, tx=pickled_list)
    cmds.skinCluster(mesh_name, e=True, ub=True)
开发者ID:MaxIsJames,项目名称:jt_tools,代码行数:29,代码来源:jt_copy_skin.py

示例10: build

def build(numBindJoints=6, numSpans=None, name='', numSkinJoints=3, width=None):
    '''
    builds a nurbs ribbon
    If width is not specified, width will be set to numBindJoints
    If numSpans is not specified, it will be set to numBindJoints
    
    '''
    if not width:
        width = numBindJoints
    if not numSpans:
        numSpans = numBindJoints
    
    main_grp = cmds.group(empty=1, name=(name + '_grp'))
    plane = cmds.nurbsPlane(axis=(0, 1, 0), ch=0, lengthRatio=(1.0 / width), w=width, u=numSpans, name=(name + '_nurbsPlane'))[0]
    cmds.parent(plane, main_grp)
    
    # Creat Skin joints
    skinJoints = []
    skinJointPositions = common.pointsAlongVector( start=[width*.5, 0, 0], end=[width*-.5, 0, 0], divisions=(numSkinJoints-1) )
    for index in range(len(skinJointPositions)):
        cmds.select(main_grp)
        j = cmds.joint(position = skinJointPositions[index], name=(name + '_' + str(index) + '_jnt'))
        skinJoints.append(j)
        
    # Add skinning to ribbon
    cmds.skinCluster(skinJoints, plane, tsb=1, name=(plane + '_skinCluster'))
    cmds.setAttr(plane+'.inheritsTransform', 0)
    
    # Add follicles
    for index in range(numBindJoints):
        f = rivet.build( mesh=plane, paramU=(1.0 / (numBindJoints-1) * index), paramV=0.5, name=(name + '_' + str(index)))
        cmds.parent(f, main_grp)
        j = cmds.joint(name=(name + '_' + str(index) + '_bnd'))
开发者ID:duncanrudd,项目名称:rooftops,代码行数:33,代码来源:ribbon.py

示例11: copyWeight

def copyWeight( first, second ):
    
    hists = cmds.listHistory( first, pdo=1 )
    
    skinNode = None
    for hist in hists:
        
        if cmds.nodeType( hist ) == 'skinCluster':
            skinNode = hist
            
    if not skinNode: return None
    
    targetSkinNode = None
    targetHists = cmds.listHistory( second, pdo=1 )
    if targetHists:
        for hist in targetHists:
            if cmds.nodeType( hist ) == 'skinCluster':
                targetSkinNode = hist

    if not targetSkinNode:
        bindObjs = cmds.listConnections( skinNode+'.matrix', s=1, d=0, type='joint' )
        bindObjs.append( second )
        print bindObjs
        cmds.skinCluster( bindObjs, tsb=1 )
    
    cmds.copySkinWeights( first, second, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation ='oneToOne' )
开发者ID:jonntd,项目名称:mayadev-1,代码行数:26,代码来源:cmdModel.py

示例12: 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

示例13: rigFace

def rigFace() : 
    jntGrp = 'facialJnt_grp'

    if not mc.objExists(jntGrp) : 
        mc.group(em = True, n = jntGrp)

    facePolyMap = {'L_brow_ply': 'L_brow_ctrl',
                     'L_baseEye_ply': 'L_baseEye_ctrl', 
                     'L_eye_ply': 'L_eye_ctrl',
                     'R_brow_ply': 'R_brow_ctrl', 
                     'R_baseEye_ply': 'R_baseEye_ctrl', 
                     'R_eye_ply': 'R_eye_ctrl', 
                     'nose_ply': 'noseface_ctrl', 
                     'mouth_ply': 'mount_ctrl'
                     }

    for each in facePolyMap : 
        poly = each
        ctrl = facePolyMap[poly]

        if mc.objExists(poly) : 

            movePivot(ctrl, poly)

            joint = mc.createNode('joint', n = poly.replace('_ply', '_jnt'))
            mc.delete(mc.pointConstraint(poly, joint))
            mc.skinCluster(poly, joint, tsb = True)
            mc.parentConstraint(ctrl, joint)
            mc.scaleConstraint(ctrl, joint)

            mc.parent(joint, jntGrp)
开发者ID:myCodeTD,项目名称:rigTools,代码行数:31,代码来源:gen2DRig+(tanimator's+conflicted+copy+2014-11-28).py

示例14: mirrorSkin

def mirrorSkin(skinCluster,search='L_',replace='R_'):
	'''
	Create a mirrored skinCluster based on the influence list and weights of another specified skinCluster
	@param skinCluster: The existing skinCluster to mirror
	@type skinCluster: str
	@param search: Name prefix of the source skinCluster
	@type search: str
	@param replace: Name prefix of the destination skinCluster geometry/influences
	@type replace: str
	'''
	# Check skinCluster
	if not isSkinCluster(skinCluster):
		raise Exception('Object "'+skinCluster+'" is not a valid skinCluster!')
	
	# Get affected object
	sourceGeo = glTools.utils.deformer.getAffectedGeometry(skinCluster).keys()[0]
	if not sourceGeo.startswith(search):
		raise Exception('Search string "'+search+'" not found in source geometry name!')
	destGeo = sourceGeo.replace(search,replace)
	if not mc.objExists(destGeo):
		raise Exception('Destination geometry "'+destGeo+'" does not exist!')
	
	# Get influence list
	influenceList = mc.skinCluster(skinCluster,q=True,inf=True)
	
	# Check destination skinCluster
	mSkinCluster = skinCluster.replace(search,replace)
	destSkinCluster = findRelatedSkinCluster(destGeo)
	if destSkinCluster and destSkinCluster != mSkinCluster:
		mc.rename(destSkinCluster,mSkinCluster)
	
	# Check influenceList
	mInfluenceList = [inf.replace(search,replace) for inf in influenceList]
	for mInf in mInfluenceList:
		if not mc.objExists(mInf):
			raise Exception('Mirror influence "'+mInf+'" does not exist!!')
	
	# Check mirror skinCluster
	if not mc.objExists(mSkinCluster):
		# Create skinCluster
		mSkinCluster = mc.skinCluster(mInfluenceList,destGeo,tsb=True,n=mSkinCluster)[0]
	else:
		# Add influence
		destInfluenceList = mc.skinCluster(mSkinCluster,q=True,inf=True)
		for mInf in mInfluenceList:
			if not destInfluenceList.count(mInf):
				mc.skinCluster(mSkinCluster,e=True,ai=mInf)
	
	# Get Mirror Weights
	mirroWeightList = {}
	for inf in influenceList:
		mirroWeightList[inf] = getInfluenceWeights(skinCluster,inf)
	
	# Clear mirrorSkin weights
	clearWeights(destGeo)
	
	# Apply mirror weights
	for i in range(len(influenceList)):
		setInfluenceWeights(mSkinCluster,mInfluenceList[i],mirroWeightList[influenceList[i]])
开发者ID:auqeyjf,项目名称:pubTool,代码行数:59,代码来源:skinCluster.py

示例15: applyRigidSkin

def applyRigidSkin():
    """"""
    sel = cmds.ls(sl=1, ap=1)
    if len(sel) < 2:
        om.MGlobal.displayError("Please select joints first, then mesh.")
        return
    mesh = sel.pop()
    cmds.skinCluster(sel, mesh, tsb=1, mi=0, nw=1, bm=1)
开发者ID:00christian00,项目名称:DeformationLearningSolver,代码行数:8,代码来源:miscFunc.py


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