Created
June 30, 2015 09:17
-
-
Save yamahigashi/635f16a5948ec0389139 to your computer and use it in GitHub Desktop.
check max influence and select these vertex. for Maya
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.mel as mel | |
DEFAULT_MAXIMUM_INFULENCE = 5 | |
############################################################################## | |
#1頂点に影響するジョイントの上限チェックする | |
############################################################################## | |
def check_maximum_influence(max=DEFAULT_MAXIMUM_INFULENCE): | |
res = [] | |
cmds.select(clear=True) | |
skin_clusters = cmds.ls(type="skinCluster") | |
for cluster in skin_clusters: | |
for mesh in cmds.skinCluster(cluster, q=True, geometry=True): | |
res += check_mesh(max, cluster, mesh) | |
print("{0} 頂点のジョイントインフルエンスが上限 {1} を超えています".format( | |
len(res), max)) | |
cmds.select(res) | |
def check_mesh(max, cluster, mesh): | |
vertices = cmds.polyListComponentConversion(mesh, toVertex=True) | |
vertices = cmds.filterExpand(vertices, selectionMask=31) # polygon vertex | |
res = [] | |
for vert in vertices: | |
joints = cmds.skinPercent( | |
cluster, vert, query=True, ignoreBelow=0.000001, transform=None) | |
if len(joints) > max: | |
res.append(vert) | |
return res | |
check_maximum_influence() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment