Rendering UV Map problem
Posted: Wed Jun 28, 2017 4:11 pm
In the SVR Blender yobj script,there is an uvlist which contains groups of 3 uv lines,when I tried to read the data to create an obj from the data (debug_uv.txt) I was able to get meaningful display.But when I grouped 3 uv lines from the OBJ that Blender creates and printed them out,the result looked like a mess.Also when Blender exports the uv,none of the lines has any relation to the uv coords in debug_uv.txt that the SVR script is extracting.
debug_uv.txt = UV that SVR YOBJ Script extracts,grouped by 3 uv
test_uv.txt = UV that Blender extracts
uv3.obj: Obj generated from test_uv.txt
uv2.obj: Obj generated from debug_uv.txt
This code converts debug_uv.txt to uv2.obj.Preview looks right.
This code converts test_uv.txt to uv3.obj,results look weird.I grouped each 3 uv lines and draw them separately
uv2.obj looks right while uv3.obj looks weird.
debug_uv.txt = UV that SVR YOBJ Script extracts,grouped by 3 uv
test_uv.txt = UV that Blender extracts
uv3.obj: Obj generated from test_uv.txt
uv2.obj: Obj generated from debug_uv.txt
This code converts debug_uv.txt to uv2.obj.Preview looks right.
Code: Select all
import scanf
input = open("debug_uv.txt")
a = open("uv2.obj", 'w')
vertices = []
faces = []
face = 0
for line in input:
x1, y1, x2, y2, x3, y3 = scanf.sscanf(line, "[%f, %f] [%f, %f] [%f, %f]\n")
vertices.append([x1, y1, 0])
vertices.append([x2, y2, 0])
vertices.append([x3, y3, 0])
faces.append([face, face+1, face+2])
face += 3
for x in xrange(len(faces)):
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3][0], vertices[x*3][1], vertices[x*3][2]))
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3+1][0], vertices[x*3+1][1], vertices[x*3+1][2]))
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3+2][0], vertices[x*3+2][1], vertices[x*3+2][2]))
for x in xrange(len(faces)):
a.write("f %d %d %d\n" % (faces[x][0]+1,faces[x][1]+1, faces[x][2]+1))
a.close()
Code: Select all
import scanf
input = open("test_uv.txt")
faces = []
vertices = []
a = open("uv3.obj", 'w')
i = 0
for line in input:
x1, y1 = scanf.sscanf(line, "%f %f\n")
vertices.append([x1, y1, 0])
if (i + 1) % 3 == 0:
faces.append([i-2, i-1, i])
i += 1
for x in xrange(len(faces)):
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3][0], vertices[x*3][1], vertices[x*3][2]))
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3+1][0], vertices[x*3+1][1], vertices[x*3+1][2]))
a.write("v %.6f %.6f %.6f\n" % (vertices[x*3+2][0], vertices[x*3+2][1], vertices[x*3+2][2]))
for x in xrange(len(faces)):
a.write("f %d %d %d\n" % (faces[x][0]+1,faces[x][1]+1, faces[x][2]+1))