The blender API of version 2.4 is very different from the API of Version 2.5 or later. Here we only provide ideas and the export solution of version 2.4.
First, provide a script called by blender to convert the mesh file of ogre.
import Blenderimport bpyimport sysimport os,globsys.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_fbxdef 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("--", ""))
The second script is called in the Windows command line. It is used to start the blender for conversion.
import glob,sys,osDUMMY_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");
This script traverses all. Mesh files in the folder and then converts them.
The core content is the same as the code "blender-B project file-P script file-Parameters"