47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
"""
|
||
|
版权所有: 清泉时代科技有限公司
|
||
|
联系方式: q.100@qq.com
|
||
|
创建日期: 2023/10/31
|
||
|
"""
|
||
|
|
||
|
import maya.cmds as cmds
|
||
|
import maya.mel as mel
|
||
|
|
||
|
def sg_clothing_weight():
|
||
|
"""
|
||
|
处理服装权重
|
||
|
- 获取选中的对象
|
||
|
- 从头部和身体模型复制蒙皮权重
|
||
|
- 应用到选中的服装模型上
|
||
|
"""
|
||
|
# 获取选中的对象
|
||
|
selection = cmds.ls(selection=True)
|
||
|
|
||
|
# 获取头部和身体模型
|
||
|
head = cmds.SGGetMeshes(m=0)
|
||
|
body = cmds.SGGetMeshes(m=50)
|
||
|
|
||
|
# 清除选择并选择身体和目标模型
|
||
|
cmds.select(clear=True)
|
||
|
cmds.select(body, add=True)
|
||
|
cmds.select(selection, add=True)
|
||
|
|
||
|
# 执行蒙皮复制
|
||
|
mel.eval('SGCopySkin')
|
||
|
|
||
|
# 为每个选中的模型复制头部和身体的权重
|
||
|
for obj in selection:
|
||
|
cmds.select(clear=True)
|
||
|
cmds.select(head, add=True)
|
||
|
cmds.select(body, add=True)
|
||
|
cmds.select(obj, add=True)
|
||
|
|
||
|
# 复制蒙皮权重
|
||
|
cmds.copySkinWeights(
|
||
|
noMirror=True,
|
||
|
surfaceAssociation="closestPoint",
|
||
|
influenceAssociation="closestJoint"
|
||
|
)
|