2025-02-09 22:11:50 +08:00
|
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
#===================================== 1. Module Imports =====================================
|
|
|
|
|
import maya.OpenMayaUI as omui
|
|
|
|
|
from scripts import config
|
|
|
|
|
import maya.cmds as cmds
|
|
|
|
|
import maya.mel as mel
|
|
|
|
|
import webbrowser
|
|
|
|
|
import sys
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
from scripts import config
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
class MeshesTab(QtWidgets.QWidget):
|
2025-02-09 23:22:48 +08:00
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super(MeshesTab, self).__init__(parent)
|
|
|
|
|
self._setup_ui()
|
|
|
|
|
self._create_connections()
|
|
|
|
|
|
|
|
|
|
def _setup_ui(self):
|
|
|
|
|
"""设置UI布局"""
|
|
|
|
|
# === Main Layout ===
|
|
|
|
|
self.main_layout = QtWidgets.QVBoxLayout(self)
|
|
|
|
|
self.main_layout.setContentsMargins(2, 2, 2, 2)
|
|
|
|
|
self.main_layout.setSpacing(2)
|
|
|
|
|
|
|
|
|
|
# 创建各个部件
|
|
|
|
|
self.toolbar_widget = self._create_toolbar()
|
|
|
|
|
self.lod_tab_widget = self._create_lod_tabs()
|
|
|
|
|
self.bottom_toolbar_widget = self._create_bottom_toolbar()
|
|
|
|
|
|
|
|
|
|
# 添加到主布局
|
|
|
|
|
self.main_layout.addWidget(self.toolbar_widget)
|
|
|
|
|
self.main_layout.addWidget(self.lod_tab_widget)
|
|
|
|
|
self.main_layout.addWidget(self.bottom_toolbar_widget)
|
|
|
|
|
|
|
|
|
|
def _create_toolbar(self):
|
|
|
|
|
"""创建顶部工具栏"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QHBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(2, 2, 2, 2)
|
|
|
|
|
layout.setSpacing(2)
|
|
|
|
|
|
|
|
|
|
# 预设下拉框
|
|
|
|
|
self.preset_combo = QtWidgets.QComboBox()
|
|
|
|
|
self.preset_combo.addItem("MetaHuman")
|
|
|
|
|
layout.addWidget(self.preset_combo)
|
|
|
|
|
|
|
|
|
|
# 垃圾桶按钮
|
|
|
|
|
self.trash_btn = QtWidgets.QPushButton()
|
|
|
|
|
self.trash_btn.setIcon(QtGui.QIcon(f"{config.ICONS_PATH}/trash.png"))
|
|
|
|
|
self.trash_btn.setFixedSize(24, 24)
|
|
|
|
|
layout.addWidget(self.trash_btn)
|
|
|
|
|
|
|
|
|
|
layout.addStretch()
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_lod_tabs(self):
|
|
|
|
|
"""创建LOD选项卡"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
self.lod_tab = QtWidgets.QTabWidget()
|
|
|
|
|
|
|
|
|
|
# 添加LOD页面
|
|
|
|
|
for i in range(8):
|
|
|
|
|
lod_widget = self._create_lod_page(i)
|
|
|
|
|
self.lod_tab.addTab(lod_widget, f"LOD{i}")
|
|
|
|
|
|
|
|
|
|
return self.lod_tab
|
|
|
|
|
|
|
|
|
|
def _create_lod_page(self, lod_index):
|
|
|
|
|
"""创建单个LOD页面"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(5, 5, 5, 5)
|
|
|
|
|
layout.setSpacing(2)
|
|
|
|
|
|
|
|
|
|
# 创建网格列表
|
|
|
|
|
scroll_area = QtWidgets.QScrollArea()
|
|
|
|
|
scroll_area.setWidgetResizable(True)
|
|
|
|
|
scroll_widget = QtWidgets.QWidget()
|
|
|
|
|
scroll_layout = QtWidgets.QVBoxLayout(scroll_widget)
|
|
|
|
|
|
|
|
|
|
# 获取当前LOD级别的网格列表
|
|
|
|
|
meshes = config.LOD_MESHES[f"LOD{lod_index}"]
|
|
|
|
|
self.mesh_items = [] # 存储所有mesh item的引用
|
|
|
|
|
|
|
|
|
|
for mesh in meshes:
|
|
|
|
|
mesh_item = self._create_mesh_item(mesh)
|
|
|
|
|
scroll_layout.addWidget(mesh_item)
|
|
|
|
|
self.mesh_items.append(mesh_item)
|
|
|
|
|
|
|
|
|
|
scroll_layout.addStretch()
|
|
|
|
|
scroll_area.setWidget(scroll_widget)
|
|
|
|
|
layout.addWidget(scroll_area)
|
|
|
|
|
|
|
|
|
|
# 添加底部按钮
|
|
|
|
|
button_widget = QtWidgets.QWidget()
|
|
|
|
|
button_layout = QtWidgets.QHBoxLayout(button_widget)
|
|
|
|
|
button_layout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
|
|
|
|
|
|
self.auto_select_btn = QtWidgets.QPushButton("自动选择模型")
|
|
|
|
|
self.standardize_btn = QtWidgets.QPushButton("标准化命名")
|
|
|
|
|
self.auto_group_btn = QtWidgets.QPushButton("自动分组")
|
|
|
|
|
|
|
|
|
|
button_layout.addWidget(self.auto_select_btn)
|
|
|
|
|
button_layout.addWidget(self.standardize_btn)
|
|
|
|
|
button_layout.addWidget(self.auto_group_btn)
|
|
|
|
|
|
|
|
|
|
layout.addWidget(button_widget)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_mesh_item(self, mesh_name):
|
|
|
|
|
"""创建单个网格项"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QHBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
|
layout.setSpacing(2)
|
|
|
|
|
|
|
|
|
|
# 网格名称标签
|
|
|
|
|
label = QtWidgets.QLabel(mesh_name)
|
|
|
|
|
label.setFixedWidth(80)
|
|
|
|
|
layout.addWidget(label)
|
|
|
|
|
|
|
|
|
|
# 网格路径输入框
|
|
|
|
|
path_edit = QtWidgets.QLineEdit()
|
|
|
|
|
layout.addWidget(path_edit)
|
|
|
|
|
|
|
|
|
|
# 添加按钮
|
|
|
|
|
add_btn = QtWidgets.QPushButton("添加...")
|
|
|
|
|
add_btn.setFixedWidth(60)
|
|
|
|
|
layout.addWidget(add_btn)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_bottom_toolbar(self):
|
|
|
|
|
"""创建底部工具栏"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QHBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(5, 5, 5, 5)
|
|
|
|
|
layout.setSpacing(5)
|
|
|
|
|
|
|
|
|
|
# 预设选择
|
|
|
|
|
preset_label = QtWidgets.QLabel("预设:")
|
|
|
|
|
self.preset_combo_bottom = QtWidgets.QComboBox()
|
|
|
|
|
self.preset_combo_bottom.addItem("MetaHuman")
|
|
|
|
|
|
|
|
|
|
# LOD选择
|
|
|
|
|
lod_label = QtWidgets.QLabel("选择LOD:")
|
|
|
|
|
self.lod_combo = QtWidgets.QComboBox()
|
|
|
|
|
self.lod_combo.addItem("全部")
|
|
|
|
|
|
|
|
|
|
# 功能按钮
|
|
|
|
|
self.create_lod_btn = QtWidgets.QPushButton("生成当前LOD")
|
|
|
|
|
self.modify_btn = QtWidgets.QPushButton("修复线性")
|
|
|
|
|
self.save_btn = QtWidgets.QPushButton("修复存储")
|
|
|
|
|
|
|
|
|
|
# 添加到布局
|
|
|
|
|
layout.addWidget(preset_label)
|
|
|
|
|
layout.addWidget(self.preset_combo_bottom)
|
|
|
|
|
layout.addStretch()
|
|
|
|
|
layout.addWidget(lod_label)
|
|
|
|
|
layout.addWidget(self.lod_combo)
|
|
|
|
|
layout.addWidget(self.create_lod_btn)
|
|
|
|
|
layout.addWidget(self.modify_btn)
|
|
|
|
|
layout.addWidget(self.save_btn)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_connections(self):
|
|
|
|
|
"""创建信号连接"""
|
|
|
|
|
# 顶部工具栏
|
|
|
|
|
self.trash_btn.clicked.connect(self._on_trash_clicked)
|
|
|
|
|
self.preset_combo.currentIndexChanged.connect(self._on_preset_changed)
|
|
|
|
|
|
|
|
|
|
# LOD页面按钮
|
|
|
|
|
for i in range(self.lod_tab.count()):
|
|
|
|
|
page = self.lod_tab.widget(i)
|
|
|
|
|
auto_select_btn = page.findChild(QtWidgets.QPushButton, "自动选择模型")
|
|
|
|
|
if auto_select_btn:
|
|
|
|
|
auto_select_btn.clicked.connect(self._on_auto_select)
|
|
|
|
|
|
|
|
|
|
# 底部工具栏
|
|
|
|
|
self.create_lod_btn.clicked.connect(self._on_create_lod)
|
|
|
|
|
self.modify_btn.clicked.connect(self._on_modify)
|
|
|
|
|
self.save_btn.clicked.connect(self._on_save)
|
|
|
|
|
|
|
|
|
|
def _on_trash_clicked(self):
|
|
|
|
|
"""垃圾桶按钮点击"""
|
|
|
|
|
# TODO: 实现清除功能
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_preset_changed(self, index):
|
|
|
|
|
"""预设改变"""
|
|
|
|
|
# TODO: 实现预设切换
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_auto_select(self):
|
|
|
|
|
"""自动选择模型"""
|
|
|
|
|
# TODO: 实现自动选择
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_create_lod(self):
|
|
|
|
|
"""生成当前LOD"""
|
|
|
|
|
# TODO: 实现LOD生成
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_modify(self):
|
|
|
|
|
"""修复线性"""
|
|
|
|
|
# TODO: 实现修复
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_save(self):
|
|
|
|
|
"""修复存储"""
|
|
|
|
|
# TODO: 实现存储
|
|
|
|
|
pass
|
2025-02-09 22:11:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
pass
|