Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 from __future__ import print_function
00025 import bpy
00026 import os
00027 import sys
00028
00029 argv = sys.argv
00030 argv = argv[argv.index("--") + 1:]
00031
00032 mesh_dir = argv[0]
00033 output_dir = argv[1]
00034 print("Exporting ogre meshes to <%s>." % output_dir)
00035
00036 scene = bpy.context.scene
00037
00038
00039 for ob in scene.objects:
00040 ob.select = True
00041 bpy.ops.object.delete()
00042
00043
00044 file_list = sorted(os.listdir(mesh_dir))
00045 for file in file_list:
00046 if file.endswith('.dae') == True :
00047
00048 bpy.ops.wm.collada_import(filepath= os.path.join(mesh_dir , file))
00049
00050 for ob in scene.objects:
00051 if ob.type == 'MESH':
00052 ob.select = True
00053 if ob.name.find("_skip") ==-1:
00054 bpy.context.scene.objects.active = ob
00055 else:
00056 ob.select = False
00057
00058 bpy.ops.object.join()
00059 for ob in scene.objects:
00060 ob.name = file
00061
00062 bpy.ops.ogre.export(filepath=os.path.join(output_dir, file) + ".scene",
00063 EX_COPY_SHADER_PROGRAMS=False,
00064 EX_MATERIALS = False,
00065 EX_SWAP_AXIS='xyz',
00066 EX_MESH=True,
00067 EX_MESH_OVERWRITE=True,
00068 EX_SCENE=False,
00069 EX_EXPORT_HIDDEN=False,
00070 EX_FORCE_CAMERA=False,
00071 EX_FORCE_LAMPS=False,
00072 EX_ARM_ANIM=False,
00073 EX_SHAPE_ANIM=False,
00074 EX_ARRAY=False,
00075 EX_optimiseAnimations=False)
00076
00077 bpy.ops.object.select_all(action="SELECT")
00078 bpy.ops.object.delete()
00079 print ("\n\n removed all objects")
00080 for ob in scene.objects:
00081 print(ob.name)
00082 print ("\n\n")
00083
00084 for material in bpy.data.materials:
00085 bpy.data.materials[material.name].user_clear()
00086 bpy.data.materials.remove(material)
00087
00088 bpy.ops.wm.quit_blender()
00089
00090