本文整理汇总了Python中maya.cmds.skinPercent方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.skinPercent方法的具体用法?Python cmds.skinPercent怎么用?Python cmds.skinPercent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.skinPercent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_skin_on_selected_subset
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def test_import_skin_on_selected_subset(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)],
)
cmds.skinPercent(
self.skin,
"{0}.vtx[1]".format(self.shape),
transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)],
)
cmds.select("{}.vtx[1]".format(self.shape))
skinio.import_skin(file_path, to_selected_shapes=True)
skin = skinio.SkinCluster(self.skin)
data = skin.gather_data()
w1 = [0.1, 0.5, 0.5, 0.0, 0.5, 0.0, 0.9, 0.5]
w2 = [0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.1, 0.5]
w3 = [0.7, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0]
self.assertListAlmostEqual(w1, data["weights"]["joint1"])
self.assertListAlmostEqual(w2, data["weights"]["joint2"])
self.assertListAlmostEqual(w3, data["weights"]["joint3"])
示例2: setWeights
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def setWeights(self, data):
"""
Set the weights on the Maya vertex.
:param list data: List of list with influences and weights data
"""
cmds.skinPercent(self.skinCluster, self.vertex, transformValue=data)
# ----------------------------------------------------------------------------
示例3: dm2skin_getLargestInfluenceOnVert
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def dm2skin_getLargestInfluenceOnVert(vertex, skinCluster=None):
"""Given a vertex returns the largest influence in the provided
skin cluster that acts upon it."""
if not skinCluster:
return False
vertInfs = cmds.skinCluster(skinCluster, q=True, inf=True)
vertVals = cmds.skinPercent(skinCluster, vertex, q=True, value=True)
return vertInfs[vertVals.index(max(vertVals))]
示例4: test_import_skin_sets_correct_data
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
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()
示例5: softSelectionSkinWeights
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def softSelectionSkinWeights(*args):
model = mc.ls(sl=True, o=True)
joints = mc.ls(model, type='joint')
mc.select(joints, deselect=True)
weights = getSoftSelectionWeights()
if not model or not joints or not weights:
raise RuntimeError('Select vertices followed by a joint')
if len(joints) > 1:
raise RuntimeError('Only one joint can be selected at a time')
joint = joints[0]
skin = utl.getSkinCluster(model[0])
if not skin:
raise RuntimeError('Mesh must have an existing skinCluster')
influences = mc.skinCluster(skin, query=True, influence=True)
if joint not in influences:
mc.skinCluster(skin, edit=True, addInfluence=joint, lockWeights=False, weight=0)
for influence in influences:
mc.skinCluster(skin, edit=True, influence=influence, lockWeights=False)
for vertex, weight in weights.items():
mc.skinPercent(skin, vertex, transformValue=(joint, weight))
mc.select(joint)
# ______________________
# - -/__ Revision History __/- - - - - - - - - - - - - - - - - - - - - - - -
#
# Revision 1: 2016-12-31 : Initial publish
#
# Revision 2: 2018-02-17 : Updating license to MIT.
示例6: __init__
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def __init__(self, parent, vertex):
Qt.QWidget.__init__(self, parent)
# variables
self.vertex = vertex
self.mesh, _ = vertex.split(".", 1)
self.skinCluster = skin.getSkinCluster(self.mesh)
# get skinned data
influences = cmds.skinPercent(
self.skinCluster, vertex, query=True, transform=None
)
values = cmds.skinPercent(
self.skinCluster, vertex, query=True, value=True
)
# order data
data = zip(values, influences)
data.sort()
data.reverse()
# create layout
layout = Qt.QVBoxLayout(self)
layout.setContentsMargins(3, 3, 3, 3)
layout.setSpacing(3)
# create divider
divider = widgets.Divider(self)
layout.addWidget(divider)
# create label
self.label = VertexLabelWidget(self, vertex)
layout.addWidget(self.label)
# create divider
divider = widgets.Divider(self)
layout.addWidget(divider)
# create frame
self.frame = VertexInfluencesWidget(self, self.skinCluster, data)
self.frame.signal.connect(self.setWeights)
layout.addWidget(self.frame)
# connect influences toggle
self.label.signal.connect(self.frame.displayInfluences)
self.frame.warningSignal.connect(self.label.displayWarning)
# force display
self.frame.displayMaxInfluences()
# ------------------------------------------------------------------------
示例7: LOD_transferWeights
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinPercent [as 别名]
def LOD_transferWeights(meshes, jointsToRemove, jointToTransferTo, debug=1, pruneWeights=0.001, *args):
'''
Original function by Charles Anderson @ Epic Games
'''
for mesh in meshes:
# Find the skin cluster for the current mesh
cluster = findCluster(mesh)
if debug:
print "MESH: ", mesh
print "CLUSTER: ", cluster
# Prune weights on the current mesh
if pruneWeights:
cmds.skinPercent(cluster, mesh, prw=pruneWeights)
# Find all of the current influences on the current skin cluster.
meshInfluences = cmds.skinCluster(cluster, q=True, inf=True)
#print "Current Influences: ", meshInfluences
for joint in jointsToRemove:
if joint in meshInfluences:
#print "Current Joint: ", joint
# If the jointToTransferTo is not already an influence on the current mesh then add it.
currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
if jointToTransferTo not in currentInfluences:
cmds.skinCluster(cluster, e=True, wt=0, ai=jointToTransferTo)
# Now transfer all of the influences we want to remove onto the jointToTransferTo.
for x in range(cmds.polyEvaluate(mesh, v=True)):
#print "TRANSFERRING DATA....."
value = cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), t=joint, q=True)
if value > 0:
cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), tmw=[joint, jointToTransferTo])
# Remove unused influences
currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
#print "Current Influences: ", currentInfluences
influencesToRemove = []
weightedInfs = cmds.skinCluster(cluster, q=True, weightedInfluence=True)
#print "Weighted Influences: ", weightedInfs
for inf in currentInfluences:
#print "Influence: ", inf
if inf not in weightedInfs:
#print "Update Influences to Remove List: ", inf
influencesToRemove.append(inf)
#print "ToRemove Influences: ", influencesToRemove
if influencesToRemove != []:
for inf in influencesToRemove:
cmds.skinCluster(cluster, e=True, ri=inf)
## UI RELATED
########################################################################
#event filter to grab and discern right/left click