2025-02-06 04:46:41 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#===================================== 1. Module Imports =====================================
|
|
|
|
import maya.cmds as cmds
|
|
|
|
import maya.mel as mel
|
|
|
|
import sys
|
2025-02-06 04:00:17 +08:00
|
|
|
import os
|
|
|
|
|
2025-02-06 04:46:41 +08:00
|
|
|
from scripts.ui.widgets import (BaseWidget, LODGroup, IconButton, SearchLineEdit)
|
|
|
|
|
|
|
|
try:
|
|
|
|
from PySide2 import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken2 import wrapInstance
|
|
|
|
print("从PySide2加载Qt和shiboken2")
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken6 import wrapInstance
|
|
|
|
print("从PySide6加载Qt和shiboken6")
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
from PySide import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken import wrapInstance
|
|
|
|
print("从PySide加载Qt和shiboken")
|
|
|
|
except ImportError as e:
|
|
|
|
print(f"Qt加载失败: {str(e)}")
|
|
|
|
QtCore = QtGui = QtWidgets = None
|
|
|
|
wrapInstance = None
|
|
|
|
|
|
|
|
#===================================== 2. Model Tab Class =====================================
|
2025-02-06 04:00:17 +08:00
|
|
|
class ModelTab(BaseWidget):
|
|
|
|
"""模型标签页"""
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(ModelTab, self).__init__(parent)
|
|
|
|
|
|
|
|
def setup_ui(self):
|
|
|
|
layout = QtWidgets.QVBoxLayout(self)
|
|
|
|
|
|
|
|
# 创建滚动区域
|
|
|
|
scroll = QtWidgets.QScrollArea()
|
|
|
|
scroll.setWidgetResizable(True)
|
|
|
|
scroll.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
|
|
|
|
layout.addWidget(scroll)
|
|
|
|
|
|
|
|
# 创建内容控件
|
|
|
|
content = QtWidgets.QWidget()
|
|
|
|
content_layout = QtWidgets.QVBoxLayout(content)
|
|
|
|
scroll.setWidget(content)
|
|
|
|
|
|
|
|
# 添加LOD组
|
|
|
|
for i in range(8):
|
|
|
|
lod_group = LODGroup(i)
|
|
|
|
content_layout.addWidget(lod_group)
|
|
|
|
|
|
|
|
# 添加LOD功能组
|
|
|
|
lod_tools = self.create_lod_tools()
|
|
|
|
content_layout.addWidget(lod_tools)
|
|
|
|
|
|
|
|
# 添加模型工具组
|
|
|
|
model_tools = self.create_model_tools()
|
|
|
|
content_layout.addWidget(model_tools)
|
|
|
|
|
|
|
|
content_layout.addStretch()
|
|
|
|
|
|
|
|
def create_lod_tools(self):
|
|
|
|
"""创建LOD功能组"""
|
|
|
|
group = QtWidgets.QGroupBox("LOD功能")
|
|
|
|
layout = QtWidgets.QHBoxLayout(group)
|
|
|
|
|
|
|
|
# 自定加载模型
|
|
|
|
load_btn = IconButton("load_meshes.png", "自定加载模型")
|
|
|
|
load_btn.clicked.connect(self.load_custom_models)
|
|
|
|
layout.addWidget(load_btn)
|
|
|
|
|
|
|
|
# 标准化命名
|
|
|
|
name_btn = IconButton("standardized_naming.png", "标准化命名")
|
|
|
|
name_btn.clicked.connect(self.standardize_naming)
|
|
|
|
layout.addWidget(name_btn)
|
|
|
|
|
|
|
|
# 自动分组
|
|
|
|
group_btn = IconButton("automatic_grouping.png", "自动分组")
|
|
|
|
group_btn.clicked.connect(self.auto_group)
|
|
|
|
layout.addWidget(group_btn)
|
|
|
|
|
|
|
|
layout.addStretch()
|
|
|
|
return group
|
|
|
|
|
|
|
|
def create_model_tools(self):
|
|
|
|
"""创建模型工具组"""
|
|
|
|
group = QtWidgets.QGroupBox("模型工具")
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
# 拓扑和LOD选择
|
|
|
|
options = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
# 拓扑结构选择
|
|
|
|
options.addWidget(QtWidgets.QLabel("拓扑结构:"))
|
|
|
|
topo_combo = QtWidgets.QComboBox()
|
|
|
|
topo_combo.addItem("MetaHuman")
|
|
|
|
options.addWidget(topo_combo)
|
|
|
|
|
|
|
|
# LOD选择
|
|
|
|
options.addWidget(QtWidgets.QLabel("选择LOD:"))
|
|
|
|
lod_combo = QtWidgets.QComboBox()
|
|
|
|
lod_combo.addItem("全部")
|
|
|
|
for i in range(8):
|
|
|
|
lod_combo.addItem(f"LOD{i}")
|
|
|
|
options.addWidget(lod_combo)
|
|
|
|
|
|
|
|
options.addStretch()
|
|
|
|
layout.addLayout(options)
|
|
|
|
|
|
|
|
# 工具按钮
|
|
|
|
tools = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
tool_buttons = [
|
|
|
|
("模型分离", "polySplitVertex.png", self.split_model),
|
|
|
|
("生成面部配件", "supplement_meshes.png", self.generate_facial_accessories),
|
|
|
|
("修复法线", "repair_normals.png", self.fix_normals),
|
|
|
|
("修复点序", "repair_vertex_order.png", self.fix_vertex_order),
|
|
|
|
("修复接缝", "polyChipOff.png", self.fix_seams)
|
|
|
|
]
|
|
|
|
|
|
|
|
for text, icon, callback in tool_buttons:
|
|
|
|
btn = IconButton(icon, text)
|
|
|
|
btn.clicked.connect(callback)
|
|
|
|
tools.addWidget(btn)
|
|
|
|
|
|
|
|
tools.addStretch()
|
|
|
|
layout.addLayout(tools)
|
|
|
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
# LOD功能回调
|
|
|
|
def load_custom_models(self):
|
|
|
|
"""自定加载模型"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.load_custom_models()
|
|
|
|
|
|
|
|
def standardize_naming(self):
|
|
|
|
"""标准化命名"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.standardize_naming()
|
|
|
|
|
|
|
|
def auto_group(self):
|
|
|
|
"""自动分组"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.auto_group()
|
|
|
|
|
|
|
|
# 模型工具回调
|
|
|
|
def split_model(self):
|
|
|
|
"""分离模型"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.split_model()
|
|
|
|
|
|
|
|
def generate_facial_accessories(self):
|
|
|
|
"""生成面部配件"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.generate_facial_accessories()
|
|
|
|
|
|
|
|
def fix_normals(self):
|
|
|
|
"""修复法线"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.fix_normals()
|
|
|
|
|
|
|
|
def fix_vertex_order(self):
|
|
|
|
"""修复点序"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.fix_vertex_order()
|
|
|
|
|
|
|
|
def fix_seams(self):
|
|
|
|
"""修复接缝"""
|
|
|
|
from scripts.utils import model_utils
|
|
|
|
model_utils.fix_seams()
|