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))
```