2025-02-06 04:46:41 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
#===================================== 1. Module Imports =====================================
|
2025-02-06 04:00:17 +08:00
|
|
|
import maya.cmds as cmds
|
2025-02-06 04:46:41 +08:00
|
|
|
import maya.mel as mel
|
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
|
|
|
|
from scripts.ui.widgets import (BaseWidget, DNABrowser, DescriptionWidget, IconButton, SearchLineEdit)
|
2025-02-06 04:00:17 +08:00
|
|
|
|
|
|
|
try:
|
2025-02-06 04:46:41 +08:00
|
|
|
from PySide2 import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken2 import wrapInstance
|
|
|
|
print("从PySide2加载Qt和shiboken2")
|
|
|
|
except ImportError:
|
2025-02-06 04:00:17 +08:00
|
|
|
try:
|
2025-02-06 04:46:41 +08:00
|
|
|
from PySide6 import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken6 import wrapInstance
|
|
|
|
print("从PySide6加载Qt和shiboken6")
|
|
|
|
except ImportError:
|
2025-02-06 04:00:17 +08:00
|
|
|
try:
|
2025-02-06 04:46:41 +08:00
|
|
|
from PySide import QtCore, QtGui, QtWidgets
|
|
|
|
from shiboken import wrapInstance
|
|
|
|
print("从PySide加载Qt和shiboken")
|
2025-02-06 04:00:17 +08:00
|
|
|
except ImportError as e:
|
2025-02-06 04:46:41 +08:00
|
|
|
print(f"Qt加载失败: {str(e)}")
|
|
|
|
QtCore = QtGui = QtWidgets = None
|
|
|
|
wrapInstance = None
|
2025-02-06 04:00:17 +08:00
|
|
|
|
2025-02-06 04:46:41 +08:00
|
|
|
#===================================== 2. Rigging Tab Class =====================================
|
2025-02-06 04:00:17 +08:00
|
|
|
class RigTab(BaseWidget):
|
|
|
|
"""绑定标签页"""
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(RigTab, 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)
|
|
|
|
|
|
|
|
# DNA部分
|
|
|
|
dna_group = self.create_dna_group()
|
|
|
|
content_layout.addWidget(dna_group)
|
|
|
|
|
|
|
|
# 资产部分
|
|
|
|
asset_group = self.create_asset_group()
|
|
|
|
content_layout.addWidget(asset_group)
|
|
|
|
|
|
|
|
# 描述部分
|
|
|
|
self.description_widget = DescriptionWidget()
|
|
|
|
content_layout.addWidget(self.description_widget)
|
|
|
|
|
|
|
|
# 骨架工具
|
|
|
|
skeleton_tools = self.create_skeleton_tools()
|
|
|
|
content_layout.addWidget(skeleton_tools)
|
|
|
|
|
|
|
|
content_layout.addStretch()
|
|
|
|
|
|
|
|
def create_dna_group(self):
|
|
|
|
"""创建DNA组"""
|
|
|
|
group = QtWidgets.QGroupBox("DNA")
|
|
|
|
layout = QtWidgets.QVBoxLayout(group)
|
|
|
|
|
|
|
|
# DNA浏览器
|
|
|
|
self.dna_browser = DNABrowser()
|
|
|
|
self.dna_browser.dnaSelected.connect(self.on_dna_selected)
|
|
|
|
layout.addWidget(self.dna_browser)
|
|
|
|
|
|
|
|
# 导入导出按钮
|
|
|
|
btn_layout = QtWidgets.QHBoxLayout()
|
|
|
|
|
|
|
|
export_btn = IconButton("export.png", "导出设置")
|
|
|
|
export_btn.clicked.connect(self.export_settings)
|
|
|
|
btn_layout.addWidget(export_btn)
|
|
|
|
|
|
|
|
import_btn = IconButton("import.png", "导入设置")
|
|
|
|
import_btn.clicked.connect(self.import_settings)
|
|
|
|
btn_layout.addWidget(import_btn)
|
|
|
|
|
|
|
|
btn_layout.addStretch()
|
|
|
|
layout.addLayout(btn_layout)
|
|
|
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
def create_asset_group(self):
|
|
|
|
"""创建资产组"""
|
|
|
|
group = QtWidgets.QGroupBox("资产")
|
|
|
|
layout = QtWidgets.QFormLayout(group)
|
|
|
|
|
|
|
|
# 项目路径
|
|
|
|
project_layout = QtWidgets.QHBoxLayout()
|
|
|
|
self.project_edit = QtWidgets.QLineEdit()
|
|
|
|
project_btn = IconButton("target.png", "选择项目路径")
|
|
|
|
project_btn.clicked.connect(self.browse_project)
|
|
|
|
project_layout.addWidget(self.project_edit)
|
|
|
|
project_layout.addWidget(project_btn)
|
|
|
|
layout.addRow("项目路径:", project_layout)
|
|
|
|
|
|
|
|
# 预设文件
|
|
|
|
preset_layout = QtWidgets.QHBoxLayout()
|
|
|
|
self.preset_edit = QtWidgets.QLineEdit()
|
|
|
|
preset_btn = IconButton("target.png", "选择预设文件")
|
|
|
|
preset_btn.clicked.connect(self.browse_preset)
|
|
|
|
preset_layout.addWidget(self.preset_edit)
|
|
|
|
preset_layout.addWidget(preset_btn)
|
|
|
|
layout.addRow("预设文件:", preset_layout)
|
|
|
|
|
|
|
|
# 数据分层
|
|
|
|
layer_layout = QtWidgets.QHBoxLayout()
|
|
|
|
self.layer_combo = QtWidgets.QComboBox()
|
|
|
|
self.layer_combo.addItems(["行为"])
|
|
|
|
self.override_check = QtWidgets.QCheckBox("覆盖表情")
|
|
|
|
layer_layout.addWidget(self.layer_combo)
|
|
|
|
layer_layout.addWidget(self.override_check)
|
|
|
|
layout.addRow("数据分层:", layer_layout)
|
|
|
|
|
|
|
|
return group
|
|
|
|
|
|
|
|
def create_skeleton_tools(self):
|
|
|
|
"""创建骨架工具"""
|
|
|
|
group = QtWidgets.QGroupBox("骨架工具")
|
|
|
|
layout = QtWidgets.QHBoxLayout(group)
|
|
|
|
|
|
|
|
# 清空选项
|
|
|
|
clear_btn = IconButton("delete.png", "清空选项")
|
|
|
|
clear_btn.clicked.connect(self.clear_options)
|
|
|
|
layout.addWidget(clear_btn)
|
|
|
|
|
|
|
|
# 导入骨架
|
|
|
|
import_btn = IconButton("HIKCharacterToolSkeleton.png", "导入骨架")
|
|
|
|
import_btn.clicked.connect(self.import_skeleton)
|
|
|
|
layout.addWidget(import_btn)
|
|
|
|
|
|
|
|
# 创建骨架
|
|
|
|
create_btn = IconButton("HIKcreateControlRig.png", "创建骨架")
|
|
|
|
create_btn.clicked.connect(self.create_skeleton)
|
|
|
|
layout.addWidget(create_btn)
|
|
|
|
|
|
|
|
layout.addStretch()
|
|
|
|
return group
|
|
|
|
|
|
|
|
# DNA功能回调
|
|
|
|
def on_dna_selected(self, dna_path):
|
|
|
|
"""DNA文件选中"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.load_dna(dna_path)
|
|
|
|
|
|
|
|
def export_settings(self):
|
|
|
|
"""导出设置"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.export_settings()
|
|
|
|
|
|
|
|
def import_settings(self):
|
|
|
|
"""导入设置"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.import_settings()
|
|
|
|
|
|
|
|
# 资产功能回调
|
|
|
|
def browse_project(self):
|
|
|
|
"""浏览项目路径"""
|
|
|
|
path = QtWidgets.QFileDialog.getExistingDirectory(
|
|
|
|
self, "选择项目路径", os.path.expanduser("~"))
|
|
|
|
if path:
|
|
|
|
self.project_edit.setText(path)
|
|
|
|
|
|
|
|
def browse_preset(self):
|
|
|
|
"""浏览预设文件"""
|
|
|
|
file_path, _ = QtWidgets.QFileDialog.getOpenFileName(
|
|
|
|
self, "选择预设文件", os.path.expanduser("~"),
|
|
|
|
"预设文件 (*.json *.preset)")
|
|
|
|
if file_path:
|
|
|
|
self.preset_edit.setText(file_path)
|
|
|
|
|
|
|
|
# 骨架工具回调
|
|
|
|
def clear_options(self):
|
|
|
|
"""清空选项"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.clear_options()
|
|
|
|
|
|
|
|
def import_skeleton(self):
|
|
|
|
"""导入骨架"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.import_skeleton()
|
|
|
|
|
|
|
|
def create_skeleton(self):
|
|
|
|
"""创建骨架"""
|
|
|
|
from scripts.utils import rigging_utils
|
|
|
|
rigging_utils.create_skeleton()
|