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
|
|
|
|
|
|
2025-02-11 00:04:32 +08:00
|
|
|
|
from scripts import config # 改为绝对导入
|
|
|
|
|
|
|
|
|
|
QtCore, QtGui, QtWidgets, wrapInstance = config.Qt()
|
2025-02-09 22:11:50 +08:00
|
|
|
|
|
2025-02-11 00:04:32 +08:00
|
|
|
|
if QtCore is None or QtGui is None or QtWidgets is None or wrapInstance is None:
|
|
|
|
|
print(f"Qt加载失败: {QtCore}, {QtGui}, {QtWidgets}, {wrapInstance}")
|
2025-02-09 22:11:50 +08:00
|
|
|
|
|
|
|
|
|
class DefinitionTab(QtWidgets.QWidget):
|
2025-02-09 23:22:48 +08:00
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super(DefinitionTab, self).__init__(parent)
|
|
|
|
|
self._setup_ui()
|
|
|
|
|
|
|
|
|
|
def _setup_ui(self):
|
|
|
|
|
"""设置UI布局"""
|
|
|
|
|
# === Main Layout ===
|
2025-02-10 04:16:11 +08:00
|
|
|
|
self.main_layout = QtWidgets.QVBoxLayout(self)
|
|
|
|
|
self.main_layout.setContentsMargins(4, 4, 4, 4)
|
|
|
|
|
self.main_layout.setSpacing(4)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# === 创建水平分割布局 ===
|
|
|
|
|
self.splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# === 左侧区域 ===
|
|
|
|
|
left_widget = QtWidgets.QWidget()
|
|
|
|
|
left_layout = QtWidgets.QVBoxLayout(left_widget)
|
|
|
|
|
left_layout.setContentsMargins(4, 8, 4, 4)
|
|
|
|
|
left_layout.setSpacing(4)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# LODs标题
|
|
|
|
|
lod_title = QtWidgets.QLabel("LODs")
|
|
|
|
|
lod_title.setStyleSheet("color: #00A5FF;")
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# LOD列表
|
2025-02-09 23:22:48 +08:00
|
|
|
|
self.lod_list = QtWidgets.QListWidget()
|
2025-02-10 04:16:11 +08:00
|
|
|
|
self.lod_list.setStyleSheet("""
|
|
|
|
|
QListWidget {
|
|
|
|
|
background: #232323;
|
|
|
|
|
border: 1px solid #555555;
|
|
|
|
|
}
|
|
|
|
|
QListWidget::item {
|
|
|
|
|
height: 24px;
|
|
|
|
|
padding: 0px 4px;
|
|
|
|
|
border-bottom: 1px solid #383838;
|
|
|
|
|
}
|
|
|
|
|
QListWidget::item:selected {
|
|
|
|
|
background: #4D4D4D;
|
|
|
|
|
}
|
|
|
|
|
""")
|
|
|
|
|
|
|
|
|
|
# 添加LOD项
|
2025-02-09 23:22:48 +08:00
|
|
|
|
for i in range(8):
|
2025-02-10 04:16:11 +08:00
|
|
|
|
item = QtWidgets.QListWidgetItem(f"LOD {i}")
|
|
|
|
|
item.setIcon(QtGui.QIcon(":mesh.png"))
|
|
|
|
|
self.lod_list.addItem(item)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 定义LOD关节按钮
|
|
|
|
|
define_lod_btn = QtWidgets.QPushButton("定义LOD关节")
|
|
|
|
|
define_lod_btn.setIcon(QtGui.QIcon(":kinJoint.png"))
|
|
|
|
|
|
|
|
|
|
# Meshes标题
|
|
|
|
|
mesh_title = QtWidgets.QLabel("Meshes [010/54]")
|
|
|
|
|
mesh_title.setStyleSheet("color: #00A5FF;")
|
|
|
|
|
|
|
|
|
|
# Mesh列表
|
|
|
|
|
self.mesh_list = QtWidgets.QListWidget()
|
|
|
|
|
self.mesh_list.setStyleSheet(self.lod_list.styleSheet())
|
|
|
|
|
|
|
|
|
|
# 添加Mesh项
|
|
|
|
|
mesh_items = [
|
|
|
|
|
("head_lod0_mesh", "000"),
|
|
|
|
|
("teeth_lod0_mesh", "001"),
|
|
|
|
|
("saliva_lod0_mesh", "002"),
|
|
|
|
|
("eyeLeft_lod0_mesh", "003"),
|
|
|
|
|
("eyeRight_lod0_mesh", "004")
|
|
|
|
|
]
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
for name, index in mesh_items:
|
|
|
|
|
item = QtWidgets.QListWidgetItem(f"{name} {index}")
|
|
|
|
|
item.setIcon(QtGui.QIcon(":mesh.png"))
|
|
|
|
|
self.mesh_list.addItem(item)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 添加到左侧布局
|
|
|
|
|
left_layout.addWidget(lod_title)
|
|
|
|
|
left_layout.addWidget(self.lod_list)
|
|
|
|
|
left_layout.addWidget(define_lod_btn)
|
|
|
|
|
left_layout.addWidget(mesh_title)
|
|
|
|
|
left_layout.addWidget(self.mesh_list)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# === 右侧区域 ===
|
|
|
|
|
right_widget = QtWidgets.QWidget()
|
|
|
|
|
right_layout = QtWidgets.QVBoxLayout(right_widget)
|
|
|
|
|
right_layout.setContentsMargins(4, 8, 4, 4)
|
|
|
|
|
right_layout.setSpacing(4)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# Joints标题和列表
|
|
|
|
|
joints_title = QtWidgets.QLabel("Joints [840/870]")
|
|
|
|
|
joints_title.setStyleSheet("color: #00A5FF;")
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
|
|
|
|
self.joints_list = QtWidgets.QListWidget()
|
2025-02-10 04:16:11 +08:00
|
|
|
|
self.joints_list.setStyleSheet(self.lod_list.styleSheet())
|
|
|
|
|
|
|
|
|
|
# BlendShapes标题和列表
|
|
|
|
|
blendshapes_title = QtWidgets.QLabel("Blend Shapes [782/782]")
|
|
|
|
|
blendshapes_title.setStyleSheet("color: #00A5FF;")
|
|
|
|
|
|
|
|
|
|
self.blendshapes_list = QtWidgets.QListWidget()
|
|
|
|
|
self.blendshapes_list.setStyleSheet(self.lod_list.styleSheet())
|
|
|
|
|
|
|
|
|
|
# AnimatedMap标题和列表
|
|
|
|
|
animatedmap_title = QtWidgets.QLabel("AnimatedMap [082/82]")
|
|
|
|
|
animatedmap_title.setStyleSheet("color: #00A5FF;")
|
|
|
|
|
|
|
|
|
|
self.animatedmap_list = QtWidgets.QListWidget()
|
|
|
|
|
self.animatedmap_list.setStyleSheet(self.lod_list.styleSheet())
|
|
|
|
|
|
|
|
|
|
# 添加到右侧布局
|
|
|
|
|
right_layout.addWidget(joints_title)
|
|
|
|
|
right_layout.addWidget(self.joints_list)
|
|
|
|
|
right_layout.addWidget(blendshapes_title)
|
|
|
|
|
right_layout.addWidget(self.blendshapes_list)
|
|
|
|
|
right_layout.addWidget(animatedmap_title)
|
|
|
|
|
right_layout.addWidget(self.animatedmap_list)
|
|
|
|
|
|
|
|
|
|
# === 底部功能区域 ===
|
|
|
|
|
bottom_widget = QtWidgets.QWidget()
|
|
|
|
|
bottom_layout = QtWidgets.QHBoxLayout(bottom_widget)
|
|
|
|
|
bottom_layout.setContentsMargins(4, 4, 4, 4)
|
|
|
|
|
bottom_layout.setSpacing(4)
|
|
|
|
|
|
|
|
|
|
# 创建三个功能区
|
|
|
|
|
for title, buttons in [
|
|
|
|
|
("导入", [
|
|
|
|
|
("导入关节和表情", ":kinJoint.png"),
|
|
|
|
|
("导入几何体", ":mesh.png"),
|
|
|
|
|
("导入蒙皮数据", ":skinWeight.png"),
|
|
|
|
|
("导入混合变形目标", ":blendShape.png")
|
|
|
|
|
]),
|
|
|
|
|
("创建", [
|
|
|
|
|
("创建混合形状", ":blendShape.png"),
|
|
|
|
|
("蒙皮到皮", ":skinWeight.png"),
|
|
|
|
|
("取消蒙皮", ":skinWeight.png")
|
|
|
|
|
]),
|
|
|
|
|
("工具", [
|
|
|
|
|
("重新定位关节位置", ":kinJoint.png"),
|
|
|
|
|
("快速创建蒙皮设置", ":skinWeight.png")
|
|
|
|
|
])
|
|
|
|
|
]:
|
|
|
|
|
group = QtWidgets.QGroupBox(title)
|
|
|
|
|
group_layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
group_layout.setContentsMargins(4, 4, 4, 8)
|
|
|
|
|
group_layout.setSpacing(4)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 添加按钮
|
|
|
|
|
for text, icon in buttons:
|
|
|
|
|
btn = QtWidgets.QPushButton(text)
|
|
|
|
|
btn.setIcon(QtGui.QIcon(icon))
|
|
|
|
|
btn.setFixedHeight(24)
|
|
|
|
|
group_layout.addWidget(btn)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 添加弹性空间到底部
|
|
|
|
|
group_layout.addStretch()
|
|
|
|
|
bottom_layout.addWidget(group)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 添加到分割器和主布局
|
|
|
|
|
self.splitter.addWidget(left_widget)
|
|
|
|
|
self.splitter.addWidget(right_widget)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
self.main_layout.addWidget(self.splitter)
|
|
|
|
|
self.main_layout.addWidget(bottom_widget)
|
2025-02-09 23:22:48 +08:00
|
|
|
|
|
2025-02-10 04:16:11 +08:00
|
|
|
|
# 设置分割器初始比例为均等
|
|
|
|
|
self.splitter.setSizes([int(self.width() * 0.5), int(self.width() * 0.5)])
|
2025-02-09 22:11:50 +08:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
pass
|