101 lines
3.4 KiB
Python
101 lines
3.4 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import maya.cmds as cmds
|
|
from scripts.utils.Core import (
|
|
GetMeshes,
|
|
Descriptor,
|
|
ReadJson,
|
|
RBFDeformer,
|
|
ProgressBar
|
|
)
|
|
|
|
def supplement_meshes():
|
|
"""补充和变形各个LOD级别的网格"""
|
|
# 遍历8个LOD级别
|
|
for i in range(8):
|
|
# 获取当前LOD级别的网格列表
|
|
lod_list = GetMeshes(lod=i)
|
|
head = GetMeshes(m=lod_list[0])
|
|
deformed = GetMeshes(m=0)
|
|
|
|
if cmds.objExists(head):
|
|
# 准备源模型
|
|
source = GetMeshes(cm=0)
|
|
source_buffer = f"{source}_buffer"
|
|
source_buffer = source_buffer[1:] # 移除第一个字符
|
|
source_buffer = cmds.rename(source, source_buffer)
|
|
|
|
# 设置进度条标题
|
|
title = f"[LOD{i}] Please be patient and wait..."
|
|
if Descriptor(l=True) == "ZH":
|
|
title = f"[LOD{i}] 请耐心等待..."
|
|
|
|
# 初始化进度条
|
|
ProgressBar(sp=True)
|
|
ProgressBar(t=title)
|
|
|
|
# 初始化网格列表
|
|
eye_mesh = []
|
|
eye = []
|
|
mouth_mesh = []
|
|
|
|
# 读取顶点信息
|
|
json_file = Descriptor(ti="vertexsInfo")
|
|
eye_indices = ReadJson(f=json_file, k="headEye", t="int")
|
|
mouth_indices = ReadJson(f=json_file, k="headMouth", t="int")
|
|
|
|
# 处理每个网格
|
|
for j in range(1, len(lod_list)):
|
|
if lod_list[j] < 50:
|
|
mesh = GetMeshes(m=lod_list[j])
|
|
if not cmds.objExists(mesh):
|
|
new_mesh = GetMeshes(cm=lod_list[j])
|
|
if cmds.objExists(new_mesh):
|
|
# 根据名称分类网格
|
|
if any(x in new_mesh for x in ["eyeshell", "eyelashes", "eyeEdge", "cartilage"]):
|
|
eye_mesh.append(new_mesh)
|
|
elif any(x in new_mesh for x in ["eyeLeft", "eyeRight"]):
|
|
eye.append(new_mesh)
|
|
elif any(x in new_mesh for x in ["teeth", "saliva"]):
|
|
mouth_mesh.append(new_mesh)
|
|
|
|
# 设置进度条
|
|
ProgressBar(max_value=3)
|
|
|
|
# 应用RBF变形器
|
|
ProgressBar(apr=1)
|
|
if eye_mesh:
|
|
RBFDeformer(
|
|
r=0.01,
|
|
rbf=1,
|
|
m=[source_buffer, deformed],
|
|
pi=eye_indices,
|
|
t=eye_mesh
|
|
)
|
|
|
|
ProgressBar(apr=1)
|
|
if eye:
|
|
RBFDeformer(
|
|
r=0.01,
|
|
rbf=1,
|
|
d="off",
|
|
m=[source_buffer, deformed],
|
|
pi=eye_indices,
|
|
t=eye
|
|
)
|
|
|
|
ProgressBar(apr=1)
|
|
if mouth_mesh:
|
|
RBFDeformer(
|
|
r=0.01,
|
|
rbf=1,
|
|
d="off",
|
|
m=[source_buffer, deformed],
|
|
pi=mouth_indices,
|
|
t=mouth_mesh
|
|
)
|
|
|
|
# 清理和结束
|
|
cmds.delete(source_buffer)
|
|
ProgressBar(ep=True) |