From fd9b8f7b4a8937e9955deab45ef60b679b530189 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 15 Apr 2012 09:34:53 +0900 Subject: [PATCH] Fix import and export for blender 2.63 Blender 2.63 should be out in a few days. Nice to get this ready ahead of time. --- tools/io_mesh_qfmdl/export_mdl.py | 11 ++++++----- tools/io_mesh_qfmdl/import_mdl.py | 12 ++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/io_mesh_qfmdl/export_mdl.py b/tools/io_mesh_qfmdl/export_mdl.py index 87f526deb..0cd0b6fac 100644 --- a/tools/io_mesh_qfmdl/export_mdl.py +++ b/tools/io_mesh_qfmdl/export_mdl.py @@ -32,7 +32,7 @@ def check_faces(mesh): #quad to tri conversion will not be done automatically. faces_ok = True save_select = [] - for f in mesh.faces: + for f in mesh.polygons: save_select.append(f.select) f.select = False if len(f.vertices) > 3: @@ -42,7 +42,7 @@ def check_faces(mesh): mesh.update() return False #reset selection to what it was before the check. - for f, s in map(lambda x, y: (x, y), mesh.faces, save_select): + for f, s in map(lambda x, y: (x, y), mesh.polygons, save_select): f.select = s mesh.update() return True @@ -94,14 +94,15 @@ def build_tris(mesh): # the layout. However, there seems to be nothing in the mdl format # preventing the use of duplicate 3d vertices to allow complete freedom # of the UV layout. - uvfaces = mesh.uv_textures[0].data + uvfaces = mesh.uv_loop_layers[0].data stverts = [] tris = [] vertmap = [] # map mdl vert num to blender vert num (for 3d verts) uvdict = {} - for face, uvface in map(lambda a,b: (a,b), mesh.faces, uvfaces): + for face in mesh.polygons: fv = list(face.vertices) - uv = list(uvface.uv) + uv = uvfaces[face.loop_start:face.loop_start + face.loop_total] + uv = list(map(lambda a: a.uv, uv)) # blender's and quake's vertex order seem to be opposed fv.reverse() uv.reverse() diff --git a/tools/io_mesh_qfmdl/import_mdl.py b/tools/io_mesh_qfmdl/import_mdl.py index 64a3e8cfb..303a0e8c6 100644 --- a/tools/io_mesh_qfmdl/import_mdl.py +++ b/tools/io_mesh_qfmdl/import_mdl.py @@ -100,13 +100,13 @@ def setup_skins (mdl, uvs): load_skins (mdl) img = mdl.images[0] # use the first skin for now uvlay = mdl.mesh.uv_textures.new(mdl.name) - for i, f in enumerate(uvlay.data): + uvloop = mdl.mesh.uv_loop_layers[0] + for i, texpoly in enumerate(uvlay.data): + poly = mdl.mesh.polygons[i] mdl_uv = uvs[i] - for j, uv in enumerate(f.uv): - uv[0], uv[1] = mdl_uv[j] - f.image = img - if hasattr(f, "use_image"): # for older blender - f.use_image = True + texpoly.image = img + for j,k in enumerate(poly.loop_indices): + uvloop.data[k].uv = mdl_uv[j] mat = bpy.data.materials.new(mdl.name) mat.diffuse_color = (1,1,1) mat.use_raytrace = False