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 from __future__ import print_function
00024 import bpy
00025 import os
00026 import sys
00027 
00028 argv = sys.argv
00029 argv = argv[argv.index("--") + 1:]  
00030 
00031 
00032 
00033 
00034 blacklist = ["skip"]
00035 
00036 
00037 mesh_dir = argv[0]
00038 name = argv[1]
00039 
00040 
00041 bpy.ops.object.select_by_type(type="MESH")
00042 sel_obs = bpy.context.selected_objects[:]
00043 
00044 
00045 bpy.ops.ogre.export(filepath=os.path.join(mesh_dir, name + '.scene'),
00046 EX_COPY_SHADER_PROGRAMS=False,
00047 EX_MATERIALS = True,
00048 EX_SEP_MATS=False,
00049 EX_SWAP_AXIS='xyz',
00050 EX_MESH_OVERWRITE=False,
00051 EX_MESH=False,
00052 EX_SELONLY=False,
00053 EX_SCENE=False,
00054 EX_EXPORT_HIDDEN=False,
00055 EX_FORCE_CAMERA=False,
00056 EX_FORCE_LAMPS=False,
00057 EX_ARM_ANIM=False,
00058 EX_SHAPE_ANIM=False,
00059 EX_ARRAY=False,
00060 EX_optimiseAnimations=False)
00061 
00062 
00063 for ob in bpy.data.objects:
00064 
00065     skip_mesh = False
00066     for keyword in blacklist:
00067         if ob.name.find(keyword) != -1:
00068             skip_mesh = True
00069     
00070     if ob.type != 'MESH' or skip_mesh == True:
00071         continue
00072 
00073     
00074     bpy.ops.object.select_all(action="DESELECT")
00075 
00076     
00077     ob.hide = False
00078     ob.select = True
00079 
00080 
00081     
00082     bpy.context.scene.collada_export(filepath=os.path.join(mesh_dir, ob.name + ".dae"), selected = True, include_uv_textures=True, include_children=True)
00083 
00084 
00085 
00086 bpy.ops.object.select_all(action="DESELECT")
00087 for ob in sel_obs:
00088     ob.select = True
00089 bpy.context.scene.objects.active = ob
00090 
00091 print("%s meshes exported." % len(sel_obs))
00092 
00093 bpy.ops.wm.quit_blender()