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 Fileslender-2.49b-windows.blenderscripts orchlight"); sys.path.append(r"D:Program Fileslender-2.49b-windows.blenderscripts"); 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:MyProjunity3darpg36ARPGToolauto_convert_meshdummy.blend" CONVERT_SCRIPT = r"E:MyProjunity3darpg36ARPGToolauto_convert_meshconvert_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:MyProjunity3darpg36ARPGAssetsModelMediaLevel");
此脚本遍历目录下的全部.mesh文件。然后进行转换。
最核心的内容就一样代码 "Blender -b 项目文件 -P 脚本文件 --參数"