From 4a3731652eb15eb85c49be5db59bb5062c1e5a6e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 22 Sep 2011 14:08:10 +0900 Subject: [PATCH] Fix the exported skin conversion. I must remember to test language features in python 3 :P --- tools/io_mesh_qfmdl/export_mdl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/io_mesh_qfmdl/export_mdl.py b/tools/io_mesh_qfmdl/export_mdl.py index fe09c18d0..cbdea618b 100644 --- a/tools/io_mesh_qfmdl/export_mdl.py +++ b/tools/io_mesh_qfmdl/export_mdl.py @@ -74,12 +74,12 @@ def export_mdl(operator, context, filepath): skin.pixels = bytearray(mdl.skinwidth * mdl.skinheight) # preallocate for y in range(mdl.skinheight): for x in range(mdl.skinwidth): - oi = y * mdl.skinwidth + x + outind = y * mdl.skinwidth + x # quake textures are top to bottom, but blender images # are bottom to top - ii = ((mdl.skinheight - 1 - y) * mdl.skinwidth + x) * 4 - rgb = image.pixels[ii : ii + 3] # ignore alpha - rgb = map(lambda x: int(x * 255 + 0.5), rgb) + inind = ((mdl.skinheight - 1 - y) * mdl.skinwidth + x) * 4 + rgb = image.pixels[inind : inind + 3] # ignore alpha + rgb = tuple(map(lambda x: int(x * 255 + 0.5), rgb)) best = (3*256*256, -1) for i, p in enumerate(palette): if i > 255: # should never happen @@ -89,7 +89,7 @@ def export_mdl(operator, context, filepath): r += x if r < best[0]: best = (r, i) - skin.pixels[i] = best[1] + skin.pixels[outind] = best[1] mdl.skins.append(skin) mdl.write (filepath) return {'FINISHED'}