Make the skin show in blender's 3d view.

Much thanks to ideasman_42 for showing me which code I needed to grok to
get it working.
This commit is contained in:
Bill Currie 2011-09-15 22:45:23 +09:00
parent 320f613263
commit 41213f2c30

View file

@ -227,6 +227,7 @@ def import_mdl(operator, context, filepath):
faces, uvs = make_faces (mdl)
verts = make_verts (mdl, 0)
load_skins (mdl)
img = mdl.images[0] # use the first skin for now
mesh = bpy.data.meshes.new(mdl.name)
mesh.from_pydata(verts, [], faces)
uvlay = mesh.uv_textures.new(mdl.name)
@ -234,14 +235,15 @@ def import_mdl(operator, context, filepath):
mdl_uv = uvs[i]
for j, uv in enumerate(f.uv):
uv[0], uv[1] = mdl_uv[j]
f.image = img
f.use_image = True
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
tex.image = img
mat.texture_slots.add()
ts = mat.texture_slots[0]
ts.texture = tex