368 lines
8.6 KiB
Python
368 lines
8.6 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Geometry function module
|
|
几何模型工具函数模块 - 提供几何模型UI所需的所有功能函数
|
|
"""
|
|
|
|
#===================================== 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 config
|
|
from scripts.ui import localization
|
|
LANG = localization.LANG
|
|
|
|
#========================================== FUNCTIONS ========================================
|
|
|
|
# 左侧面板功能
|
|
# LOD相关功能
|
|
def lod_selected(item):
|
|
"""
|
|
LOD项目被选中
|
|
"""
|
|
print(f"LOD项目被选中: {item.text()}")
|
|
# 这里实现LOD项目选中的功能
|
|
return True
|
|
|
|
def update_lod_selection():
|
|
"""
|
|
更新LOD选择
|
|
"""
|
|
print("更新LOD选择")
|
|
# 这里实现更新LOD选择的功能
|
|
return True
|
|
|
|
def add_lod():
|
|
"""
|
|
添加LOD
|
|
"""
|
|
print("添加LOD")
|
|
# 这里实现添加LOD的功能
|
|
return True
|
|
|
|
def remove_lod():
|
|
"""
|
|
移除LOD
|
|
"""
|
|
print("移除LOD")
|
|
# 这里实现移除LOD的功能
|
|
return True
|
|
|
|
def duplicate_lod():
|
|
"""
|
|
复制LOD
|
|
"""
|
|
print("复制LOD")
|
|
# 这里实现复制LOD的功能
|
|
return True
|
|
|
|
# 模型相关功能
|
|
def model_selected(item):
|
|
"""
|
|
模型项目被选中
|
|
"""
|
|
print(f"模型项目被选中: {item.text()}")
|
|
# 这里实现模型项目选中的功能
|
|
return True
|
|
|
|
def update_model_selection():
|
|
"""
|
|
更新模型选择
|
|
"""
|
|
print("更新模型选择")
|
|
# 这里实现更新模型选择的功能
|
|
return True
|
|
|
|
def add_model():
|
|
"""
|
|
添加模型
|
|
"""
|
|
print("添加模型")
|
|
# 这里实现添加模型的功能
|
|
return True
|
|
|
|
def remove_model():
|
|
"""
|
|
移除模型
|
|
"""
|
|
print("移除模型")
|
|
# 这里实现移除模型的功能
|
|
return True
|
|
|
|
def duplicate_model():
|
|
"""
|
|
复制模型
|
|
"""
|
|
print("复制模型")
|
|
# 这里实现复制模型的功能
|
|
return True
|
|
|
|
# 右侧面板功能
|
|
# 模型属性相关功能
|
|
def update_model_name(text):
|
|
"""
|
|
更新模型名称
|
|
"""
|
|
print(f"更新模型名称: {text}")
|
|
# 这里实现更新模型名称的功能
|
|
return True
|
|
|
|
def update_model_type(index):
|
|
"""
|
|
更新模型类型
|
|
"""
|
|
print(f"更新模型类型: {index}")
|
|
# 这里实现更新模型类型的功能
|
|
return True
|
|
|
|
def toggle_model_visibility(state):
|
|
"""
|
|
切换模型可见性
|
|
"""
|
|
print(f"切换模型可见性: {state}")
|
|
# 这里实现切换模型可见性的功能
|
|
return True
|
|
|
|
def apply_properties():
|
|
"""
|
|
应用属性
|
|
"""
|
|
print("应用属性")
|
|
# 这里实现应用属性的功能
|
|
return True
|
|
|
|
def reset_properties():
|
|
"""
|
|
重置属性
|
|
"""
|
|
print("重置属性")
|
|
# 这里实现重置属性的功能
|
|
return True
|
|
|
|
# 模型工具相关功能
|
|
def standardize_names():
|
|
"""
|
|
标准化命名
|
|
"""
|
|
print("标准化命名")
|
|
# 这里实现标准化命名的功能
|
|
return True
|
|
|
|
def auto_group():
|
|
"""
|
|
自动分组
|
|
"""
|
|
print("自动分组")
|
|
# 这里实现自动分组的功能
|
|
return True
|
|
|
|
def generate_accessories():
|
|
"""
|
|
生成配件
|
|
"""
|
|
print("生成配件")
|
|
# 这里实现生成配件的功能
|
|
return True
|
|
|
|
def fix_seams():
|
|
"""
|
|
修复接缝
|
|
"""
|
|
print("修复接缝")
|
|
# 这里实现修复接缝的功能
|
|
return True
|
|
|
|
def fix_vertex_order():
|
|
"""
|
|
修复点序
|
|
"""
|
|
print("修复点序")
|
|
# 这里实现修复点序的功能
|
|
return True
|
|
|
|
# 底部工具面板功能
|
|
# 导入相关功能
|
|
def import_model():
|
|
"""
|
|
导入模型
|
|
"""
|
|
print("导入模型")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="Maya Files (*.ma *.mb);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=1
|
|
)
|
|
if file_path:
|
|
# 这里实现导入模型的功能
|
|
print(f"将从{file_path[0]}导入模型")
|
|
except Exception as e:
|
|
print(f"导入模型时出错: {e}")
|
|
return True
|
|
|
|
def import_fbx():
|
|
"""
|
|
导入FBX
|
|
"""
|
|
print("导入FBX")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="FBX Files (*.fbx);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=1
|
|
)
|
|
if file_path:
|
|
# 这里实现导入FBX的功能
|
|
print(f"将从{file_path[0]}导入FBX")
|
|
mel.eval(f'FBXImport -file "{file_path[0]}";')
|
|
except Exception as e:
|
|
print(f"导入FBX时出错: {e}")
|
|
return True
|
|
|
|
def import_obj():
|
|
"""
|
|
导入OBJ
|
|
"""
|
|
print("导入OBJ")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="OBJ Files (*.obj);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=1
|
|
)
|
|
if file_path:
|
|
# 这里实现导入OBJ的功能
|
|
print(f"将从{file_path[0]}导入OBJ")
|
|
cmds.file(file_path[0], i=True, type="OBJ", ignoreVersion=True, options="mo=1")
|
|
except Exception as e:
|
|
print(f"导入OBJ时出错: {e}")
|
|
return True
|
|
|
|
# 导出相关功能
|
|
def export_model():
|
|
"""
|
|
导出模型
|
|
"""
|
|
print("导出模型")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="Maya Files (*.ma *.mb);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=2
|
|
)
|
|
if file_path:
|
|
# 这里实现导出模型的功能
|
|
print(f"将模型导出到{file_path[0]}")
|
|
except Exception as e:
|
|
print(f"导出模型时出错: {e}")
|
|
return True
|
|
|
|
def export_fbx():
|
|
"""
|
|
导出 FBX
|
|
"""
|
|
print("导出 FBX")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="FBX Files (*.fbx);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=2
|
|
)
|
|
if file_path:
|
|
# 这里实现导出 FBX的功能
|
|
print(f"将模型导出到{file_path[0]}")
|
|
mel.eval('FBXExportSmoothingGroups -v true;')
|
|
mel.eval('FBXExportHardEdges -v false;')
|
|
mel.eval('FBXExportTangents -v false;')
|
|
mel.eval('FBXExportSmoothMesh -v true;')
|
|
mel.eval('FBXExportInstances -v false;')
|
|
mel.eval('FBXExportReferencedContainersContent -v false;')
|
|
mel.eval('FBXExportBakeComplexAnimation -v false;')
|
|
mel.eval('FBXExportUseSceneName -v false;')
|
|
mel.eval('FBXExportQuaternion -v euler;')
|
|
mel.eval('FBXExportShapes -v true;')
|
|
mel.eval('FBXExportSkins -v true;')
|
|
mel.eval('FBXExportConstraints -v false;')
|
|
mel.eval('FBXExportCameras -v false;')
|
|
mel.eval('FBXExportLights -v false;')
|
|
mel.eval('FBXExportEmbeddedTextures -v false;')
|
|
mel.eval('FBXExportInputConnections -v false;')
|
|
mel.eval('FBXExportUpAxis y;')
|
|
mel.eval(f'FBXExport -f "{file_path[0]}" -s;')
|
|
except Exception as e:
|
|
print(f"导出 FBX时出错: {e}")
|
|
return True
|
|
|
|
def export_obj():
|
|
"""
|
|
导出 OBJ
|
|
"""
|
|
print("导出 OBJ")
|
|
try:
|
|
file_path = cmds.fileDialog2(
|
|
fileFilter="OBJ Files (*.obj);;All Files (*.*)",
|
|
dialogStyle=2,
|
|
fileMode=2
|
|
)
|
|
if file_path:
|
|
# 这里实现导出 OBJ的功能
|
|
print(f"将模型导出到{file_path[0]}")
|
|
cmds.file(file_path[0], force=True, options="groups=1;ptgroups=1;materials=1;smoothing=1;normals=1", type="OBJexport", pr=True, exportSelected=True)
|
|
except Exception as e:
|
|
print(f"导出 OBJ时出错: {e}")
|
|
return True
|
|
|
|
# 工具相关功能
|
|
def check_model():
|
|
"""
|
|
检查模型
|
|
"""
|
|
print("检查模型")
|
|
# 这里实现检查模型的功能
|
|
return True
|
|
|
|
def optimize_model():
|
|
"""
|
|
优化模型
|
|
"""
|
|
print("优化模型")
|
|
# 这里实现优化模型的功能
|
|
return True
|
|
|
|
def clean_model():
|
|
"""
|
|
清理模型
|
|
"""
|
|
print("清理模型")
|
|
# 这里实现清理模型的功能
|
|
return True
|
|
|
|
def uv_tools():
|
|
"""
|
|
UV工具
|
|
"""
|
|
print("UV工具")
|
|
# 这里实现UV工具的功能
|
|
return True
|
|
|
|
# 保留原来的函数作为兼容性考虑
|
|
def geometry_temp_utils_function():
|
|
"""
|
|
Placeholder function for geometry module
|
|
This function will be replaced with actual functionality in future updates
|
|
"""
|
|
print("Geometry module initialized with placeholder function")
|
|
return True |