mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-06 16:01:10 +00:00
Fix the exported skin conversion.
I must remember to test language features in python 3 :P
This commit is contained in:
parent
40f46f2ea3
commit
4a3731652e
1 changed files with 5 additions and 5 deletions
|
@ -74,12 +74,12 @@ def export_mdl(operator, context, filepath):
|
||||||
skin.pixels = bytearray(mdl.skinwidth * mdl.skinheight) # preallocate
|
skin.pixels = bytearray(mdl.skinwidth * mdl.skinheight) # preallocate
|
||||||
for y in range(mdl.skinheight):
|
for y in range(mdl.skinheight):
|
||||||
for x in range(mdl.skinwidth):
|
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
|
# quake textures are top to bottom, but blender images
|
||||||
# are bottom to top
|
# are bottom to top
|
||||||
ii = ((mdl.skinheight - 1 - y) * mdl.skinwidth + x) * 4
|
inind = ((mdl.skinheight - 1 - y) * mdl.skinwidth + x) * 4
|
||||||
rgb = image.pixels[ii : ii + 3] # ignore alpha
|
rgb = image.pixels[inind : inind + 3] # ignore alpha
|
||||||
rgb = map(lambda x: int(x * 255 + 0.5), rgb)
|
rgb = tuple(map(lambda x: int(x * 255 + 0.5), rgb))
|
||||||
best = (3*256*256, -1)
|
best = (3*256*256, -1)
|
||||||
for i, p in enumerate(palette):
|
for i, p in enumerate(palette):
|
||||||
if i > 255: # should never happen
|
if i > 255: # should never happen
|
||||||
|
@ -89,7 +89,7 @@ def export_mdl(operator, context, filepath):
|
||||||
r += x
|
r += x
|
||||||
if r < best[0]:
|
if r < best[0]:
|
||||||
best = (r, i)
|
best = (r, i)
|
||||||
skin.pixels[i] = best[1]
|
skin.pixels[outind] = best[1]
|
||||||
mdl.skins.append(skin)
|
mdl.skins.append(skin)
|
||||||
mdl.write (filepath)
|
mdl.write (filepath)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
Loading…
Reference in a new issue