我想将皮肤权重从一个骨骼转移到另一个骨骼。谁能告诉我我怎么会这样做?
此代码假设您一次只选择两个骨骼
import pymel.core as pm
oldjnt = pm.ls("*_oldJnt", sl=True, type='joint')[0]
newjnt = pm.ls("*_newJnt", sl=True, type='joint')[0]
pm.skinCluster( "skinCluster1", e=True, selectInfluenceVerts=oldjnt,)
pm.skinPercent(tmw=oldjnt, tmw=newjnt, "skinCluster1")
我不确定如何让 transformMoveWeights (tmw) 像在 Mel 中那样从一个骨骼应用到另一个骨骼。
这是梅尔代码:
skinCluster -e -selectInfluenceVerts Jnt_oldJnt skinCluster1;
skinPercent -tmw Jnt_oldJnt -tmw Jnt_newJnt skinCluster1;
看起来您几乎拥有它,但该命令只是一些语法错误。我知道你的代码只是试图从一个关节转移,但这个例子将遍历所有匹配正确命名的关节。只要 oldJnt 名称与 newJnt 正确匹配,它就应该从正确的名称转移权重:
import maya.cmds as cmds
# Select all vertexes from your mesh.
cmds.select("pSphere1.vtx[*]")
# We use sorted so that if the objects are names properly, the order of the objects should match indexes.
old_objs = sorted(cmds.ls("*_oldJnt")) # Get a list of all of your old joints.
new_objs = sorted(cmds.ls("*_newJnt")) # Get a list of all of your new joints.
# Use zip to loop through both old and new joints.
for old_jnt, new_jnt in zip(old_objs, new_objs):
cmds.skinPercent("skinCluster1", tmw=[old_jnt, new_jnt]) # Transfer weights from the old joint to the new one.
# Clear vertex selection.
cmds.select(clear=True)
我在cmds
这里使用,但pymel
如果您愿意,您也可以将其切换到。
文档提到它只会从选定的顶点传输权重,所以在这个例子中我只是选择所有的顶点。
这已经用一个球体和 2 个旧关节到 2 个新关节进行了测试。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句