1 from mathutils import Vector
4 def write(me, uvs, matimage = False) :
5 uvs, nest = bel.nested(uvs)
7 for uvi, uvlist in enumerate(uvs) :
9 uv = me.uv_textures.new()
12 for uvfi, uvface in enumerate(uvlist) :
13 #uv.data[uvfi].use_twoside = True # 2.60 changes mat ways
14 mslotid = me.faces[uvfi].material_index
15 #mat = mesh.materials[mslotid]
17 if matimage[mslotid] :
18 img = matimage[mslotid]
19 uv.data[uvfi].image=img
20 #uv.data[uvfi].use_image = True
22 uv.data[uvfi].uv1 = Vector((uvface[0],uvface[1]))
23 uv.data[uvfi].uv2 = Vector((uvface[2],uvface[3]))
24 uv.data[uvfi].uv3 = Vector((uvface[4],uvface[5]))
26 uv.data[uvfi].uv4 = Vector((uvface[6],uvface[7]))
28 if nest : return newuvs
29 else : return newuvs[0]
32 # face are squared or rectangular,
34 # vert order width then height 01 and 23 = x 12 and 03 = y
35 # normal default when face has been built
36 def row(vertices,faces,normals=True) :
39 v0 = vertices[face[0]]
40 v1 = vertices[face[1]]
41 v2 = vertices[face[-1]]
55 if normals : uvs.append([x,y,x+lx,y,x+lx,y+ly,x,y+ly])
56 else : uvs.append([x+lx,y,x,y,x,y+ly,x+lx,y+ly])
59 ## convert UV given as verts location to blender format
60 # eg : [ [v0x,v0y] , [vnx , vny] ... ] -> [ [ v1x,v1y,v0x,v0y,v4x,v4y] ... ]
62 def asVertsLocation(verts2d, faces) :
67 uvface.extend(verts2d[vi])