This commit is contained in:
2025-05-07 01:31:21 +08:00
parent d27ef50341
commit 27240530b6
18 changed files with 2033 additions and 1160 deletions

View File

@@ -3,7 +3,7 @@
"""
Behaviour function module
行为系统工具函数模块 - 提供行为系统UI所需的所有功能函数
行为系统功能模块 - 提供行为系统相关的功能函数
"""
#===================================== IMPORT MODULES =====================================
@@ -19,9 +19,30 @@ import importlib
import traceback
import sys
import os
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
@@ -47,31 +68,27 @@ def control_selected(item):
return True
def update_control_selection():
"""
更新控制选择
"""
print("更新控制选择")
# 这里实现更新控制选择的功能
return True
"""更新控制器选择"""
try:
print("更新控制器选择")
except Exception as e:
print(f"更新控制选择时出错: {str(e)}")
def update_control_value(value):
"""
更新控制值
"""
print(f"更新控制值: {value}")
# 这里实现更新控制值的功能
return True
"""更新控制器值"""
try:
print(f"更新控制器值: {value}")
except Exception as e:
print(f"更新控制器值时出错: {str(e)}")
def switch_page(page):
"""切换页面"""
try:
print(f"切换到页面: {page}")
except Exception as e:
print(f"切换页面时出错: {str(e)}")
# 页码相关功能
def switch_page(page):
"""
切换页面
"""
print(f"切换页面: {page}")
# 这里实现切换页面的功能
return True
# 范围相关功能
def decrease_range():
"""
减小范围
@@ -99,20 +116,81 @@ def blendshape_selected(item):
return True
def update_blendshape_selection():
"""
更新混合形状选择
"""
print("更新混合形状选择")
# 这里实现更新混合形状选择的功能
return True
"""更新BlendShape选择"""
try:
print("更新BlendShape选择")
except Exception as e:
print(f"更新BlendShape选择时出错: {str(e)}")
def update_blendshape_value(value):
"""
更新混合形状值
"""
print(f"更新混合形状值: {value}")
# 这里实现更新混合形状值的功能
return True
"""更新BlendShape值"""
try:
print(f"更新BlendShape值: {value}")
except Exception as e:
print(f"更新BlendShape值时出错: {str(e)}")
def flip_target():
"""翻转目标"""
try:
print("翻转目标")
except Exception as e:
print(f"翻转目标时出错: {str(e)}")
def mirror_target():
"""镜像目标"""
try:
print("镜像目标")
except Exception as e:
print(f"镜像目标时出错: {str(e)}")
def find_flip_target():
"""查找翻转目标"""
try:
print("查找翻转目标")
except Exception as e:
print(f"查找翻转目标时出错: {str(e)}")
def add_blendshape():
"""添加BlendShape"""
try:
print("添加BlendShape")
except Exception as e:
print(f"添加BlendShape时出错: {str(e)}")
def delete_blendshape():
"""删除BlendShape"""
try:
print("删除BlendShape")
except Exception as e:
print(f"删除BlendShape时出错: {str(e)}")
def batch_blendshape():
"""批量处理BlendShape"""
try:
print("批量处理BlendShape")
except Exception as e:
print(f"批量处理BlendShape时出错: {str(e)}")
def rebuild_select():
"""重建选择"""
try:
print("重建选择")
except Exception as e:
print(f"重建选择时出错: {str(e)}")
def reposition():
"""重新定位"""
try:
print("重新定位")
except Exception as e:
print(f"重新定位时出错: {str(e)}")
def blend_select():
"""混合选择"""
try:
print("混合选择")
except Exception as e:
print(f"混合选择时出错: {str(e)}")
# BlendShape操作相关功能
def reset_blendshape():
@@ -131,14 +209,6 @@ def mirror_blendshape():
# 这里实现镜像混合形状的功能
return True
def add_blendshape():
"""
添加混合形状
"""
print("添加混合形状")
# 这里实现添加混合形状的功能
return True
def remove_blendshape():
"""
移除混合形状
@@ -181,21 +251,61 @@ def combine_blendshape():
# 标签页相关功能
def switch_tab(tab):
"""
切换标签页
"""
print(f"切换标签页: {tab}")
# 这里实现切换标签页的功能
return True
"""切换标签页"""
try:
print(f"切换到标签页: {tab}")
except Exception as e:
print(f"切换标签页时出错: {str(e)}")
# 底部相关功能
def update_main_value(value):
"""
更新主值
"""
print(f"更新主值: {value}")
# 这里实现更新主值的功能
return True
"""更新主滑块值"""
try:
print(f"更新主滑块值: {value}")
except Exception as e:
print(f"更新主滑块值时出错: {str(e)}")
def reset_default_expression():
"""重置默认表情"""
try:
print("重置默认表情")
except Exception as e:
print(f"重置默认表情时出错: {str(e)}")
def find_select_expression():
"""查找选择表情"""
try:
print("查找选择表情")
except Exception as e:
print(f"查找选择表情时出错: {str(e)}")
def write_current_expressions():
"""写入当前表情"""
try:
print("写入当前表情")
except Exception as e:
print(f"写入当前表情时出错: {str(e)}")
def controller_find():
"""控制器查找"""
try:
print("控制器查找")
except Exception as e:
print(f"控制器查找时出错: {str(e)}")
def select_associated_joint():
"""选择关联关节"""
try:
print("选择关联关节")
except Exception as e:
print(f"选择关联关节时出错: {str(e)}")
def write_find_mirror():
"""写入查找镜像"""
try:
print("写入查找镜像")
except Exception as e:
print(f"写入查找镜像时出错: {str(e)}")
def exchange_from_expression():
"""
@@ -265,6 +375,239 @@ def import_map_expression():
print(f"导入表情映射时出错: {e}")
return True
# 勾选框处理函数
def toggle_raw_slider_all(state):
"""
切换左侧滑块的All选项
Args:
state (int): 勾选框状态
"""
try:
print(f"切换左侧滑块All选项: {state}")
# 根据勾选状态执行相应操作
if state == 2: # 选中状态
print("应用到所有控制器")
# TODO: 实现应用到所有控制器的逻辑
else: # 未选中状态
print("仅应用到选中的控制器")
# TODO: 实现仅应用到选中控制器的逻辑
except Exception as e:
print(f"切换左侧滑块All选项时出错: {str(e)}")
def toggle_bs_slider_all(state):
"""
切换右侧BS滑块的All选项
Args:
state (int): 勾选框状态
"""
try:
print(f"切换右侧BS滑块All选项: {state}")
# 根据勾选状态执行相应操作
if state == 2: # 选中状态
print("应用到所有BlendShape")
# TODO: 实现应用到所有BlendShape的逻辑
else: # 未选中状态
print("仅应用到选中的BlendShape")
# TODO: 实现仅应用到选中BlendShape的逻辑
except Exception as e:
print(f"切换右侧BS滑块All选项时出错: {str(e)}")
def toggle_bottom_slider_all(state):
"""
切换底部主滑块的All选项
Args:
state (int): 勾选框状态
"""
try:
print(f"切换底部主滑块All选项: {state}")
# 根据勾选状态执行相应操作
if state == 2: # 选中状态
print("应用到所有表情")
# TODO: 实现应用到所有表情的逻辑
else: # 未选中状态
print("仅应用到当前表情")
# TODO: 实现仅应用到当前表情的逻辑
except Exception as e:
print(f"切换底部主滑块All选项时出错: {str(e)}")
# 滑块更新函数
def update_raw_slider_value(value):
"""
更新左侧滑块数值显示
Args:
value (int): 滑块值
Returns:
float: 标准化后的值(0-1范围)
"""
# 将滑块值转换为0-1范围的浮点数并显示3位小数
normalized_value = value / 100.0
# 获取UI实例并更新显示
from scripts.ui.behaviour import BehaviourUI
ui_instance = BehaviourUI.get_instance()
if ui_instance and hasattr(ui_instance, 'controls'):
ui_instance.controls["raw_slider_value"].setText(f"{normalized_value:.3f}")
# 更新控制值
update_control_value(value)
return normalized_value
def update_bs_slider_value(value):
"""
更新右侧BS滑块数值显示
Args:
value (int): 滑块值
Returns:
float: 标准化后的值(0-1范围)
"""
# 将滑块值转换为0-1范围的浮点数并显示3位小数
normalized_value = value / 100.0
# 获取UI实例并更新显示
from scripts.ui.behaviour import BehaviourUI
ui_instance = BehaviourUI.get_instance()
if ui_instance and hasattr(ui_instance, 'controls'):
ui_instance.controls["bs_slider_value"].setText(f"{normalized_value:.3f}")
# 更新BlendShape值
update_blendshape_value(value)
return normalized_value
def update_bottom_slider_value(value):
"""
更新底部主滑块数值显示
Args:
value (int): 滑块值
Returns:
float: 标准化后的值(0-1范围)
"""
# 将滑块值转换为0-1范围的浮点数并显示3位小数
normalized_value = value / 100.0
# 获取UI实例并更新显示
from scripts.ui.behaviour import BehaviourUI
ui_instance = BehaviourUI.get_instance()
if ui_instance and hasattr(ui_instance, 'controls'):
ui_instance.controls["bottom_slider_value"].setText(f"{normalized_value:.3f}")
# 更新主值
update_main_value(value)
return normalized_value
# UI事件处理相关的功能函数
def on_selection_changed(ui_instance):
"""
处理Maya选择变化事件
Args:
ui_instance: UI实例对象
"""
print("选择变化事件触发")
# 这里将来会实现选择变化的处理逻辑
# 目前仅作为占位函数
def switch_tab(ui_instance, index):
"""
切换标签页
Args:
ui_instance: UI实例对象
index (int): 标签页索引
"""
if hasattr(ui_instance, 'controls') and 'bottom_tab_widget' in ui_instance.controls:
ui_instance.controls["bottom_tab_widget"].setCurrentIndex(index)
print(f"切换到标签页: {index}")
def adjust_range(delta):
"""
调整滑块范围
Args:
delta (float): 范围调整值
"""
if delta > 0:
increase_range()
else:
decrease_range()
def reset_splitter_sizes(ui_instance):
"""
重置分割器大小,确保左右分栏均等
Args:
ui_instance: UI实例对象
"""
from scripts.ui import ui_utils
ui_utils.reset_splitter_sizes(ui_instance)
def on_raw_slider_changed(value):
"""
处理Raw滑块值变化
Args:
value (int): 滑块值
"""
# 更新显示值
print(f"Raw滑块值变化: {value}")
# 调用实际的更新函数
update_raw_slider_value(value)
def on_bs_slider_changed(value):
"""
处理BlendShape滑块值变化
Args:
value (int): 滑块值
"""
# 更新显示值
print(f"BlendShape滑块值变化: {value}")
# 调用实际的更新函数
update_bs_slider_value(value)
def on_bottom_slider_changed(value):
"""
处理底部主滑块值变化
Args:
value (int): 滑块值
"""
# 更新显示值
print(f"底部主滑块值变化: {value}")
# 调用实际的更新函数
update_bottom_slider_value(value)
def on_control_selection_changed():
"""处理控制列表选择变化"""
print("控制列表选择变化")
update_control_selection()
def on_blendshape_selection_changed():
"""处理BlendShape列表选择变化"""
print("BlendShape列表选择变化")
update_blendshape_selection()
def adjust_bs_range(delta):
"""
调整BlendShape滑块范围
Args:
delta (float): 范围调整值
"""
print(f"调整BlendShape滑块范围: {delta}")
adjust_range(delta)
# 保留原来的函数作为兼容性考虑
def behaviour_temp_utils_function():
"""
@@ -272,4 +615,14 @@ def behaviour_temp_utils_function():
This function will be replaced with actual functionality in future updates
"""
print("Behaviour module temporary function called")
return True
return True
def reposition_joints():
"""
重新定位关节
根据当前选择的模型重新定位关节位置
"""
print("重新定位关节...")
# 这里将来会实现关节重新定位的功能
# 目前仅作为占位函数
cmds.warning("关节重新定位功能尚未实现")

View File

@@ -3,7 +3,7 @@
"""
Definition function module
定义系统工具函数模块 - 提供定义系统UI所需的所有功能函数
定义系统功能模块 - 提供定义系统相关的功能函数
"""
#===================================== IMPORT MODULES =====================================
@@ -19,12 +19,32 @@ import importlib
import traceback
import sys
import os
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
#========================================== FUNCTIONS ========================================
# 左侧面板功能

View File

@@ -3,7 +3,7 @@
"""
Geometry function module
几何模型工具函数模块 - 提供几何模型UI所需的所有功能函数
几何模型功能模块 - 提供几何模型相关的功能函数
"""
#===================================== IMPORT MODULES =====================================
@@ -19,12 +19,32 @@ import importlib
import traceback
import sys
import os
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
#========================================== FUNCTIONS ========================================
# 左侧面板功能

View File

@@ -9,12 +9,42 @@ Rigging function module
#===================================== IMPORT MODULES =====================================
import maya.cmds as cmds
import pymel.core as pm
import maya.mel as mel
from maya import OpenMayaUI as omui
from Qt import QtWidgets, QtCore, QtGui
from Qt.QtCompat import wrapInstance
import webbrowser
import subprocess
import importlib
import traceback
import sys
import os
import random
from PySide2 import QtWidgets, QtCore, QtGui
from functools import partial
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
#========================================== GLOBALS ========================================
# 存储当前选中的关节和控制器信息
@@ -753,4 +783,113 @@ def on_selection_changed():
selected_controller = obj
# 可以在这里添加代码来更新UI
print(f"选中控制器: {selected_controller}")
break
break
def browse_file(ui_instance, title, input_widget, file_filter=None):
"""浏览文件或目录
Args:
ui_instance: UI实例用于获取主窗口
title (str): 对话框标题
input_widget (QLineEdit): 用于显示路径的输入框控件
file_filter (str, optional): 文件过滤器如果为None则浏览目录否则浏览文件
"""
from Qt import QtWidgets
import os
current_path = input_widget.text() or os.path.expanduser("~")
if file_filter:
# 浏览文件
if file_filter == "dna":
file_filter = "DNA文件 (*.dna);;所有文件 (*.*)"
elif file_filter == "json":
file_filter = "JSON文件 (*.json);;所有文件 (*.*)"
else:
file_filter = "所有文件 (*.*)"
file_path, _ = QtWidgets.QFileDialog.getOpenFileName(
ui_instance.main_widget, title, current_path, file_filter
)
if file_path:
input_widget.setText(file_path)
else:
# 浏览目录
dir_path = QtWidgets.QFileDialog.getExistingDirectory(
ui_instance.main_widget, title, current_path
)
if dir_path:
input_widget.setText(dir_path)
def on_selection_changed(ui_instance=None):
"""处理Maya选择变化事件
Args:
ui_instance: UI实例可选
"""
import maya.cmds as cmds
# 获取当前选择
selection = cmds.ls(selection=True)
if not selection:
return
# 更新UI显示
print(f"当前选择: {selection}")
# 这里可以添加更多的选择处理逻辑
# 如果提供了UI实例可以更新UI
if ui_instance:
# 更新UI显示
pass
def export_presets(*args):
"""导出预设"""
print("导出预设")
# 实现导出预设的功能
def import_presets(*args):
"""导入预设"""
print("导入预设")
# 实现导入预设的功能
# ======================================= 占位函数 =======================================
# 以下是未实现功能的占位函数,用于连接未创建的按钮
def add_joint(*args):
"""添加关节(占位函数)"""
print("添加关节功能尚未实现")
def remove_joint(*args):
"""删除关节(占位函数)"""
print("删除关节功能尚未实现")
def duplicate_joint(*args):
"""复制关节(占位函数)"""
print("复制关节功能尚未实现")
def add_controller(*args):
"""添加控制器(占位函数)"""
print("添加控制器功能尚未实现")
def remove_controller(*args):
"""删除控制器(占位函数)"""
print("删除控制器功能尚未实现")
def duplicate_controller(*args):
"""复制控制器(占位函数)"""
print("复制控制器功能尚未实现")
def import_dna(*args):
"""导入DNA占位函数"""
print("导入DNA功能尚未实现")
def export_dna(*args):
"""导出DNA占位函数"""
print("导出DNA功能尚未实现")
def calibrate_dna(*args):
"""校准DNA占位函数"""
print("校准DNA功能尚未实现")

View File

@@ -14,9 +14,30 @@ import importlib
import traceback
import sys
import os
# 导入配置
import config
TOOL_NAME = config.TOOL_NAME
TOOL_VERSION = config.TOOL_VERSION
TOOL_AUTHOR = config.TOOL_AUTHOR
TOOL_YEAR = config.TOOL_YEAR
TOOL_MOD_FILENAME = config.TOOL_MOD_FILENAME
TOOL_LANG = config.TOOL_LANG
TOOL_WSCL_NAME = config.TOOL_WSCL_NAME
TOOL_HELP_URL = config.TOOL_HELP_URL
TOOL_PATH = config.TOOL_PATH
SCRIPTS_PATH = config.SCRIPTS_PATH
TOOL_MAIN_SCRIPT = config.TOOL_MAIN_SCRIPT
UI_PATH = config.UI_PATH
STYLE_FILE = config.STYLE_FILE
ICONS_PATH = config.ICONS_PATH
TOOL_ICON = config.TOOL_ICON
ASSETS_PATH = config.ASSETS_PATH
DNA_FILE_PATH = config.DNA_FILE_PATH
DNA_IMG_PATH = config.DNA_IMG_PATH
TOOL_COMMAND_ICON = config.TOOL_COMMAND_ICON
TOOL_WIDTH = config.TOOL_WIDTH
TOOL_HEIGHT = config.TOOL_HEIGHT
# Localization
from scripts.ui import localization
LANG = localization.LANG
@@ -151,7 +172,7 @@ def show_help():
# 打开帮助文档或显示帮助对话框
help_dialog = QtWidgets.QMessageBox()
help_dialog.setWindowTitle(LANG.get("help_title", "帮助"))
help_dialog.setText(LANG.get("help_message", "MetaFusion是一个用于自定义MetaHuman的Maya插件。\n\n详细信息请参考文档。"))
help_dialog.setText(LANG.get("help_message", "该插件是一个用于自定义MetaHuman的Maya插件。\n\n详细信息请参考文档。"))
help_dialog.setStandardButtons(QtWidgets.QMessageBox.Ok)
help_dialog.exec_()
except Exception as e: