Benjamin

静以修身,俭以养德,非澹薄无以明志,非宁静无以致远。
随笔 - 397, 文章 - 0, 评论 - 196, 引用 - 0
数据加载中……

使用Blender自带的python将fbx转为glb(批量)

1、安装Blender
2、建立python文件
import sys
import bpy
import os
 
export_options = {
    'export_format': 'GLB', 
    'export_apply': True, 
    'export_animations': True, 
    'export_image_format': 'AUTO', 
    'export_texture_dir': '', 
    #'export_embed_buffers': True, 
    #'export_embed_images': True,
    #'export_emissive_strength': False, 
}
path="G:\\TestConvert"
for i,j,k in os.walk(path):
    print(i,j,k)
    for a in k:
        if a.endswith(".fbx"):            
            #clean out the scene
            bpy.ops.object.select_all(action='SELECT')
            bpy.ops.object.delete()
            print("xxxx====="+a)
            currentpsth=path+"\\"+a
            bpy.ops.import_scene.fbx(filepath=currentpsth)
            fname,ext = os.path.splitext(a)
            outpath="G:\\ConvertGlb\\"+fname
            bpy.ops.export_scene.gltf(filepath=outpath,**export_options)
            #export_image_format='AUTO', export_texture_dir='', export_embed_buffers=True, export_image_format='AUTO')
3、运行:使用Blender安装目录下python.exe执行python脚本即可,比如Blender版本是3.6,那么python.exe位置是Blender/3.6/python/bin/python.exe

posted on 2023-07-25 13:59 Benjamin 阅读(570) 评论(0)  编辑 收藏 引用 所属分类: python


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理