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 DefinitionTab(QtWidgets.QWidget):
|
2025-02-09 23:22:48 +08:00
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
|
super(DefinitionTab, self).__init__(parent)
|
|
|
|
|
self._setup_ui()
|
|
|
|
|
self._create_connections()
|
|
|
|
|
|
|
|
|
|
def _setup_ui(self):
|
|
|
|
|
"""设置UI布局"""
|
|
|
|
|
# === Main Layout ===
|
|
|
|
|
self.main_layout = QtWidgets.QHBoxLayout(self)
|
|
|
|
|
self.main_layout.setContentsMargins(2, 2, 2, 2)
|
|
|
|
|
self.main_layout.setSpacing(2)
|
|
|
|
|
|
|
|
|
|
# 创建左侧和右侧面板
|
|
|
|
|
self.left_panel = self._create_left_panel()
|
|
|
|
|
self.right_panel = self._create_right_panel()
|
|
|
|
|
|
|
|
|
|
self.main_layout.addWidget(self.left_panel, 1) # 1:3比例
|
|
|
|
|
self.main_layout.addWidget(self.right_panel, 3)
|
|
|
|
|
|
|
|
|
|
def _create_left_panel(self):
|
|
|
|
|
"""创建左侧面板"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(5, 5, 5, 5)
|
|
|
|
|
layout.setSpacing(5)
|
|
|
|
|
|
|
|
|
|
# LODs列表
|
|
|
|
|
lod_group = QtWidgets.QGroupBox("LODs")
|
|
|
|
|
lod_layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
self.lod_list = QtWidgets.QListWidget()
|
|
|
|
|
for i in range(8):
|
|
|
|
|
self.lod_list.addItem(f"LOD {i}")
|
|
|
|
|
lod_layout.addWidget(self.lod_list)
|
|
|
|
|
|
|
|
|
|
# Define Joint按钮
|
|
|
|
|
self.define_joint_btn = QtWidgets.QPushButton("Define Joint For LOD")
|
|
|
|
|
lod_layout.addWidget(self.define_joint_btn)
|
|
|
|
|
|
|
|
|
|
lod_group.setLayout(lod_layout)
|
|
|
|
|
layout.addWidget(lod_group)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_right_panel(self):
|
|
|
|
|
"""创建右侧面板"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(widget)
|
|
|
|
|
layout.setContentsMargins(5, 5, 5, 5)
|
|
|
|
|
layout.setSpacing(5)
|
|
|
|
|
|
|
|
|
|
# 创建各个部分
|
|
|
|
|
self.meshes_widget = self._create_meshes_section()
|
|
|
|
|
self.joints_widget = self._create_joints_section()
|
|
|
|
|
self.blend_shapes_widget = self._create_blend_shapes_section()
|
|
|
|
|
self.animated_map_widget = self._create_animated_map_section()
|
|
|
|
|
|
|
|
|
|
# 添加到布局
|
|
|
|
|
layout.addWidget(self.meshes_widget)
|
|
|
|
|
layout.addWidget(self.joints_widget)
|
|
|
|
|
layout.addWidget(self.blend_shapes_widget)
|
|
|
|
|
layout.addWidget(self.animated_map_widget)
|
|
|
|
|
|
|
|
|
|
# 添加操作按钮区域
|
|
|
|
|
self.operation_widget = self._create_operation_section()
|
|
|
|
|
layout.addWidget(self.operation_widget)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_meshes_section(self):
|
|
|
|
|
"""创建Meshes部分"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
group = QtWidgets.QGroupBox("Meshes [010/54]")
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
|
|
# 列表
|
|
|
|
|
self.meshes_list = QtWidgets.QListWidget()
|
|
|
|
|
meshes = [
|
|
|
|
|
"head_lod0_mesh (000)",
|
|
|
|
|
"teeth_lod0_mesh (001)",
|
|
|
|
|
"saliva_lod0_mesh (002)",
|
|
|
|
|
"eyeLeft_lod0_mesh (003)",
|
|
|
|
|
"eyeRight_lod0_mesh (004)",
|
|
|
|
|
"eyeshell_lod0_mesh (005)",
|
|
|
|
|
"eyelashes_lod0_mesh (006)",
|
|
|
|
|
"eyeEdge_lod0_mesh (007)"
|
|
|
|
|
]
|
|
|
|
|
for mesh in meshes:
|
|
|
|
|
self.meshes_list.addItem(mesh)
|
|
|
|
|
|
|
|
|
|
layout.addWidget(self.meshes_list)
|
|
|
|
|
|
|
|
|
|
# Create Geometry按钮
|
|
|
|
|
self.create_geo_btn = QtWidgets.QPushButton("Create Geometry")
|
|
|
|
|
layout.addWidget(self.create_geo_btn)
|
|
|
|
|
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
|
|
def _create_joints_section(self):
|
|
|
|
|
"""创建Joints部分"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
group = QtWidgets.QGroupBox("Joints [840/870]")
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
|
|
# 列表
|
|
|
|
|
self.joints_list = QtWidgets.QListWidget()
|
|
|
|
|
joints = [
|
|
|
|
|
"FACIAL_C_NeckB Group: 001",
|
|
|
|
|
"FACIAL_L_NeckB1 Group: 002",
|
|
|
|
|
"FACIAL_R_NeckB1 Group: 003",
|
|
|
|
|
"FACIAL_L_NeckB2 Group: 002",
|
|
|
|
|
"FACIAL_R_NeckB2 Group: 003",
|
|
|
|
|
"FACIAL_C12PV_NeckB1 Group: 001"
|
|
|
|
|
]
|
|
|
|
|
for joint in joints:
|
|
|
|
|
self.joints_list.addItem(joint)
|
|
|
|
|
|
|
|
|
|
layout.addWidget(self.joints_list)
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
|
|
def _create_blend_shapes_section(self):
|
|
|
|
|
"""创建Blend Shapes部分"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
group = QtWidgets.QGroupBox("Blend Shapes [782/782]")
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
|
|
# 列表
|
|
|
|
|
self.blend_shapes_list = QtWidgets.QListWidget()
|
|
|
|
|
shapes = [
|
|
|
|
|
"brow_down_L 000",
|
|
|
|
|
"brow_down_R 001",
|
|
|
|
|
"brow_lateral_L 002",
|
|
|
|
|
"brow_lateral_R 003",
|
|
|
|
|
"brow_raiseIn_L 004",
|
|
|
|
|
"brow_raiseIn_R 005"
|
|
|
|
|
]
|
|
|
|
|
for shape in shapes:
|
|
|
|
|
self.blend_shapes_list.addItem(shape)
|
|
|
|
|
|
|
|
|
|
layout.addWidget(self.blend_shapes_list)
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
|
|
def _create_animated_map_section(self):
|
|
|
|
|
"""创建AnimatedMap部分"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
group = QtWidgets.QGroupBox("AnimatedMap [082/82]")
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
|
|
# 列表
|
|
|
|
|
self.animated_map_list = QtWidgets.QListWidget()
|
|
|
|
|
maps = [
|
|
|
|
|
"head_cm2_color.head_wm2.browsDown 000",
|
|
|
|
|
"head_cm2_color.head_wm2.browsDown 001",
|
|
|
|
|
"head_cm2_color.head_wm2.browsLate 002",
|
|
|
|
|
"head_cm2_color.head_wm2.browsLate 003",
|
|
|
|
|
"head_cm1_color.head_wm1.browsRais 004",
|
|
|
|
|
"head_cm1_color.head_wm1.browsRais 005"
|
|
|
|
|
]
|
|
|
|
|
for map_item in maps:
|
|
|
|
|
self.animated_map_list.addItem(map_item)
|
|
|
|
|
|
|
|
|
|
layout.addWidget(self.animated_map_list)
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
|
|
def _create_operation_section(self):
|
|
|
|
|
"""创建操作区域"""
|
|
|
|
|
# === Widget ===
|
|
|
|
|
widget = QtWidgets.QWidget()
|
|
|
|
|
|
|
|
|
|
# === Layout ===
|
|
|
|
|
layout = QtWidgets.QVBoxLayout(widget)
|
|
|
|
|
|
|
|
|
|
# Write部分
|
|
|
|
|
write_group = QtWidgets.QGroupBox("Write")
|
|
|
|
|
write_layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
write_buttons = [
|
|
|
|
|
"Write Neutral Pose Joint Position",
|
|
|
|
|
"Write Geometry",
|
|
|
|
|
"Write Skin Weights",
|
|
|
|
|
"Write Blend Shapes Targets"
|
|
|
|
|
]
|
|
|
|
|
for text in write_buttons:
|
|
|
|
|
btn = QtWidgets.QPushButton(text)
|
|
|
|
|
write_layout.addWidget(btn)
|
|
|
|
|
write_group.setLayout(write_layout)
|
|
|
|
|
layout.addWidget(write_group)
|
|
|
|
|
|
|
|
|
|
# Create部分
|
|
|
|
|
create_group = QtWidgets.QGroupBox("Create")
|
|
|
|
|
create_layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
create_buttons = [
|
|
|
|
|
"Create Blend Shapes For Mesh",
|
|
|
|
|
"Bind Skin For Mesh",
|
|
|
|
|
"Unbind Skin For Mesh"
|
|
|
|
|
]
|
|
|
|
|
for text in create_buttons:
|
|
|
|
|
btn = QtWidgets.QPushButton(text)
|
|
|
|
|
create_layout.addWidget(btn)
|
|
|
|
|
create_group.setLayout(create_layout)
|
|
|
|
|
layout.addWidget(create_group)
|
|
|
|
|
|
|
|
|
|
# Tools部分
|
|
|
|
|
tools_group = QtWidgets.QGroupBox("Tools")
|
|
|
|
|
tools_layout = QtWidgets.QVBoxLayout()
|
|
|
|
|
tools_buttons = [
|
|
|
|
|
"New Neutral Joint Transform",
|
|
|
|
|
"Quickly Create Presets"
|
|
|
|
|
]
|
|
|
|
|
for text in tools_buttons:
|
|
|
|
|
btn = QtWidgets.QPushButton(text)
|
|
|
|
|
tools_layout.addWidget(btn)
|
|
|
|
|
tools_group.setLayout(tools_layout)
|
|
|
|
|
layout.addWidget(tools_group)
|
|
|
|
|
|
|
|
|
|
return widget
|
|
|
|
|
|
|
|
|
|
def _create_connections(self):
|
|
|
|
|
"""创建信号连接"""
|
|
|
|
|
# LOD列表选择
|
|
|
|
|
self.lod_list.currentItemChanged.connect(self._on_lod_changed)
|
|
|
|
|
|
|
|
|
|
# Define Joint按钮
|
|
|
|
|
self.define_joint_btn.clicked.connect(self._on_define_joint)
|
|
|
|
|
|
|
|
|
|
# Create Geometry按钮
|
|
|
|
|
self.create_geo_btn.clicked.connect(self._on_create_geometry)
|
|
|
|
|
|
|
|
|
|
# ================================ 事件函数 ================================
|
|
|
|
|
def _on_lod_changed(self, current, previous):
|
|
|
|
|
"""LOD选择改变"""
|
|
|
|
|
# TODO: 实现LOD切换逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_define_joint(self):
|
|
|
|
|
"""Define Joint按钮点击"""
|
|
|
|
|
# TODO: 实现Define Joint逻辑
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_create_geometry(self):
|
|
|
|
|
"""Create Geometry按钮点击"""
|
|
|
|
|
# TODO: 实现Create Geometry逻辑
|
|
|
|
|
pass
|
2025-02-09 22:11:50 +08:00
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
pass
|