From 257fefca38f5308d6f2ac0ed6d423120aa96255e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 15 Sep 2011 19:52:18 +0900 Subject: [PATCH] Link the first skin to the imported object. The texture doesn't display properly in 3d space in texture mode yet. --- tools/qfmdl/import_mdl.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/qfmdl/import_mdl.py b/tools/qfmdl/import_mdl.py index 5fb1ee182..46fe9372c 100644 --- a/tools/qfmdl/import_mdl.py +++ b/tools/qfmdl/import_mdl.py @@ -234,8 +234,25 @@ def import_mdl(operator, context, filepath): mdl_uv = uvs[i] for j, uv in enumerate(f.uv): uv[0], uv[1] = mdl_uv[j] + + mat = bpy.data.materials.new(mdl.name) + mat.diffuse_color = (1,1,1) + mat.use_raytrace = False + tex = bpy.data.textures.new(mdl.name, 'IMAGE') + tex.extension = 'CLIP' + tex.use_preview_alpha = True + tex.image = mdl.images[0] # use the first skin for now + mat.texture_slots.add() + ts = mat.texture_slots[0] + ts.texture = tex + ts.use_map_alpha = True + ts.texture_coords = 'UV' mesh.update() object_data_add(context, mesh, operator=None) + act = bpy.context.active_object + if not act.material_slots: + bpy.ops.object.material_slot_add() + act.material_slots[0].material = mat bpy.context.user_preferences.edit.use_global_undo = True return 'FINISHED'