UV_Export rounding error fixed by Macouno (from elysiun).

Also standardized some indenting and export to black lines instead of red.
This commit is contained in:
2005-11-26 15:25:21 +00:00
parent 5b04f23777
commit eb8012d1a1

View File

@@ -9,7 +9,7 @@ Tooltip: 'Export the UV face layout of the selected object to a .TGA file'
__author__ = "Martin 'theeth' Poirier"
__url__ = ("http://www.blender.org", "http://www.elysiun.com")
__version__ = "1.3a"
__version__ = "1.4"
__bpydoc__ = """\
This script exports the UV face layout of the selected mesh object to
@@ -26,8 +26,9 @@ There are more options to configure, like setting export path, if image should
use object's name and more.
Notes:<br>
Jean-Michel Soler (jms) wrote TGA functions used by this script.
Zaz added the default path code and Selected Face option.
Jean-Michel Soler (jms) wrote TGA functions used by this script.<br>
Zaz added the default path code and Selected Face option.<br>
Macouno fixed a rounding error in the step calculations<br>
"""
@@ -75,6 +76,9 @@ Notes:<br>
# Version 1.3a
# Corrected a minor typo and added the tga extension to both export call
# --------------------------
# Version 1.4 Updates by Macouno from Elysiun.com
# Fixed rounding error that can cause breaks in lines.
# --------------------------
import Blender
from math import *
@@ -238,11 +242,12 @@ def UV_Export(size, wsize, file):
co2 = f[index + 1]
else:
co2 = f[0]
step = int(size*sqrt((co1[0]-co2[0])**2+(co1[1]-co2[1])**2))
step = int(ceil(size*sqrt((co1[0]-co2[0])**2+(co1[1]-co2[1])**2)))
if step:
for t in range(step + 1):
x = int((co1[0] + t*(co2[0]-co1[0])/step) * size)
y = int((co1[1] + t*(co2[1]-co1[1])/step) * size)
for t in range(step):
x = int(floor((co1[0] + t*(co2[0]-co1[0])/step) * size))
y = int(floor((co1[1] + t*(co2[1]-co1[1])/step) * size))
if bWrap.val:
x = x % wrapSize
@@ -251,16 +256,17 @@ def UV_Export(size, wsize, file):
x = int ((x - minx) * scale)
y = int ((y - miny) * scale)
co = x * 3 + y * 3 * size
co = x * 3 + y * 3 * size;
img[co] = 0
img[co+1] = 0
img[co+2] = 255
img[co+2] = 0
if wsize > 1:
for x in range(-1*wsize + 1,wsize):
for y in range(-1*wsize,wsize):
img[co + 3 * x + y * 3 * size] = 0
img[co + 3 * x + y * 3 * size +1] = 0
img[co + 3 * x + y * 3 * size +2] = 255
img[co + 3 * x + y * 3 * size +2] = 0
for v in f:
x = int(v[0] * size)
@@ -276,8 +282,7 @@ def UV_Export(size, wsize, file):
co = x * 3 + y * 3 * size
img[co] = 0
img[co+1] = 0
img[co+2] = 0
img[co+2] = 255
write_tgafile(file,img,size,size,3)