vault backup: 2023-09-30 10:18:03
This commit is contained in:
parent
159dc65b98
commit
829832372d
@ -1,4 +0,0 @@
|
||||
# Shader
|
||||
|
||||
|
||||
# CPP
|
@ -5,4 +5,96 @@
|
||||
- https://www.bilibili.com/video/BV1ex4y1g7DX/?spm_id_from=333.337.search-card.all.click&vd_source=d47c0bb42f9c72fd7d74562185cee290
|
||||
- (收费)Blender Retargeting Tools 1.2:https://blendermarket.com/products/blender-retargeting-tools-1
|
||||
|
||||
##
|
||||
# 调用
|
||||
使用Rokoko与BetterFbx插件。这里因为需要规避Rokoko插件名带有“-”的问题,所以还需要安装Importlib库
|
||||
```python
|
||||
import bpy
|
||||
import os
|
||||
import sys
|
||||
import importlib
|
||||
rokoko = importlib.import_module("rokoko-studio-live-blender-master")
|
||||
from better_fbx import *
|
||||
|
||||
|
||||
# 启动命令参数
|
||||
'''
|
||||
# blender --background test.blend --python mytest.py -- example args 123
|
||||
cd /d D:/Program Files/Blender Foundation/Blender 3.3/
|
||||
blender.exe --python C:/Users/BlueRose/Desktop/Retareting/Blender_AnimationRetarget.py -- C:/Users/BlueRose/Desktop/Retareting/Animations/MF_Run_Fwd.fbx C:/Users/BlueRose/Desktop/Retareting/Characters/SKM_Quinn.fbx C:/Users/BlueRose/Desktop/Retareting/Animations/ExportAnimation.fbx 0
|
||||
|
||||
# Blender后台启动并且执行Python
|
||||
blender.exe --python C:/Users/BlueRose/Desktop/Retareting/Blender_AnimationRetarget.py --background --python-text -- C:/Users/BlueRose/Desktop/Retareting/Animations/MF_Run_Fwd.fbx C:/Users/BlueRose/Desktop/Retareting/Characters/SKM_Quinn.fbx C:/Users/BlueRose/Desktop/Retareting/Animations/ExportAnimation.fbx 0
|
||||
|
||||
# Python CMD 交互方式
|
||||
blender.exe --python-console --background -- C:/Users/BlueRose/Desktop/Retareting/Animations/MF_Run_Fwd.fbx C:/Users/BlueRose/Desktop/Retareting/Characters/SKM_Quinn.fbx C:/Users/BlueRose/Desktop/Retareting/Animations/ExportAnimation.fbx 0
|
||||
'''
|
||||
# 读取输入路径
|
||||
argv = sys.argv
|
||||
argv = argv[argv.index("--") + 1:] # get all args after "--"
|
||||
print(argv) # --> ['example', 'args', '123']
|
||||
SourceAnimation = argv[0]
|
||||
TargetSkeletalMesh = argv[1]
|
||||
ExportAnimtion = argv[2]
|
||||
bExportPreviewMesh = bool(int(argv[3]))
|
||||
# SourceAnimation = "C:/Users/BlueRose/Desktop/Retareting/Animations/MM_Run_Fwd.fbx"
|
||||
# TargetSkeletalMesh = "C:/Users/BlueRose/Desktop/Retareting/Characters/SKM_Quinn.fbx"
|
||||
# ExportAnimtion = "C:/Users/BlueRose/Desktop/Retareting/Animations/ExportAnimation.fbx"
|
||||
# bExportPreviewMesh = bool(int("0"))
|
||||
|
||||
# 清空场景
|
||||
# bpy.ops.wm.read_factory_settings(use_empty=True)
|
||||
bpy.ops.scene.new(type='EMPTY')
|
||||
# for block in bpy.data.meshes:
|
||||
# if block.users == 0:
|
||||
# bpy.data.meshes.remove(block)
|
||||
# for block in bpy.data.materials:
|
||||
# if block.users == 0:
|
||||
# bpy.data.materials.remove(block)
|
||||
# for block in bpy.data.textures:
|
||||
# if block.users == 0:
|
||||
# bpy.data.textures.remove(block)
|
||||
# for block in bpy.data.images:
|
||||
# if block.users == 0:
|
||||
# bpy.data.images.remove(block)
|
||||
|
||||
# 导入相关资产
|
||||
bpy.ops.better_import.fbx(filepath=TargetSkeletalMesh,use_auto_bone_orientation=False,use_reset_mesh_origin=False,use_animation=False,use_detect_deform_bone=False,use_import_materials=False)
|
||||
#bpy.ops.import_scene.fbx(filepath=TargetSkeletalMesh,use_anim=False)
|
||||
TargetSeletctObjects = bpy.context.selected_objects
|
||||
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
|
||||
bpy.ops.better_import.fbx(filepath=SourceAnimation,use_auto_bone_orientation=False,use_reset_mesh_origin=False,use_animation=True,use_detect_deform_bone=False,use_import_materials=False)
|
||||
#bpy.ops.import_scene.fbx(filepath=SourceAnimation,use_anim=True)
|
||||
SourceSeletctObjects = bpy.context.selected_objects
|
||||
|
||||
# 使用插件重定向
|
||||
for Object in SourceSeletctObjects:
|
||||
if Object.type == "ARMATURE":
|
||||
bpy.context.scene.rsl_retargeting_armature_source=Object
|
||||
for Object in TargetSeletctObjects:
|
||||
if Object.type == "ARMATURE":
|
||||
bpy.context.scene.rsl_retargeting_armature_target=Object
|
||||
|
||||
# 构建Bone映射表 & 填充缺少的BoneName(假设使用相同的骨骼结构) & 移除root的映射
|
||||
bpy.ops.rsl.build_bone_list()
|
||||
|
||||
for BoneItem in bpy.context.scene.rsl_retargeting_bone_list:
|
||||
if BoneItem.bone_name_target == "":
|
||||
BoneItem.bone_name_target = BoneItem.bone_name_source
|
||||
continue
|
||||
if BoneItem.bone_name_target == "root":
|
||||
BoneItem.bone_name_target = ""
|
||||
|
||||
# 动画重定向
|
||||
bpy.ops.rsl.retarget_animation()
|
||||
|
||||
# 输出
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
for Object in TargetSeletctObjects:
|
||||
if bExportPreviewMesh or Object.type == "ARMATURE":
|
||||
Object.select_set(True)
|
||||
|
||||
bpy.ops.better_export.fbx(filepath=ExportAnimtion,my_fbx_format="binary",use_selection=True,use_visible=True,use_only_root_empty_node=False)
|
||||
# bpy.ops.export_scene.fbx(filepath=ExportAnimtion,use_selection=True,add_leaf_bones=False,object_types={"ARMATURE","MESH"},bake_anim_use_nla_strips=False,bake_anim_use_all_actions=False)
|
||||
```
|
Loading…
x
Reference in New Issue
Block a user