2.4版本的Blender API和2.5以上版本的API有很大的不同,这里只是提供了思路和2.4版本的导出方案。
先提供一个脚本,这个是由Blender调用的,用于转换Ogre的Mesh文件的脚本
import Blender import bpy import sys import os,glob sys.path.append(r"D:\Program Files\blender-2.49b-windows\.blender\scripts\torchlight"); sys.path.append(r"D:\Program Files\blender-2.49b-windows\.blender\scripts"); import importTL,export_fbx def ImportMesh(file): print file; scn = bpy.data.scenes.active #Scene.Unlink(scn); importTL.ImportOgre(file); output = file.replace(".mesh", ".fbx"); output = output.replace(".MESH", ".fbx"); export_fbx.fbx_default_setting(); export_fbx.fbx_write(output); return True; ImportMesh(sys.argv[5].replace("--", ""))
import glob,sys,os DUMMY_BLEND = r"E:\MyProj\unity3d\arpg36\ARPG\Tool\auto_convert_mesh\dummy.blend" CONVERT_SCRIPT = r"E:\MyProj\unity3d\arpg36\ARPG\Tool\auto_convert_mesh\convert_mesh.py" def convert_path(path): for root, dirs, files in os.walk(path): for dir in dirs: strDir = os.path.join(root, dir); #print(strDir); for file in files: file = file.lower(); strFile = os.path.join(root, file); #print(strFile); if strFile.find(".mesh") != -1: os.system("Blender -b {0} -P {1} --{2}".format(DUMMY_BLEND, CONVERT_SCRIPT, strFile)); for root, dirs, files in os.walk(path): for file in files: file = file.lower(); if file.find(".mesh") != -1 or file.find(".skeleton") != -1 or file.find(".xml") != -1 or file.find(".material") != -1 or file.find(".animation") != -1 or file.find(".adm") != -1: strFile = os.path.join(root, file); os.remove(strFile); convert_path(r"E:\MyProj\unity3d\arpg36\ARPG\Assets\Model\Media\Level");
最核心的内容就一样代码 "Blender -b 项目文件 -P 脚本文件 --参数"
使用Blender批量导出/转换模型,布布扣,bubuko.com
原文地址:http://blog.csdn.net/langresser_king/article/details/36634911