This commit is contained in:
Jeffreytsai1004 2025-01-20 23:02:49 +08:00
parent f91643cc52
commit 8934fc8db4
68 changed files with 378 additions and 792 deletions

View File

@ -1,80 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/20
"""
import os
import maya.cmds as cmds
def sg_unload_plugin():
"""
卸载当前Maya版本的插件
"""
# 获取Maya版本
version = cmds.about(version=True)
plugin_name = f"SuperRiggingEditor{version}"
# 如果插件已加载,则卸载
if cmds.pluginInfo(plugin_name, query=True, loaded=True):
cmds.unloadPlugin(plugin_name)
def sg_update_plugin():
"""
更新插件文件
从更新文件夹复制新版本插件到对应的插件目录
"""
# 获取更新文件夹路径
sg_path = os.environ.get("SG_PATH")
update_folder = os.path.join(sg_path, "plug-ins-update")
# 检查更新文件夹是否存在
if os.path.exists(update_folder):
# 卸载当前插件
sg_unload_plugin()
# 支持的Maya版本列表
versions = ["2018", "2019", "2020", "2022", "2023", "2024"]
# 处理每个版本的插件
for version in versions:
# 构建路径
update_path = os.path.join(sg_path, "plug-ins-update", version)
target_path = os.path.join(sg_path, "plug-ins", version)
# 获取需要更新的插件文件列表
if os.path.exists(update_path):
plugins = [f for f in os.listdir(update_path) if f.endswith('.mll')]
# 更新每个插件
for plugin in plugins:
new_file = os.path.join(update_path, plugin)
old_file = os.path.join(target_path, plugin)
try:
# 复制新文件到目标位置
if os.path.exists(new_file):
os.replace(old_file, new_file)
print(f"{old_file} update succeeded...")
os.remove(new_file)
except Exception as e:
print(f"{old_file} update failed: {str(e)}")
# 删除空的更新目录
try:
os.rmdir(update_path)
except:
pass
# 删除空的更新主目录
try:
os.rmdir(update_folder)
except:
pass
# 如果直接运行此脚本
if __name__ == '__main__':
sg_update_plugin()

View File

@ -1,9 +0,0 @@
from maya import cmds, mel, utils
def SuperRiggingInstallations():
if not cmds.about(batch=True):
mel.eval("SGUpdatePlugin;")
mel.eval("SGCreateMenuItem;")
mel.eval("SGEnableJointOrient;")
utils.executeDeferred(SuperRiggingInstallations)

View File

@ -1,15 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/16
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_add_blend_shape(target_name):
def add_blend_shape(target_name):
"""
为选中的模型添加混合变形目标
@ -22,16 +17,16 @@ def sg_add_blend_shape(target_name):
for sel in selection:
# 遍历50个可能的网格体
for j in range(50):
mesh = cmds.SGGetMeshes(m=j) # 假设SGGetMeshes是一个自定义命令
mesh = mfc.GetMeshes(m=j) # GetMeshes是一个自定义命令
if sel == mesh:
if target_name:
# 获取混合变形节点名称
blend_shape = cmds.SGGetBlendShape(mesh) # 假设SGGetBlendShape是一个自定义命令
blend_shape = mfc.GetBlendShape(mesh) # GetBlendShape是一个自定义命令
# 如果混合变形节点不存在,创建一个新的
if not cmds.objExists(blend_shape):
blend_shape = cmds.SGGetMeshes(i=j) + "_blendShapes"
blend_shape = mfc.GetMeshes(i=j) + "_blendShapes"
cmds.blendShape(mesh, automatic=True, name=blend_shape)
# 获取权重属性路径

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/20
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_automatic_grouping():
"""
@ -18,7 +13,7 @@ def sg_automatic_grouping():
# 处理head模型的LOD分组
for i in range(8):
# 获取当前LOD级别的网格体索引列表
lod_mesh_indices = cmds.SGGetMeshes(lod=i)
lod_mesh_indices = mfc.GetMeshes(lod=i)
group_name = f"head_lod{i}_grp"
# 如果分组不存在则创建
@ -32,7 +27,7 @@ def sg_automatic_grouping():
continue
# 获取网格体名称
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
# 如果网格体存在,将其放入对应分组
if cmds.objExists(mesh):
@ -52,7 +47,7 @@ def sg_automatic_grouping():
# 遍历处理body的4个LOD级别
for i in range(4):
body_index = 50 + i
mesh = cmds.SGGetMeshes(m=body_index)
mesh = mfc.GetMeshes(m=body_index)
# 如果分组不存在则创建
if not cmds.objExists(body_groups[i]):

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/24
"""
import maya.cmds as cmds
import re
import MetaFusionCore as mfc
def sg_batch_add_blend_shape(lod, meshes):
"""
@ -19,15 +14,15 @@ def sg_batch_add_blend_shape(lod, meshes):
meshes (list): 要处理的网格体名称列表
"""
# 获取指定LOD级别的所有网格体索引
mesh_indices = cmds.SGGetMeshes(lod=lod)
mesh_indices = mfc.GetMeshes(lod=lod)
# 开始进度条
cmds.SGProgressBar(sp=True)
mfc.ProgressBar(sp=True)
for mesh_index in mesh_indices:
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
lod_mesh = cmds.SGGetMeshes(i=mesh_index)
lod_mesh = mfc.GetMeshes(i=mesh_index)
# 使用正则表达式匹配第一个下划线前的内容
head = re.match(r'[^_]+', lod_mesh).group(0)
@ -52,23 +47,23 @@ def sg_batch_add_blend_shape(lod, meshes):
if head in target_count_map:
target_count = target_count_map[head]
count = cmds.SGGetBlendShapes(tc=target_count)
count = mfc.GetBlendShapes(tc=target_count)
# 设置进度条
cmds.SGProgressBar(max=count)
cmds.SGProgressBar(t=f"[{blend_shape}] Creating Target Mesh...")
mfc.ProgressBar(max=count)
mfc.ProgressBar(t=f"[{blend_shape}] Creating Target Mesh...")
# 创建混合变形目标
for index in range(count):
cmds.SGProgressBar(apr=1)
bs_name = cmds.SGGetBlendShapes(bsn=target_count, index=index)
mfc.ProgressBar(apr=1)
bs_name = mfc.GetBlendShapes(bsn=target_count, index=index)
# 复制网格体作为目标
cmds.duplicate(mesh, returnRootsOnly=True, name=bs_name)
# 对LOD0级别的特定模型设置混合变形目标
if lod == 0 and (head in ["head", "teeth", "cartilage"]):
cmds.SGSetBlendShapes(ct=mesh_index, index=index, target=bs_name)
mfc.SetBlendShapes(ct=mesh_index, index=index, target=bs_name)
# 添加混合变形目标
cmds.blendShape(
@ -83,4 +78,4 @@ def sg_batch_add_blend_shape(lod, meshes):
cmds.delete(bs_name)
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/24
"""
import maya.cmds as cmds
import re
import MetaFusionCore as mfc
def sg_batch_del_blend_shape(lod, meshes):
"""
@ -19,15 +14,15 @@ def sg_batch_del_blend_shape(lod, meshes):
meshes (list): 要处理的网格体名称列表
"""
# 获取指定LOD级别的所有网格体索引
mesh_indices = cmds.SGGetMeshes(lod=lod)
mesh_indices = mfc.GetMeshes(lod=lod)
for mesh_index in mesh_indices:
# 获取网格体名称
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取LOD网格体名称
lod_mesh = cmds.SGGetMeshes(i=mesh_index)
lod_mesh = mfc.GetMeshes(i=mesh_index)
# 使用正则表达式匹配第一个下划线前的内容
head = re.match(r'[^_]+', lod_mesh).group(0)

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
def sg_get_orig_name(geo):
"""
@ -60,20 +55,20 @@ def sg_bind_pose_reset(objs):
objs (list): 要处理的模型列表
"""
# 开始进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(max=len(objs))
mfc.ProgressBar(sp=True)
mfc.ProgressBar(max=len(objs))
for obj in objs:
# 更新进度条
cmds.SGProgressBar(t=f"[{obj}] Bind Pose Reset...")
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(t=f"[{obj}] Bind Pose Reset...")
mfc.ProgressBar(apr=1)
# 获取蒙皮变形节点
skin_cluster = mel.eval(f'findRelatedSkinCluster("{obj}")')
if cmds.objExists(skin_cluster):
# 获取混合变形节点
blend_shape = cmds.SGGetBlendShape(obj)
blend_shape = mfc.GetBlendShape(obj)
# 创建临时复制模型
copy_name = cmds.duplicate(obj, name=f"{obj}_CopyTarget", returnRootsOnly=True)
@ -149,4 +144,4 @@ def sg_bind_pose_reset(objs):
cmds.delete(copy_name[0])
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)

View File

@ -1,16 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/26
"""
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
def sg_bind_skin_cluster():
def bind_skin_cluster():
"""
为模型绑定蒙皮变形器
- 处理LOD0到LOD7的所有模型
@ -20,7 +15,7 @@ def sg_bind_skin_cluster():
# 遍历8个LOD级别
for i in range(8):
# 获取当前LOD级别的骨骼列表
joint_lod = cmds.SGGetJoints(lod=i, type="string")
joint_lod = mfc.GetJoints(lod=i, type="string")
# 检查所有骨骼是否存在
exists = True
@ -32,12 +27,12 @@ def sg_bind_skin_cluster():
# 如果所有骨骼都存在处理当前LOD级别的模型
if exists:
# 获取当前LOD级别的模型索引列表
lod_indices = cmds.SGGetMeshes(lod=i)
lod_indices = mfc.GetMeshes(lod=i)
# 遍历处理每个模型
for mesh_index in lod_indices:
# 获取模型名称
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 检查是否已经有蒙皮变形器
@ -45,11 +40,11 @@ def sg_bind_skin_cluster():
if not cmds.objExists(skin_cluster):
# 构建蒙皮变形器名称
name = f"{cmds.SGGetMeshes(i=mesh_index)}_skinCluster"
name = f"{mfc.GetMeshes(i=mesh_index)}_skinCluster"
# 获取影响骨骼和最大影响数
influences = cmds.SGGetJoints(inf=mesh_index)
max_influences = cmds.SGGetJoints(mi=mesh_index)
influences = mfc.GetJoints(inf=mesh_index)
max_influences = mfc.GetJoints(mi=mesh_index)
# 创建蒙皮变形器
cmds.skinCluster(
@ -61,4 +56,4 @@ def sg_bind_skin_cluster():
)
# 执行权重绑定
mel.eval('SGBindSkinClusterWeights')
mel.eval('BindSkinClusterWeights')

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel

View File

@ -1,14 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/10/31
"""
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
import CopySkin
def sg_clothing_weight():
"""
@ -21,8 +17,8 @@ def sg_clothing_weight():
selection = cmds.ls(selection=True)
# 获取头部和身体模型
head = cmds.SGGetMeshes(m=0)
body = cmds.SGGetMeshes(m=50)
head = mfc.GetMeshes(m=0)
body = mfc.GetMeshes(m=50)
# 清除选择并选择身体和目标模型
cmds.select(clear=True)
@ -30,7 +26,7 @@ def sg_clothing_weight():
cmds.select(selection, add=True)
# 执行蒙皮复制
mel.eval('SGCopySkin')
CopySkin.sg_copy_skin()
# 为每个选中的模型复制头部和身体的权重
for obj in selection:

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_copy_meshes(name):
"""
@ -17,7 +12,7 @@ def sg_copy_meshes(name):
name (str): 组名称
"""
# 获取所有需要处理的网格体
meshes = [cmds.SGGetMeshes(m=i) for i in range(9)]
meshes = [mfc.GetMeshes(m=i) for i in range(9)]
# 创建组
if not cmds.objExists(name):
@ -40,7 +35,7 @@ def sg_merge_blend_shape(arkit_list):
arkit_list (list): ARKit表情目标列表
"""
# 获取所有需要处理的网格体
meshes = [cmds.SGGetMeshes(m=i) for i in range(9)]
meshes = [mfc.GetMeshes(m=i) for i in range(9)]
# 处理每个网格体
for mesh in meshes:

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_create_blend_shape():
"""
@ -17,28 +12,28 @@ def sg_create_blend_shape():
- 显示进度条指示创建进度
"""
# 开始进度条
cmds.SGProgressBar(sp=True)
mfc.ProgressBar(sp=True)
# 遍历处理每个模型
for mesh_index in range(50):
# 获取模型名称
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取混合变形节点名称
blend_shape = cmds.SGGetBlendShape(mesh)
blend_shape = mfc.GetBlendShape(mesh)
# 获取目标数量
count = cmds.SGGetBlendShapes(dr="r", tc=mesh_index)
count = mfc.GetBlendShapes(dr="r", tc=mesh_index)
# 如果没有混合变形节点且有目标需要创建
if not cmds.objExists(blend_shape) and count > 0:
# 构建混合变形节点名称
blend_shape_name = f"{cmds.SGGetMeshes(i=mesh_index)}_blendShapes"
blend_shape_name = f"{mfc.GetMeshes(i=mesh_index)}_blendShapes"
# 设置进度条
cmds.SGProgressBar(max=count)
cmds.SGProgressBar(t=f"[{blend_shape_name}] Creating Target Mesh...")
mfc.ProgressBar(max=count)
mfc.ProgressBar(t=f"[{blend_shape_name}] Creating Target Mesh...")
# 创建混合变形节点
cmds.blendShape(mesh, name=blend_shape_name)
@ -46,16 +41,16 @@ def sg_create_blend_shape():
# 创建每个目标
for index in range(count):
# 更新进度条
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 获取目标名称
bs_name = cmds.SGGetBlendShapes(dr="r", bsn=(mesh_index, index))
bs_name = mfc.GetBlendShapes(dr="r", bsn=(mesh_index, index))
# 复制模型作为目标
cmds.duplicate(mesh, returnRootsOnly=True, name=bs_name)
# 设置混合变形目标
cmds.SGSetBlendShapes(ct=mesh_index, index=index, target=bs_name)
mfc.SetBlendShapes(ct=mesh_index, index=index, target=bs_name)
# 添加到混合变形节点
cmds.blendShape(
@ -70,4 +65,4 @@ def sg_create_blend_shape():
cmds.delete(bs_name)
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import imp
import maya.cmds as cmds
@ -18,7 +12,7 @@ def sg_create_body_ctrl():
- 动态加载身体控制器模块
"""
# 获取环境变量中的路径
path = os.environ.get('SG_PATH')
path = os.environ.get('PATH')
# 构建模块路径
module_path = os.path.join(path, 'files/meta_body_ctrl/meta_body_ctrl.py')

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_create_lod(index):
"""
@ -45,13 +40,13 @@ def sg_create_lod(index):
if not cmds.objExists(head_mesh):
# 创建LOD网格体
cmds.SGGetMeshes(cml=index)
head_lod = cmds.SGGetMeshes(lod=0)
create_lod = cmds.SGGetMeshes(lod=index)
mfc.GetMeshes(cml=index)
head_lod = mfc.GetMeshes(lod=0)
create_lod = mfc.GetMeshes(lod=index)
# 处理每个创建的LOD模型
for c in create_lod:
create = cmds.SGGetMeshes(i=c)
create = mfc.GetMeshes(i=c)
# 跳过索引大于等于50的模型
if c >= 50:
@ -65,7 +60,7 @@ def sg_create_lod(index):
continue
if any(create.startswith(mesh) for mesh in meshes[:h+1]):
mesh = cmds.SGGetMeshes(m=h)
mesh = mfc.GetMeshes(m=h)
if cmds.objExists(mesh):
# 处理模型
cmds.parent(create, head_grp)
@ -103,10 +98,10 @@ def sg_create_lod(index):
cmds.group(empty=True, name=body_grp)
if not cmds.objExists(body_mesh):
mesh = cmds.SGGetMeshes(m=50)
mesh = mfc.GetMeshes(m=50)
if cmds.objExists(mesh):
body_index = 50 + index
cmds.SGGetMeshes(cm=body_index)
mfc.GetMeshes(cm=body_index)
cmds.parent(body_mesh, body_grp)
# 获取UV集

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel
@ -21,7 +15,7 @@ def sg_create_menu_item():
# 创建主菜单
cmds.menu(
"SG_MENU",
"MENU",
tearOff=True,
label="SuperRigging",
parent="MayaWindow"
@ -29,7 +23,7 @@ def sg_create_menu_item():
# 添加Super Rigging菜单项
cmds.menuItem(
"SG_Editor",
"Editor",
label="Super Rigging",
image=logo,
command="execute_super_rigging()"
@ -37,7 +31,7 @@ def sg_create_menu_item():
# 添加Pose Wrangler菜单项
cmds.menuItem(
"SG_PoseWrangler",
"PoseWrangler",
label="Pose Wrangler",
image=icon,
command="execute_pose_wrangler()"
@ -45,16 +39,16 @@ def sg_create_menu_item():
def execute_super_rigging():
"""
执行Super Rigging功能
执行MetaFusion功能
- 加载必要的插件
- 打开Super Rigging窗口
- 打开MetaFusion窗口
"""
# 获取Maya版本
version = cmds.about(version=True)
# 需要加载的插件列表
plugins = [
f"SuperRiggingEditor{version}",
f"MetaFusionEditor{version}",
f"MayaUE4RBFPlugin{version}",
"embeddedRL4",
"MayaUERBFPlugin",
@ -70,8 +64,8 @@ def execute_super_rigging():
except:
pass
# 打开Super Rigging窗口
mel.eval("SuperRiggingWindow;")
# 打开MetaFusion窗口
mel.eval("MetaFusionWindow;")
def execute_pose_wrangler():
"""

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
def sg_create_rl4_node(dna, name):
"""
@ -19,17 +14,17 @@ def sg_create_rl4_node(dna, name):
name (str): 节点名称
"""
# 删除现有的RL4节点
mel.eval('SGDeleteRL4Node')
mel.eval('DeleteRL4Node')
# 重置所有关节的颜色
joints = cmds.SGGetJoints()
joints = mfc.GetJoints()
for joint in joints:
cmds.SGSetColor(joint, 0, 0, 0, 0, 0, 0)
mfc.SetColor(joint, 0, 0, 0, 0, 0, 0)
# 查找有效的LOD级别
lod = None
for i in range(8):
joint_lod = cmds.SGGetJoints(lod=i, type="string")
joint_lod = mfc.GetJoints(lod=i, type="string")
exists = True
# 检查所有关节是否存在
@ -43,7 +38,7 @@ def sg_create_rl4_node(dna, name):
break
# 修复LOD 0的关节
mel.eval('SGRepairJointForLOD 0')
mel.eval('RepairJointForLOD 0')
# 设置命名空间和属性路径
if cmds.namespace(exists="DHIhead"):
@ -67,4 +62,4 @@ def sg_create_rl4_node(dna, name):
)
# 删除指定LOD级别的关节
mel.eval(f'SGDeleteJointForLOD {lod}')
mel.eval(f'DeleteJointForLOD {lod}')

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/04
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_current_project_dna():
"""
@ -24,7 +19,7 @@ def sg_current_project_dna():
return
# 获取当前项目DNA路径
pre_path = cmds.SGDescriptor(gpd=True)
pre_path = mfc.Descriptor(gpd=True)
# 检查每个RL4节点
for node in rl4_nodes:
@ -33,4 +28,4 @@ def sg_current_project_dna():
# 如果文件存在且与当前路径不同则更新项目DNA路径
if cmds.file(rl4_path, query=True, exists=True) and rl4_path != pre_path:
cmds.SGDescriptor(spd=rl4_path)
mfc.Descriptor(spd=rl4_path)

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/02/23
"""
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
def sg_define_joint_for_lod(lod):
"""
@ -44,20 +39,20 @@ def sg_define_joint_for_lod(lod):
cmds.delete(rl4_nodes)
# 修复LOD 0的关节
mel.eval('SGRepairJointForLOD 0')
mel.eval('RepairJointForLOD 0')
# 如果存在RL4节点重新创建
if exists:
dna = cmds.SGDescriptor(wd=True)
dna = mfc.Descriptor(wd=True)
if cmds.file(dna, query=True, exists=True):
name = f"rl4Embedded_{cmds.SGDescriptor(n=True)}_rl"
mel.eval(f'SGCreateRL4Node "{dna}" "{name}"')
name = f"rl4Embedded_{mfc.Descriptor(n=True)}_rl"
mel.eval(f'CreateRL4Node "{dna}" "{name}"')
# 处理蒙皮和关节
mel.eval('SGFastUnbindSkinCluster')
mel.eval(f'SGRepairJointForLOD {lod}')
mel.eval(f'SGDeleteJointForLOD {lod}')
mel.eval('SGFastBindSkinCluster')
mel.eval('FastUnbindSkinCluster')
mel.eval(f'RepairJointForLOD {lod}')
mel.eval(f'DeleteJointForLOD {lod}')
mel.eval('FastBindSkinCluster')
def _get_control_list():
"""

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/16
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_del_blend_shape(mesh_index, in_tgt_grp):
"""
@ -18,7 +13,7 @@ def sg_del_blend_shape(mesh_index, in_tgt_grp):
in_tgt_grp (int): 目标组索引
"""
# 获取混合变形节点名称
bsn = f"{cmds.SGGetMeshes(i=mesh_index)}_blendShapes"
bsn = f"{mfc.GetMeshes(i=mesh_index)}_blendShapes"
# 检查节点是否存在
if not cmds.objExists(bsn):

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/02/23
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_delete_joint_for_lod(lod):
"""
@ -17,8 +12,8 @@ def sg_delete_joint_for_lod(lod):
lod (int): LOD级别
"""
# 获取所有关节和指定LOD级别的关节
joint_all = cmds.SGGetJoints(lod=0, type="string")
joint_lod = cmds.SGGetJoints(lod=lod, type="string")
joint_all = mfc.GetJoints(lod=0, type="string")
joint_lod = mfc.GetJoints(lod=lod, type="string")
# 找出需要删除的关节在所有关节中但不在指定LOD级别中的关节
joint_del = list(set(joint_all) - set(joint_lod))

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_delete_rl4_node():

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import maya.cmds as cmds
@ -28,7 +22,7 @@ def sg_demo_help(help_name):
)
# 获取环境变量中的路径
path = os.environ.get('SG_PATH')
path = os.environ.get('PATH')
image_path = os.path.join(path, 'images', 'ARKit', f'{help_name}.png')
# 创建布局

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_duplicate_target(target, index):
"""
@ -18,7 +13,7 @@ def sg_duplicate_target(target, index):
index (int): 目标索引用于确定位置
"""
# 获取头部模型
head = cmds.SGGetMeshes(m=0)
head = mfc.GetMeshes(m=0)
# 创建根目标组
root_targets_grp = "root_targets_grp"
@ -28,7 +23,7 @@ def sg_duplicate_target(target, index):
# 处理每个网格
for i in range(9):
# 获取部署网格名称
meshe_deploy = cmds.SGGetMeshes(i=i)
meshe_deploy = mfc.GetMeshes(i=i)
# 获取混合变形节点名称
blend_shape = f"{meshe_deploy}_blendShapes"
@ -49,7 +44,7 @@ def sg_duplicate_target(target, index):
continue
# 获取网格和目标名称
meshe = cmds.SGGetMeshes(m=i)
meshe = mfc.GetMeshes(m=i)
meshe_target = f"{meshe_deploy}_{target}"
# 复制网格

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_edit_blend_shape(index, blend_shape):

View File

@ -1,15 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
# 配置常量
JOINT_ORIENT_CONFIG = {
@ -265,7 +260,7 @@ def get_ui_labels():
"""
根据语言设置获取UI标签
"""
is_chinese = cmds.SGDescriptor(l=True) == "ZH"
is_chinese = mfc.Descriptor(l=True) == "ZH"
if is_chinese:
return {
@ -311,16 +306,16 @@ def sg_main_amend_axis():
joints = sg_body_joints()
# 创建进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(max=len(joints))
cmds.SGProgressBar(t="Amend Joint Axis...")
mfc.ProgressBar(sp=True)
mfc.ProgressBar(max=len(joints))
mfc.ProgressBar(t="Amend Joint Axis...")
# 处理每个关节
for joint in joints:
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 获取关节类型
joint_type = cmds.SGReadJson(d=joint, k="type", t="string")
joint_type = mfc.ReadJson(d=joint, k="type", t="string")
# 获取关节名称
joint_drv = f"{joint}_drv"
@ -354,7 +349,7 @@ def sg_main_amend_axis():
cmds.setAttr(f"{joint_body}.jo", *drv_rot)
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
def sg_skin_amend_axis():
"""
@ -364,13 +359,13 @@ def sg_skin_amend_axis():
joints = sg_body_joints()
# 创建进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(max=len(joints))
cmds.SGProgressBar(t="Amend Skin Joint Axis...")
mfc.ProgressBar(sp=True)
mfc.ProgressBar(max=len(joints))
mfc.ProgressBar(t="Amend Skin Joint Axis...")
# 处理每个关节
for joint in joints:
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 获取关节名称
joint_drv = f"{joint}_drv"
@ -390,7 +385,7 @@ def sg_skin_amend_axis():
cmds.joint(joint_head, edit=True, orientJoint="none")
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
def sg_other_amend_axis(joints):
"""
@ -518,29 +513,29 @@ def sg_orient(joints, aim_axis, up_axis, up_dir, do_auto):
up_dir (list): 向上方向
do_auto (bool): 是否自动处理
"""
# 这个函数的具体实现需要根据原MEL脚本中的SGOrient函数来完成
# 这个函数的具体实现需要根据原MEL脚本中的Orient函数来完成
pass
def sg_body_joints():
"""
获取身体关节列表
"""
return cmds.SGGetJoints(bj=True)
return mfc.GetJoints(bj=True)
def sg_body_joints_locator():
"""
创建身体关节定位器
"""
# 获取JSON文件路径
json_path = os.path.join(os.environ.get('SG_PATH'), "files/data/BodyJoints.json")
json_path = os.path.join(os.environ.get('PATH'), "files/data/BodyJoints.json")
# 读取对象数据
objects = cmds.SGReadJson(f=json_path, t="object")
objects = mfc.ReadJson(f=json_path, t="object")
if not objects:
return
# 创建进度条
cmds.SGProgressBar(sp=True)
mfc.ProgressBar(sp=True)
# 创建临时定位器
locator = "MetaHumanLocatorTemp"
@ -548,11 +543,11 @@ def sg_body_joints_locator():
cmds.spaceLocator(name=locator)
# 设置进度条最大值
cmds.SGProgressBar(max=len(objects))
cmds.SGProgressBar(t="Set Body Joint Translation...")
mfc.ProgressBar(max=len(objects))
mfc.ProgressBar(t="Set Body Joint Translation...")
# 获取中性关节位置
positions = cmds.SGGetNeutralJointTranslations(b=True)
positions = mfc.GetNeutralJointTranslations(b=True)
# 检查数据数量
if len(objects) != len(positions) // 3:
@ -561,15 +556,15 @@ def sg_body_joints_locator():
# 处理每个关节
for i, obj in enumerate(objects):
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 获取关节和类型信息
joints = cmds.SGReadJson(d=obj, k="joint", t="string")
joint_type = cmds.SGReadJson(d=obj, k="type", t="string")
joints = mfc.ReadJson(d=obj, k="joint", t="string")
joint_type = mfc.ReadJson(d=obj, k="type", t="string")
joint_drv = f"{joints[0]}_drv"
# 检查是否需要定位
locate = cmds.SGReadJson(d=obj, k="locate", t="bool")
locate = mfc.ReadJson(d=obj, k="locate", t="bool")
if locate[0] and cmds.objExists(joint_drv):
# 设置位置
x = 0.0 if joint_type[0] == "middle" else positions[i*3]
@ -580,8 +575,8 @@ def sg_body_joints_locator():
cmds.delete(cmds.pointConstraint(locator, joint_drv, weight=1))
# 重置进度条
cmds.SGProgressBar(pr=0)
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(pr=0)
mfc.ProgressBar(ep=True)
# 删除临时定位器
cmds.delete(locator)

View File

@ -1,15 +1,10 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/01
"""
import os
import maya.cmds as cmds
import maya.mel as mel
import MetaFusionCore as mfc
def sg_export_fbx_window():
"""
@ -120,7 +115,7 @@ def sg_export_fbx_window():
def get_ui_labels():
"""获取UI标签"""
is_chinese = cmds.SGDescriptor(l=True) == "ZH"
is_chinese = mfc.Descriptor(l=True) == "ZH"
if is_chinese:
return {
@ -192,7 +187,7 @@ def sg_export_head_command():
return
# 重命名混合变形
mel.eval('SGRenameBlendShapes')
mel.eval('RenameBlendShapes')
# 获取LOD选择状态
lods = []
@ -206,8 +201,8 @@ def sg_export_head_command():
if is_selected:
export_grp = f"head_lod{i}_grp"
if cmds.ls(export_grp, dag=True, geometry=True):
path = cmds.SGDescriptor(p=True)
name = cmds.SGDescriptor(n=True)
path = mfc.Descriptor(p=True)
name = mfc.Descriptor(n=True)
file_path = f"{path}/{name}_lod{i}_head.fbx"
cmds.select(clear=True)
@ -218,10 +213,10 @@ def sg_export_head_command():
cmds.error(f'"{export_grp}" No geometry found within the group...')
# 重置混合变形
mel.eval('SGResetBlendShapes')
mel.eval('ResetBlendShapes')
# 打开输出文件夹
folder_path = cmds.SGDescriptor(p=True).replace('/', '\\')
folder_path = mfc.Descriptor(p=True).replace('/', '\\')
os.system(f'explorer "{folder_path}"')
def sg_export_select_head_command():
@ -242,23 +237,23 @@ def sg_export_select_head_command():
return
# 重命名混合变形
mel.eval('SGRenameBlendShapes')
mel.eval('RenameBlendShapes')
# 导出选中物体
cmds.select(clear=True)
cmds.select(selection, replace=True)
cmds.select('DHIhead:root', add=True)
path = cmds.SGDescriptor(p=True)
name = cmds.SGDescriptor(n=True)
path = mfc.Descriptor(p=True)
name = mfc.Descriptor(n=True)
file_path = f"{path}/{name}_lod_head.fbx"
sg_export_fbx(file_path)
# 重置混合变形
mel.eval('SGResetBlendShapes')
mel.eval('ResetBlendShapes')
# 打开输出文件夹
folder_path = cmds.SGDescriptor(p=True).replace('/', '\\')
folder_path = mfc.Descriptor(p=True).replace('/', '\\')
os.system(f'explorer "{folder_path}"')
def sg_export_body_command():
@ -282,8 +277,8 @@ def sg_export_body_command():
if is_selected:
export_grp = f"body_lod{i}_grp"
if cmds.ls(export_grp, dag=True, geometry=True):
path = cmds.SGDescriptor(p=True)
name = cmds.SGDescriptor(n=True)
path = mfc.Descriptor(p=True)
name = mfc.Descriptor(n=True)
file_path = f"{path}/{name}_lod{i}_body.fbx"
cmds.select(clear=True)
@ -294,7 +289,7 @@ def sg_export_body_command():
cmds.error(f'"{export_grp}" No geometry found within the group...')
# 打开输出文件夹
folder_path = cmds.SGDescriptor(p=True).replace('/', '\\')
folder_path = mfc.Descriptor(p=True).replace('/', '\\')
os.system(f'explorer "{folder_path}"')
def sg_export_select_body_command():
@ -319,11 +314,11 @@ def sg_export_select_body_command():
cmds.select(selection, replace=True)
cmds.select('DHIbody:root', add=True)
path = cmds.SGDescriptor(p=True)
name = cmds.SGDescriptor(n=True)
path = mfc.Descriptor(p=True)
name = mfc.Descriptor(n=True)
file_path = f"{path}/{name}_lod_body.fbx"
sg_export_fbx(file_path)
# 打开输出文件夹
folder_path = cmds.SGDescriptor(p=True).replace('/', '\\')
folder_path = mfc.Descriptor(p=True).replace('/', '\\')
os.system(f'explorer "{folder_path}"')

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_export_skin_cluster():
"""
@ -34,4 +29,5 @@ def sg_export_skin_cluster():
# 构建保存路径
save_path = f"{directory[0]}/{obj}{suffix}"
# 导出权重
cmds.SGSkinCluster(ef=obj, export_file=save_path)
mfc.SkinCluster(ef=obj, export_file=save_path)

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/26
"""
import os
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_fast_bind_skin_cluster():
"""
@ -20,14 +15,14 @@ def sg_fast_bind_skin_cluster():
# 遍历所有网格0-53
for i in range(54):
# 获取网格名称
mesh = cmds.SGGetMeshes(m=i)
mesh = mfc.GetMeshes(m=i)
# 检查网格是否存在
if not cmds.objExists(mesh):
continue
# 获取蒙皮权重文件路径
path = os.path.join(cmds.SGDescriptor(p=True), "skin_buffer")
path = os.path.join(mfc.Descriptor(p=True), "skin_buffer")
# 检查路径是否存在
if not os.path.exists(path):
@ -52,6 +47,6 @@ def sg_fast_bind_skin_cluster():
# 导入蒙皮权重
try:
cmds.SGSkinCluster(mesh, import_file=skin_file_path)
mfc.SkinCluster(mesh, import_file=skin_file_path)
except:
pass # 忽略导入错误

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/26
"""
import os
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_fast_unbind_skin_cluster():
"""
@ -20,7 +15,7 @@ def sg_fast_unbind_skin_cluster():
# 遍历所有网格0-53
for i in range(54):
# 获取网格名称
mesh = cmds.SGGetMeshes(m=i)
mesh = mfc.GetMeshes(m=i)
# 检查网格是否存在
if not cmds.objExists(mesh):
@ -32,7 +27,7 @@ def sg_fast_unbind_skin_cluster():
# 如果存在蒙皮变形器
if cmds.objExists(skin_cluster):
# 构建保存路径
path = os.path.join(cmds.SGDescriptor(p=True), "skin_buffer")
path = os.path.join(mfc.Descriptor(p=True), "skin_buffer")
skin_file = os.path.join(path, f"{mesh}.skin")
# 如果目录不存在则创建
@ -40,7 +35,7 @@ def sg_fast_unbind_skin_cluster():
os.makedirs(path)
# 导出蒙皮权重
cmds.SGSkinCluster(ef=mesh, export_file=skin_file)
mfc.SkinCluster(ef=mesh, export_file=skin_file)
# 解除蒙皮绑定
cmds.skinCluster(mesh, edit=True, unbind=True)

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_get_blend_shape(mesh):

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 清泉时代科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import maya.cmds as cmds
@ -28,7 +22,7 @@ def sg_help(help_name):
)
# 获取环境变量中的路径
path = os.environ.get('SG_PATH')
path = os.environ.get('PATH')
image_path = os.path.join(path, 'images', 'help', f'{help_name}.jpg')
# 创建布局

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import imp
import maya.cmds as cmds
@ -15,7 +9,7 @@ def sg_import_body_anim():
"""
导入身体动画数据
"""
path = os.getenv('SG_PATH')
path = os.getenv('PATH')
meta_anim_path = os.path.join(path, 'files/meta_anim/meta_body_anim.py')
# 使用imp模块导入动画脚本

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import imp
import maya.cmds as cmds
@ -15,7 +9,7 @@ def sg_import_face_anim():
"""
导入面部动画数据
"""
path = os.getenv('SG_PATH')
path = os.getenv('PATH')
meta_anim_path = os.path.join(path, 'files/meta_anim/meta_face_anim.py')
# 使用imp模块导入动画脚本

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_import_skin_cluster():
"""
@ -34,7 +29,7 @@ def sg_import_skin_cluster():
# 处理单个选中物体的情况
if len(selection) == 1:
cmds.SGSkinCluster(selection[0], skin_files[0], if_=True)
mfc.SkinCluster(selection[0], skin_files[0], if_=True)
else:
# 处理多个文件的情况
for skin_file in skin_files:
@ -48,7 +43,7 @@ def sg_import_skin_cluster():
skin_cluster = cmds.findRelatedSkinCluster(mesh_name)
if not skin_cluster:
# 导入权重数据
cmds.SGSkinCluster(mesh_name, skin_file, if_=True)
mfc.SkinCluster(mesh_name, skin_file, if_=True)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_meshe_detach(topology):

View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import maya.cmds as cmds

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import os
import imp
import maya.cmds as cmds
@ -15,7 +9,7 @@ def sg_motion_apply():
"""
导入动作应用模块
"""
path = os.getenv('SG_PATH')
path = os.getenv('PATH')
meta_motion_path = os.path.join(path, 'files/meta_motion_apply/meta_motion_apply.py')
# 使用imp模块导入动作应用脚本

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/04/17
"""
import os
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_pose(pose):
"""
@ -50,13 +45,13 @@ def sg_pose(pose):
cmds.parent(locator, locator_grp)
# 读取关节数据
json_file = os.path.join(os.getenv("SG_PATH"), "files/data/BodyJoints.json")
objects = cmds.SGReadJson(f=json_file, t="object")
json_file = os.path.join(os.getenv("PATH"), "files/data/BodyJoints.json")
objects = mfc.ReadJson(f=json_file, t="object")
for obj in objects:
joint_name = cmds.SGReadJson(d=obj, k="joint", t="string")[0]
joint_name = mfc.ReadJson(d=obj, k="joint", t="string")[0]
if joint_name in pose_joints:
pos = cmds.SGReadJson(d=obj, k=pose, t="double")
pos = mfc.ReadJson(d=obj, k=pose, t="double")
joint_drv = f"{joint_name}_drv"
# 创建并删除父约束以获取位置
@ -99,13 +94,13 @@ def sg_pose(pose):
meshes = []
for index in mesh_indices:
mesh = cmds.SGGetMeshes(m=index)
mesh = mfc.GetMeshes(m=index)
if cmds.objExists(mesh):
meshes.append(mesh)
# 执行轴向修正和重置绑定姿势
cmds.SGSkinAmendAxis()
cmds.SGBindPoseReset(meshes)
mfc.SkinAmendAxis()
mfc.BindPoseReset(meshes)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,14 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/04/08
"""
import maya.cmds as cmds
import math
import MetaFusionCore as mfc
def sg_presets_settings():
"""
@ -23,7 +18,7 @@ def sg_presets_settings():
cmds.deleteUI('presetsSettingsWin')
# 获取关节信息文件路径
json_file = cmds.SGDescriptor(ti="jointsInfo")
json_file = mfc.Descriptor(ti="jointsInfo")
# 创建窗口
window = cmds.window('presetsSettingsWin',
@ -50,27 +45,27 @@ def sg_presets_settings():
# 左侧按钮
cmds.button(label="Select Head Vertexs", align="center",
command="cmds.SGSelectVertexs(0, 'head')")
command="mfc.SelectVertexs(0, 'head')")
cmds.button(label="Save Head Vertexs", align="center",
command="cmds.SGSaveVertexs(0, 'head')")
command="mfc.SaveVertexs(0, 'head')")
cmds.separator(height=10, style="in")
cmds.button(label="Select Teeth Vertexs", align="center",
command="cmds.SGSelectVertexs(1, 'teeth')")
command="mfc.SelectVertexs(1, 'teeth')")
cmds.button(label="Save Teeth Vertexs", align="center",
command="cmds.SGSaveVertexs(1, 'teeth')")
command="mfc.SaveVertexs(1, 'teeth')")
cmds.separator(height=10, style="in")
cmds.button(label="Select EyeLeft Vertexs", align="center",
command="cmds.SGSelectVertexs(3, 'eyeLeft')")
command="mfc.SelectVertexs(3, 'eyeLeft')")
cmds.button(label="Save EyeLeft Vertexs", align="center",
command="cmds.SGSaveVertexs(3, 'eyeLeft')")
command="mfc.SaveVertexs(3, 'eyeLeft')")
cmds.separator(height=10, style="in")
cmds.button(label="Select EyeRight Vertexs", align="center",
command="cmds.SGSelectVertexs(4, 'eyeRight')")
command="mfc.SelectVertexs(4, 'eyeRight')")
cmds.button(label="Save EyeRight Vertexs", align="center",
command="cmds.SGSaveVertexs(4, 'eyeRight')")
command="mfc.SaveVertexs(4, 'eyeRight')")
cmds.setParent('..')
# 右侧列布局
@ -82,27 +77,27 @@ def sg_presets_settings():
# 右侧按钮
cmds.button(label="Select Body Vertexs", align="center",
command="cmds.SGSelectVertexs(50, 'body')")
command="mfc.SelectVertexs(50, 'body')")
cmds.button(label="Save Body Vertexs", align="center",
command="cmds.SGSaveVertexs(50, 'body')")
command="mfc.SaveVertexs(50, 'body')")
cmds.separator(height=10, style="in")
cmds.button(label="Select Neck Vertexs", align="center",
command="cmds.SGSelectVertexs(0, 'neck')")
command="mfc.SelectVertexs(0, 'neck')")
cmds.button(label="Save Neck Vertexs", align="center",
command="cmds.SGSaveVertexs(0, 'neck')")
command="mfc.SaveVertexs(0, 'neck')")
cmds.separator(height=10, style="in")
cmds.button(label="Select HeadEye Vertexs", align="center",
command="cmds.SGSelectVertexs(0, 'headEye')")
command="mfc.SelectVertexs(0, 'headEye')")
cmds.button(label="Save HeadEye Vertexs", align="center",
command="cmds.SGSaveVertexs(0, 'headEye')")
command="mfc.SaveVertexs(0, 'headEye')")
cmds.separator(height=10, style="in")
cmds.button(label="Select HeadMouth Vertexs", align="center",
command="cmds.SGSelectVertexs(0, 'headMouth')")
command="mfc.SelectVertexs(0, 'headMouth')")
cmds.button(label="Save HeadMouth Vertexs", align="center",
command="cmds.SGSaveVertexs(0, 'headMouth')")
command="mfc.SaveVertexs(0, 'headMouth')")
cmds.setParent('..')
# 底部列布局
@ -114,14 +109,14 @@ def sg_presets_settings():
cmds.separator(height=10, style="in")
cmds.button(label="The Closest Point Of The Head", align="center",
command="cmds.SGGetClosestPointOnMesh(0)")
command="mfc.GetClosestPointOnMesh(0)")
cmds.button(label="The Closest Point Of The Body", align="center",
command="cmds.SGGetClosestPointOnMesh(50)")
command="mfc.GetClosestPointOnMesh(50)")
cmds.button(label="The Closest Point Of The Teeth", align="center",
command="cmds.SGGetClosestPointOnMesh(1)")
command="mfc.GetClosestPointOnMesh(1)")
cmds.separator(height=10, style="in")
cmds.button(label="Write Joints Default Position", align="center",
command="cmds.SGWriteJointsDefaultPosition()")
command="mfc.WriteJointsDefaultPosition()")
cmds.separator(height=10, style="in")
cmds.setParent('..')
@ -152,9 +147,9 @@ def sg_select_vertexs(mesh_index, region):
mesh_index: 网格索引
region: 区域名称
"""
open_file = cmds.SGDescriptor(ti="vertexsInfo")
mesh = cmds.SGGetMeshes(m=mesh_index)
vertexs = cmds.SGReadJson(f=open_file, k=region, t="int")
open_file = mfc.Descriptor(ti="vertexsInfo")
mesh = mfc.GetMeshes(m=mesh_index)
vertexs = mfc.ReadJson(f=open_file, k=region, t="int")
cmds.select(cl=True)
for vertex in vertexs:
@ -167,8 +162,8 @@ def sg_save_vertexs(mesh_index, region):
mesh_index: 网格索引
region: 区域名称
"""
json_file = cmds.SGDescriptor(ti="vertexsInfo")
mesh = cmds.SGGetMeshes(m=mesh_index)
json_file = mfc.Descriptor(ti="vertexsInfo")
mesh = mfc.GetMeshes(m=mesh_index)
selection = cmds.ls(sl=True, fl=True)
indices = []
@ -179,7 +174,7 @@ def sg_save_vertexs(mesh_index, region):
return
indices.append(int(vertex_id.strip('vtx[]')))
cmds.SGWriteJson(of=json_file, sf=json_file, k=region, t="int", value=indices)
mfc.WriteJson(of=json_file, sf=json_file, k=region, t="int", value=indices)
def sg_get_closest_point_on_mesh(mesh_index):
"""
@ -187,22 +182,22 @@ def sg_get_closest_point_on_mesh(mesh_index):
Args:
mesh_index: 网格索引
"""
open_file = cmds.SGDescriptor(ti="jointsInfo")
mesh = cmds.SGGetMeshes(m=mesh_index)
open_file = mfc.Descriptor(ti="jointsInfo")
mesh = mfc.GetMeshes(m=mesh_index)
closest_point_node = cmds.createNode('closestPointOnMesh')
cmds.connectAttr(f"{mesh}.worldMesh[0]", f"{closest_point_node}.inMesh", f=True)
key = "head" if mesh_index != 50 else "body"
cmds.select(cl=True)
objects = cmds.SGReadJson(f=open_file, k=key, t="object")
objects = mfc.ReadJson(f=open_file, k=key, t="object")
for obj in objects:
joint_name = cmds.SGReadJson(d=obj, k="joint", t="string")[0]
joint_name = mfc.ReadJson(d=obj, k="joint", t="string")[0]
if mesh_index in [0, 1]:
joint = f"DHIhead:{joint_name}"
index = cmds.SGReadJson(d=obj, k="mesh", t="int")[0]
index = mfc.ReadJson(d=obj, k="mesh", t="int")[0]
if index == mesh_index:
point_position = cmds.xform(joint, q=True, ws=True, t=True)
cmds.setAttr(f"{closest_point_node}.inPosition", *point_position)
@ -210,7 +205,7 @@ def sg_get_closest_point_on_mesh(mesh_index):
cmds.select(f"{mesh}.vtx[{closest_vertex_index}]", add=True)
else:
joint = f"{joint_name}_drv"
enable = cmds.SGReadJson(d=obj, k="enable", t="bool")[0]
enable = mfc.ReadJson(d=obj, k="enable", t="bool")[0]
if enable:
point_position = cmds.xform(joint, q=True, ws=True, t=True)
cmds.setAttr(f"{closest_point_node}.inPosition", *point_position)
@ -223,37 +218,37 @@ def sg_write_joints_default_position():
"""
写入关节默认位置
"""
json_file = cmds.SGDescriptor(ti="jointsInfo")
json_file = mfc.Descriptor(ti="jointsInfo")
# 处理身体关节
object_body = cmds.SGReadJson(f=json_file, k="body", t="object")
object_body = mfc.ReadJson(f=json_file, k="body", t="object")
for i, obj in enumerate(object_body):
joint_name = cmds.SGReadJson(d=obj, k="joint", t="string")[0]
joint_name = mfc.ReadJson(d=obj, k="joint", t="string")[0]
joint = f"{joint_name}_drv"
pos = cmds.xform(joint, q=True, ws=True, t=True)
# 四舍五入到小数点后4位
pos = [round(x * 10000) / 10000 for x in pos]
data = cmds.SGWriteJson(d=obj, sf="data", k="translate", t="double", value=pos)
data = mfc.WriteJson(d=obj, sf="data", k="translate", t="double", value=pos)
object_body[i] = data
cmds.SGWriteJson(of=json_file, sf=json_file, k="body", t="object", value=object_body)
mfc.WriteJson(of=json_file, sf=json_file, k="body", t="object", value=object_body)
# 处理头部关节
object_head = cmds.SGReadJson(f=json_file, k="head", t="object")
object_head = mfc.ReadJson(f=json_file, k="head", t="object")
for i, obj in enumerate(object_head):
joint_name = cmds.SGReadJson(d=obj, k="joint", t="string")[0]
joint_name = mfc.ReadJson(d=obj, k="joint", t="string")[0]
joint = f"DHIhead:{joint_name}"
pos = cmds.xform(joint, q=True, ws=True, t=True)
# 四舍五入到小数点后4位
pos = [round(x * 10000) / 10000 for x in pos]
data = cmds.SGWriteJson(d=obj, sf="data", k="translate", t="double", value=pos)
data = mfc.WriteJson(d=obj, sf="data", k="translate", t="double", value=pos)
object_head[i] = data
cmds.SGWriteJson(of=json_file, sf=json_file, k="head", t="object", value=object_head)
mfc.WriteJson(of=json_file, sf=json_file, k="head", t="object", value=object_head)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/11/18
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_rbf_deformer_window():
"""
@ -31,7 +26,7 @@ def sg_rbf_deformer_window():
'Execute': 'Execute'
}
if cmds.SGDescriptor(l=True) == "ZH":
if mfc.Descriptor(l=True) == "ZH":
texts.update({
'Load': '加载...',
'Original': '原始模型:',
@ -148,7 +143,7 @@ def sg_rbf_deformer_execute(*args):
selection = cmds.ls(selection=True)
# 执行RBF变形
cmds.SGRBFDeformer(r=radius, np=points, rbf=1, m=[original, deformed], t=selection)
mfc.RBFDeformer(r=radius, np=points, rbf=1, m=[original, deformed], t=selection)
def sg_rbf_deformer_load_original(*args):
"""

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_range_blend_shape_all(range_value):
"""
@ -18,11 +13,11 @@ def sg_range_blend_shape_all(range_value):
# 遍历前50个网格
for i in range(50):
# 获取当前索引的网格
mesh = cmds.SGGetMeshes(m=i)
mesh = mfc.GetMeshes(m=i)
if cmds.objExists(mesh):
# 获取网格的混合变形器
blend_shape = cmds.SGGetBlendShape(mesh)
blend_shape = mfc.GetBlendShape(mesh)
if cmds.objExists(blend_shape):
# 获取所有权重属性
@ -51,7 +46,7 @@ def sg_range_blend_shape_all(range_value):
target=j
)
cmds.SGSetBlendShapes(r=range_value, value=bs_name[0])
mfc.SetBlendShapes(r=range_value, value=bs_name[0])
cmds.delete(bs_name)
# 更新进度窗口

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_range_blend_shape_select(mesh_indices, target_indices, range_value):
"""
@ -20,8 +15,8 @@ def sg_range_blend_shape_select(mesh_indices, target_indices, range_value):
count = len(mesh_indices)
# 初始化进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(max=count)
mfc.ProgressBar(sp=True)
mfc.ProgressBar(max=count)
# 处理每个网格和目标
for i in range(count):
@ -29,11 +24,11 @@ def sg_range_blend_shape_select(mesh_indices, target_indices, range_value):
target_index = target_indices[i]
# 获取网格
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取混合变形器
blend_shape = cmds.SGGetBlendShape(mesh)
blend_shape = mfc.GetBlendShape(mesh)
if cmds.objExists(blend_shape):
# 重新生成目标并设置范围
@ -44,16 +39,16 @@ def sg_range_blend_shape_select(mesh_indices, target_indices, range_value):
target=target_index
)
cmds.SGSetBlendShapes(r=range_value, value=bs_name[0])
mfc.SetBlendShapes(r=range_value, value=bs_name[0])
cmds.delete(bs_name)
# 更新进度条
title = f"[{i+1}/{count}]Select Target Mesh..."
cmds.SGProgressBar(t=title)
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(t=title)
mfc.ProgressBar(apr=1)
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_rebuild_target(target_ids, blend_shape):

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_meshes_list():
"""
@ -16,16 +11,16 @@ def sg_meshes_list():
list: 网格名称列表
"""
meshes = []
edition = cmds.SGDescriptor(ed=True)
edition = mfc.Descriptor(ed=True)
if edition >= 2:
# 获取LOD0的网格索引
mesh_indices = cmds.SGGetMeshes(lod=0)
mesh_indices = mfc.GetMeshes(lod=0)
for index in mesh_indices:
meshes.append(cmds.SGGetMeshes(i=index))
meshes.append(mfc.GetMeshes(i=index))
else:
# 获取所有网格
meshes = cmds.SGGetMeshes()
meshes = mfc.GetMeshes()
return meshes
@ -36,7 +31,7 @@ def sg_set_mesh_line_edit(index, mesh):
index (int): 网格索引
mesh (str): 网格名称
"""
meshes = cmds.SGGetMeshes()
meshes = mfc.GetMeshes()
if mesh:
# 设置选项变量
@ -58,9 +53,9 @@ def sg_refresh_geo_line_edit():
if cmds.objExists(mesh):
# 如果对象存在,设置网格
if mesh_name == "body_lod0_mesh":
cmds.SGSetMeshes(m=50, value=mesh)
mfc.SetMeshes(m=50, value=mesh)
else:
cmds.SGSetMeshes(m=i, value=mesh)
mfc.SetMeshes(m=i, value=mesh)
else:
# 如果对象不存在,尝试通过名称模式查找
selection = cmds.ls(f"*{mesh_name}*", type="transform")
@ -68,13 +63,13 @@ def sg_refresh_geo_line_edit():
for sel in selection:
if cmds.objectType(sel) == "transform":
if mesh_name == "body_lod0_mesh":
cmds.SGSetMeshes(m=50, value=sel)
mfc.SetMeshes(m=50, value=sel)
else:
cmds.SGSetMeshes(m=i, value=sel)
mfc.SetMeshes(m=i, value=sel)
break
else:
# 如果找不到匹配的对象,清除设置
cmds.SGSetMeshes(m=i, value="")
mfc.SetMeshes(m=i, value="")
else:
# 如果不存在选项变量,尝试通过名称模式查找
selection = cmds.ls(f"*{mesh_name}*", type="transform")
@ -82,13 +77,13 @@ def sg_refresh_geo_line_edit():
for sel in selection:
if cmds.objectType(sel) == "transform":
if mesh_name == "body_lod0_mesh":
cmds.SGSetMeshes(m=50, value=sel)
mfc.SetMeshes(m=50, value=sel)
else:
cmds.SGSetMeshes(m=i, value=sel)
mfc.SetMeshes(m=i, value=sel)
break
else:
# 如果找不到匹配的对象,清除设置
cmds.SGSetMeshes(m=i, value="")
mfc.SetMeshes(m=i, value="")
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,20 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_refresh_neutral_joint_translation():
"""
刷新关节的中性位置平移值
"""
# 获取所有关节
joints = cmds.SGGetJoints()
joints = mfc.GetJoints()
# 遍历每个关节
for i, joint in enumerate(joints):
@ -22,7 +17,7 @@ def sg_refresh_neutral_joint_translation():
pos = cmds.getAttr(f"{joint}.t")[0]
# 设置关节的中性位置
cmds.SGSetNeutralJointTranslations(i, pos[0], pos[1], pos[2])
mfc.SetNeutralJointTranslations(i, pos[0], pos[1], pos[2])
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_rename_blend_shapes():
"""
@ -17,7 +12,7 @@ def sg_rename_blend_shapes():
# 遍历前50个网格
for j in range(50):
# 获取网格名称
mesh = cmds.SGGetMeshes(i=j)
mesh = mfc.GetMeshes(i=j)
blend_shape = f"{mesh}_blendShapes"
# 检查混合变形器是否存在

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/09/16
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def is_sorted(array):
"""
@ -49,10 +44,10 @@ def sg_reorder_blend_shapes():
"""
# 遍历前50个网格
for mesh_index in range(50):
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
blend_shape = cmds.SGGetBlendShape(mesh)
blend_shape = mfc.GetBlendShape(mesh)
if cmds.objExists(blend_shape):
attr_weight = f"{blend_shape}.weight"
@ -63,7 +58,7 @@ def sg_reorder_blend_shapes():
# 获取当前和预期的混合变形目标列表
current_blend_shape_list = cmds.listAttr(attr_weight, m=True)
blend_shape_list = cmds.SGGetBlendShapes()
blend_shape_list = mfc.GetBlendShapes()
# 检查是否需要重新排序
needs_reorder = (

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/02/23
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_repair_joint_for_lod(lod):
"""
@ -16,12 +11,12 @@ def sg_repair_joint_for_lod(lod):
lod (int): LOD级别
"""
# 获取指定LOD级别的关节索引列表
joints = cmds.SGGetJoints(lod=lod, t="int")
joints = mfc.GetJoints(lod=lod, t="int")
# 遍历每个关节索引
for i, index in enumerate(joints):
# 获取关节名称
joint = cmds.SGGetJoints(i=index)
joint = mfc.GetJoints(i=index)
# 如果关节不存在,则创建并设置
if not cmds.objExists(joint):
@ -29,14 +24,14 @@ def sg_repair_joint_for_lod(lod):
cmds.joint(p=(0, 0, 0), name=joint)
# 获取并设置父关节
parent = cmds.SGGetJoints(p=index)
parent = mfc.GetJoints(p=index)
try:
cmds.parent(joint, parent)
except:
pass
# 获取并设置关节的中性位置
pos = cmds.SGGetNeutralJointTranslations(i=index)
pos = mfc.GetNeutralJointTranslations(i=index)
# 设置平移和旋转
cmds.setAttr(f"{joint}.t", pos[0], pos[1], pos[2], type="float3")

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/01
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_meta_human_normals():
"""
@ -53,21 +48,21 @@ def sg_repair_normals(index):
vtxs = sg_meta_human_normals()
# 获取头部和身体模型
head = cmds.SGGetMeshes(m=0)
body = cmds.SGGetMeshes(m=50)
head = mfc.GetMeshes(m=0)
body = mfc.GetMeshes(m=50)
# 计算需要处理的顶点对数量
count = len(vtxs) // 2
# 初始化进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(max=count)
cmds.SGProgressBar(t="Repair Normals...")
mfc.ProgressBar(sp=True)
mfc.ProgressBar(max=count)
mfc.ProgressBar(t="Repair Normals...")
# 处理每对对应的顶点
for i in range(count):
# 更新进度条
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 获取头部和身体对应的顶点索引
h = vtxs[i*2]
@ -84,7 +79,7 @@ def sg_repair_normals(index):
cmds.polyNormalPerVertex(body_vtx, xyz=(pos[0], pos[1], pos[2]))
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
# 清除选择并选择身体模型
cmds.select(clear=True)

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/10/21
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_meta_human_normals():
"""
@ -60,8 +55,8 @@ def sg_repair_seams():
vtxs = sg_meta_human_normals()
# 获取头部和身体模型
head = cmds.SGGetMeshes(m=0)
body = cmds.SGGetMeshes(m=50)
head = mfc.GetMeshes(m=0)
body = mfc.GetMeshes(m=50)
# 复制头部模型
head_copy = cmds.duplicate(head, rr=True)[0]
@ -87,7 +82,7 @@ def sg_repair_seams():
head_vtxs.extend(neck_vtxs)
# 应用RBF变形器
cmds.SGRBFDeformer(
mfc.RBFDeformer(
rbf=1,
m=[head, head_copy],
t=[head],

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/23
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_repair_vertex_order():
"""
@ -17,7 +12,7 @@ def sg_repair_vertex_order():
# 遍历所有网格
for i in range(54):
# 获取目标模型
target = cmds.SGGetMeshes(m=i)
target = mfc.GetMeshes(m=i)
if cmds.objExists(target):
# 清除历史记录
@ -25,13 +20,13 @@ def sg_repair_vertex_order():
cmds.DeleteAllHistory()
# 获取源模型并重命名
source = cmds.SGGetMeshes(cm=i)
source = mfc.GetMeshes(cm=i)
source_buffer = f"{source}_buffer"
source_buffer = source_buffer[1:] # 移除第一个字符
source_buffer = cmds.rename(source, source_buffer)
# 应用顶点顺序
cmds.SGSetMeshes(tvo=source_buffer, value=target)
mfc.SetMeshes(tvo=source_buffer, value=target)
# 删除临时模型
cmds.delete(source_buffer)

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_reset_blend_shapes():
"""
@ -17,7 +12,7 @@ def sg_reset_blend_shapes():
# 遍历前50个网格
for j in range(50):
# 获取网格名称
mesh = cmds.SGGetMeshes(i=j)
mesh = mfc.GetMeshes(i=j)
blend_shape = f"{mesh}_blendShapes"
# 检查混合变形器是否存在

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_reset_target(target_ids, blend_shape):

View File

@ -1,32 +1,27 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_save_blend_shape():
"""
保存所有网格的混合变形目标
"""
# 保存混合变形映射
cmds.SGSaveBlendShapeMappings(0)
mfc.SaveBlendShapeMappings(0)
# 初始化进度条
cmds.SGProgressBar(sp=True)
mfc.ProgressBar(sp=True)
# 遍历前50个网格
for mesh_index in range(50):
# 获取网格
mesh = cmds.SGGetMeshes(m=mesh_index)
mesh = mfc.GetMeshes(m=mesh_index)
if cmds.objExists(mesh):
# 获取混合变形器
blend_shape = cmds.SGGetBlendShape(mesh)
blend_shape = mfc.GetBlendShape(mesh)
if cmds.objExists(blend_shape):
# 获取混合变形目标数量
@ -34,13 +29,13 @@ def sg_save_blend_shape():
if count:
# 设置进度条
cmds.SGProgressBar(max=count)
cmds.SGProgressBar(t=f"[{blend_shape}] Save Target Mesh...")
mfc.ProgressBar(max=count)
mfc.ProgressBar(t=f"[{blend_shape}] Save Target Mesh...")
# 处理每个混合变形目标
for index in range(count):
# 更新进度条
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 重新生成目标并保存
bs_name = cmds.sculptTarget(
@ -50,13 +45,13 @@ def sg_save_blend_shape():
target=index
)
cmds.SGSaveBlendShapes(bs=mesh_index, i=index, value=bs_name[0])
mfc.SaveBlendShapes(bs=mesh_index, i=index, value=bs_name[0])
# 删除临时目标
cmds.delete(bs_name)
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/06/12
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_save_blend_shape_mappings(reset_mappings):
"""
@ -16,25 +11,25 @@ def sg_save_blend_shape_mappings(reset_mappings):
reset_mappings (int): 是否重置映射
"""
# 初始化进度条
cmds.SGProgressBar(sp=True)
mfc.ProgressBar(sp=True)
# 初始化映射索引
mapping = 0
# 获取所有混合变形目标名称
blend_shape_names = cmds.SGGetBlendShapes()
blend_shape_names = mfc.GetBlendShapes()
# 设置进度条
cmds.SGProgressBar(max=len(blend_shape_names))
cmds.SGProgressBar(t="Update BlendShape Mappings...")
cmds.SGProgressBar(pr=0)
mfc.ProgressBar(max=len(blend_shape_names))
mfc.ProgressBar(t="Update BlendShape Mappings...")
mfc.ProgressBar(pr=0)
# 获取所有存在的混合变形器和对应的网格索引
blend_shapes = []
mesh_indices = []
for mesh_index in range(50):
blend_shape = f"{cmds.SGGetMeshes(i=mesh_index)}_blendShapes"
blend_shape = f"{mfc.GetMeshes(i=mesh_index)}_blendShapes"
if cmds.objExists(blend_shape):
blend_shapes.append(blend_shape)
mesh_indices.append(mesh_index)
@ -42,7 +37,7 @@ def sg_save_blend_shape_mappings(reset_mappings):
# 处理每个混合变形目标名称
for blend_shape_name in blend_shape_names:
# 更新进度条
cmds.SGProgressBar(apr=1)
mfc.ProgressBar(apr=1)
# 检查每个混合变形器
for i, blend_shape in enumerate(blend_shapes):
@ -52,7 +47,7 @@ def sg_save_blend_shape_mappings(reset_mappings):
# 如果找到匹配的目标名称
if bs_node and blend_shape_name in bs_node:
# 保存映射关系
cmds.SGSaveBlendShapes(
mfc.SaveBlendShapes(
rm=reset_mappings,
ma=mapping,
m=mesh_indices[i],
@ -61,7 +56,7 @@ def sg_save_blend_shape_mappings(reset_mappings):
mapping += 1
# 结束进度条
cmds.SGProgressBar(ep=True)
mfc.ProgressBar(ep=True)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,33 +1,28 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import MetaFusionCore as mfc
def sg_set_body_neutral_joint_translation():
"""
设置身体模型的关节中性位置
"""
# 获取身体模型
body_mesh = cmds.SGGetMeshes(m=50)
body_mesh = mfc.GetMeshes(m=50)
# 如果身体模型不存在,直接返回
if not cmds.objExists(body_mesh):
return
# 执行身体关节定位
cmds.SGBodyJointsLocator()
mfc.BodyJointsLocator()
# 执行主要轴向修正
cmds.SGMainAmendAxis()
mfc.MainAmendAxis()
# 执行蒙皮轴向修正
cmds.SGSkinAmendAxis()
mfc.SkinAmendAxis()
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/01
"""
import maya.cmds as cmds
def sg_set_color(object_name, rgb, r, g, b, index, enabled):

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_set_head_neutral_joint_translation():
@ -14,18 +8,18 @@ def sg_set_head_neutral_joint_translation():
设置头部模型的关节中性位置
"""
# 获取所需的网格模型
head_mesh = cmds.SGGetMeshes(m=0)
teeth_mesh = cmds.SGGetMeshes(m=1)
eye_left_mesh = cmds.SGGetMeshes(m=3)
eye_right_mesh = cmds.SGGetMeshes(m=4)
head_mesh = cmds.GetMeshes(m=0)
teeth_mesh = cmds.GetMeshes(m=1)
eye_left_mesh = cmds.GetMeshes(m=3)
eye_right_mesh = cmds.GetMeshes(m=4)
# 检查必要的模型是否都存在
if not all(cmds.objExists(mesh) for mesh in [head_mesh, teeth_mesh, eye_left_mesh, eye_right_mesh]):
return
# 获取关节信息
json_file = cmds.SGDescriptor(ti="jointsInfo")
object_list = cmds.SGReadJson(f=json_file, k="head", t="object")
json_file = cmds.Descriptor(ti="jointsInfo")
object_list = cmds.ReadJson(f=json_file, k="head", t="object")
namespace = "DHIhead:"
@ -34,7 +28,7 @@ def sg_set_head_neutral_joint_translation():
count = len(object_list)
# 初始化进度条
cmds.SGProgressBar(sp=True)
cmds.ProgressBar(sp=True)
# 创建临时定位器
locator = "MetaHumanLocatorTemp"
@ -42,11 +36,11 @@ def sg_set_head_neutral_joint_translation():
cmds.spaceLocator(n=locator)
# 设置进度条
cmds.SGProgressBar(max=count)
cmds.SGProgressBar(t="Set Head Joint Translation...")
cmds.ProgressBar(max=count)
cmds.ProgressBar(t="Set Head Joint Translation...")
# 获取中性关节位置
pos = cmds.SGGetNeutralJointTranslations(h=True)
pos = cmds.GetNeutralJointTranslations(h=True)
# 检查数据一致性
if count != len(pos) // 3:
@ -55,16 +49,16 @@ def sg_set_head_neutral_joint_translation():
# 处理每个关节
for i in range(count):
# 更新进度条
cmds.SGProgressBar(apr=1)
cmds.ProgressBar(apr=1)
# 获取关节信息
joints = cmds.SGReadJson(d=object_list[i], k="joint", t="string")
joints = cmds.ReadJson(d=object_list[i], k="joint", t="string")
# 处理命名空间
joint = f"{namespace}{joints[0]}" if cmds.namespace(exists=namespace) else joints[0]
# 检查是否需要定位
enable = cmds.SGReadJson(d=object_list[i], k="locate", t="bool")[0]
enable = cmds.ReadJson(d=object_list[i], k="locate", t="bool")[0]
if enable:
# 设置定位器位置
@ -79,8 +73,8 @@ def sg_set_head_neutral_joint_translation():
# 清理和刷新
cmds.delete(locator)
cmds.SGRefreshNeutralJointTranslation()
cmds.SGProgressBar(ep=True)
cmds.RefreshNeutralJointTranslation()
cmds.ProgressBar(ep=True)
cmds.refresh()
# 如果直接运行此脚本

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/03/20
"""
import maya.cmds as cmds
def sg_standardized_naming():
@ -15,18 +9,18 @@ def sg_standardized_naming():
将所有网格重命名为标准名称
"""
# 获取所有标准网格名称
meshes = cmds.SGGetMeshes()
meshes = cmds.GetMeshes()
# 遍历每个网格索引
for i in range(len(meshes)):
# 获取当前网格
mesh = cmds.SGGetMeshes(m=i)
mesh = cmds.GetMeshes(m=i)
# 如果网格存在,进行重命名
if cmds.objExists(mesh):
# 重命名网格并更新引用
new_name = cmds.rename(mesh, meshes[i])
cmds.SGSetMeshes(m=i, value=new_name)
cmds.SetMeshes(m=i, value=new_name)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/04/01
"""
import maya.cmds as cmds
def sg_supplement_meshes():
@ -16,25 +10,25 @@ def sg_supplement_meshes():
# 遍历8个LOD级别
for i in range(8):
# 获取当前LOD级别的网格列表
lod_list = cmds.SGGetMeshes(lod=i)
head = cmds.SGGetMeshes(m=lod_list[0])
deformed = cmds.SGGetMeshes(m=0)
lod_list = cmds.GetMeshes(lod=i)
head = cmds.GetMeshes(m=lod_list[0])
deformed = cmds.GetMeshes(m=0)
if cmds.objExists(head):
# 准备源模型
source = cmds.SGGetMeshes(cm=0)
source = cmds.GetMeshes(cm=0)
source_buffer = f"{source}_buffer"
source_buffer = source_buffer[1:] # 移除第一个字符
source_buffer = cmds.rename(source, source_buffer)
# 设置进度条标题
title = f"[LOD{i}] Please be patient and wait..."
if cmds.SGDescriptor(l=True) == "ZH":
if cmds.Descriptor(l=True) == "ZH":
title = f"[LOD{i}] 请耐心等待..."
# 初始化进度条
cmds.SGProgressBar(sp=True)
cmds.SGProgressBar(t=title)
cmds.ProgressBar(sp=True)
cmds.ProgressBar(t=title)
# 初始化网格列表
eye_mesh = []
@ -42,16 +36,16 @@ def sg_supplement_meshes():
mouth_mesh = []
# 读取顶点信息
json_file = cmds.SGDescriptor(ti="vertexsInfo")
eye_indices = cmds.SGReadJson(f=json_file, k="headEye", t="int")
mouth_indices = cmds.SGReadJson(f=json_file, k="headMouth", t="int")
json_file = cmds.Descriptor(ti="vertexsInfo")
eye_indices = cmds.ReadJson(f=json_file, k="headEye", t="int")
mouth_indices = cmds.ReadJson(f=json_file, k="headMouth", t="int")
# 处理每个网格
for j in range(1, len(lod_list)):
if lod_list[j] < 50:
mesh = cmds.SGGetMeshes(m=lod_list[j])
mesh = cmds.GetMeshes(m=lod_list[j])
if not cmds.objExists(mesh):
new_mesh = cmds.SGGetMeshes(cm=lod_list[j])
new_mesh = cmds.GetMeshes(cm=lod_list[j])
if cmds.objExists(new_mesh):
# 根据名称分类网格
if any(x in new_mesh for x in ["eyeshell", "eyelashes", "eyeEdge", "cartilage"]):
@ -62,12 +56,12 @@ def sg_supplement_meshes():
mouth_mesh.append(new_mesh)
# 设置进度条
cmds.SGProgressBar(max=3)
cmds.ProgressBar(max=3)
# 应用RBF变形器
cmds.SGProgressBar(apr=1)
cmds.ProgressBar(apr=1)
if eye_mesh:
cmds.SGRBFDeformer(
cmds.RBFDeformer(
r=0.01,
rbf=1,
m=[source_buffer, deformed],
@ -75,9 +69,9 @@ def sg_supplement_meshes():
t=eye_mesh
)
cmds.SGProgressBar(apr=1)
cmds.ProgressBar(apr=1)
if eye:
cmds.SGRBFDeformer(
cmds.RBFDeformer(
r=0.01,
rbf=1,
d="off",
@ -86,9 +80,9 @@ def sg_supplement_meshes():
t=eye
)
cmds.SGProgressBar(apr=1)
cmds.ProgressBar(apr=1)
if mouth_mesh:
cmds.SGRBFDeformer(
cmds.RBFDeformer(
r=0.01,
rbf=1,
d="off",
@ -99,7 +93,7 @@ def sg_supplement_meshes():
# 清理和结束
cmds.delete(source_buffer)
cmds.SGProgressBar(ep=True)
cmds.ProgressBar(ep=True)
# 如果直接运行此脚本
if __name__ == '__main__':

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
def sg_transfer_maps():
@ -16,20 +10,20 @@ def sg_transfer_maps():
# 处理头部相关网格的LOD级别
for i in range(1, 8):
# 获取当前LOD级别的网格索引列表
mesh_indices = cmds.SGGetMeshes(lod=i)
mesh_indices = cmds.GetMeshes(lod=i)
# 处理前9个网格
for j in range(9):
mesh = cmds.SGGetMeshes(m=j)
mesh = cmds.GetMeshes(m=j)
if cmds.objExists(mesh):
# 获取网格类型前缀
mesh_type = mesh.split('_')[0]
# 查找相同类型的LOD网格
for m in mesh_indices:
lod_mesh = cmds.SGGetMeshes(i=m)
lod_mesh = cmds.GetMeshes(i=m)
if lod_mesh.startswith(mesh_type):
lod = cmds.SGGetMeshes(m=m)
lod = cmds.GetMeshes(m=m)
# 传递材质
cmds.transferShadingSets(
mesh,
@ -39,12 +33,12 @@ def sg_transfer_maps():
)
# 处理身体网格的LOD级别
body = cmds.SGGetMeshes(m=50)
body = cmds.GetMeshes(m=50)
if cmds.objExists(body):
# 处理身体的3个LOD级别
for i in range(1, 4):
body_index = 50 + i
lod = cmds.SGGetMeshes(m=body_index)
lod = cmds.GetMeshes(m=body_index)
# 传递材质
cmds.transferShadingSets(
body,

View File

@ -1,15 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/04/02
"""
import maya.cmds as cmds
def sg_uv_transfer_vertex_order():
def uv_transfer_vertex_order():
"""
传递UV顶点顺序
在两个选中的对象之间传递UV顶点顺序
@ -23,8 +17,10 @@ def sg_uv_transfer_vertex_order():
return
# 传递顶点顺序
cmds.SGSetMeshes(tvo=sel[0], value=sel[1])
cmds.SetMeshes(tvo=sel[0], value=sel[1])
# 如果直接运行此脚本
if __name__ == '__main__':
sg_uv_transfer_vertex_order()
uv_transfer_vertex_order()

View File

@ -1,12 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2023/08/08
"""
import maya.cmds as cmds
import maya.mel as mel
@ -18,7 +12,7 @@ def sg_unbind_skin_cluster():
# 遍历所有网格
for i in range(54):
# 获取网格
mesh = cmds.SGGetMeshes(m=i)
mesh = cmds.GetMeshes(m=i)
if cmds.objExists(mesh):
# 查找关联的蒙皮变形器

View File

@ -1,15 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
版权所有: 深圳时光科技有限公司
联系方式: q.100@qq.com
创建日期: 2024/10/28
"""
import maya.cmds as cmds
def sg_update_ctrl(json_file, index):
def update_ctrl(json_file, index):
"""
更新控制器的属性到JSON文件
Args:
@ -20,7 +14,7 @@ def sg_update_ctrl(json_file, index):
sel_list = cmds.ls(selection=True)
# 读取JSON文件中的对象列表
object_list = cmds.SGReadJson(f=json_file, t="object")
object_list = cmds.ReadJson(f=json_file, t="object")
# 检查JSON对象数量是否足够
if len(object_list) < 61:
@ -50,7 +44,7 @@ def sg_update_ctrl(json_file, index):
# 如果值超过阈值,记录到数据中
if value > 0.001 or value < -0.001:
data = cmds.SGWriteJson(
data = cmds.WriteJson(
d=data,
k=attribute,
t="double",
@ -61,7 +55,7 @@ def sg_update_ctrl(json_file, index):
object_list[index] = data
# 将更新后的数据写回JSON文件
cmds.SGWriteJson(
cmds.WriteJson(
of=json_file,
sf=json_file,
t="object",