53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import maya.cmds as cmds
|
|
from scripts.utils.Core import GetMeshes
|
|
|
|
def transfer_maps():
|
|
"""
|
|
传递所有LOD级别网格的材质映射
|
|
"""
|
|
# 处理头部相关网格的LOD级别
|
|
for i in range(1, 8):
|
|
# 获取当前LOD级别的网格索引列表
|
|
mesh_indices = GetMeshes(lod=i)
|
|
|
|
# 处理前9个网格
|
|
for j in range(9):
|
|
mesh = GetMeshes(m=j)
|
|
if cmds.objExists(mesh):
|
|
# 获取网格类型前缀
|
|
mesh_type = mesh.split('_')[0]
|
|
|
|
# 查找相同类型的LOD网格
|
|
for m in mesh_indices:
|
|
lod_mesh = GetMeshes(i=m)
|
|
if lod_mesh.startswith(mesh_type):
|
|
lod = GetMeshes(m=m)
|
|
# 传递材质
|
|
cmds.transferShadingSets(
|
|
mesh,
|
|
lod,
|
|
sampleSpace=0,
|
|
searchMethod=3
|
|
)
|
|
|
|
# 处理身体网格的LOD级别
|
|
body = GetMeshes(m=50)
|
|
if cmds.objExists(body):
|
|
# 处理身体的3个LOD级别
|
|
for i in range(1, 4):
|
|
body_index = 50 + i
|
|
lod = GetMeshes(m=body_index)
|
|
# 传递材质
|
|
cmds.transferShadingSets(
|
|
body,
|
|
lod,
|
|
sampleSpace=0,
|
|
searchMethod=3
|
|
)
|
|
|
|
# 如果直接运行此脚本
|
|
if __name__ == '__main__':
|
|
transfer_maps() |