49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
|
"""
|
||
|
版权所有: 深圳时光科技有限公司
|
||
|
联系方式: q.100@qq.com
|
||
|
创建日期: 2023/08/08
|
||
|
"""
|
||
|
|
||
|
import maya.cmds as cmds
|
||
|
|
||
|
def sg_reset_target(target_ids, blend_shape):
|
||
|
"""
|
||
|
重置混合变形目标的点位置
|
||
|
Args:
|
||
|
target_ids (list): 目标索引列表
|
||
|
blend_shape (str): 混合变形器名称
|
||
|
"""
|
||
|
# 清除选择
|
||
|
cmds.select(clear=True)
|
||
|
|
||
|
# 处理每个目标
|
||
|
for target_id in target_ids:
|
||
|
# 重新生成目标
|
||
|
target = cmds.sculptTarget(
|
||
|
blend_shape,
|
||
|
edit=True,
|
||
|
regenerate=True,
|
||
|
target=target_id
|
||
|
)[0]
|
||
|
|
||
|
# 获取形状节点
|
||
|
shape = cmds.listRelatives(target, shapes=True)[0]
|
||
|
|
||
|
# 获取顶点数量
|
||
|
vertex_count = cmds.polyEvaluate(target, vertex=True)
|
||
|
|
||
|
# 重置所有点的位置为原点
|
||
|
for i in range(vertex_count):
|
||
|
cmds.setAttr(f"{shape}.pnts[{i}].pntx", 0)
|
||
|
cmds.setAttr(f"{shape}.pnts[{i}].pnty", 0)
|
||
|
cmds.setAttr(f"{shape}.pnts[{i}].pntz", 0)
|
||
|
|
||
|
# 删除临时目标
|
||
|
cmds.delete(target)
|
||
|
|
||
|
# 如果直接运行此脚本
|
||
|
if __name__ == '__main__':
|
||
|
pass
|