Update
This commit is contained in:
@@ -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("关节重新定位功能尚未实现")
|
Reference in New Issue
Block a user