mesh.generate_material_uv()
texunits = []
- if mesh.uv_textures and self.export_uv!="NONE":
+ if mesh.uv_layers and self.export_uv!="NONE":
if self.export_uv=="UNIT0":
texunits = [0]
else:
- texunits = list(range(len(mesh.uv_textures)))
+ texunits = list(range(len(mesh.uv_layers)))
tbn_unit = 0
if self.tbn_vecs:
- uvtex_names = [u.name for u in mesh.uv_textures]
+ uvtex_names = [u.name for u in mesh.uv_layers]
if self.tbn_uvtex in uvtex_names:
tbn_unit = uvtex_names.index(uvtex)
del texunits[tbn_unit]
fmt += "_VERTEX3"
out_file.begin("vertices", fmt)
normal = None
- uvs = [None]*len(mesh.uv_textures)
+ uvs = [None]*len(mesh.uv_layers)
tan = None
bino = None
for v in mesh.vertices:
self.flag = False
-class FakeUvTex:
+class UvLayer:
+ def __init__(self, l):
+ self._layer = l
+ self.name = None
+
+ def __getattr__(self, attr):
+ return getattr(self._layer, attr)
+
+class FakeUvLayer:
def __init__(self, n):
self.name = n
self._mesh = m
self.vertices = [Vertex(v) for v in self.vertices]
- self.faces = [Face(f) for f in self.faces]
+ self.faces = [Face(f) for f in self.polygons]
self.materials = self.materials[:]
- self.uv_textures = [u for u in self.uv_textures if not u.name.endswith(".hidden")]
- self.uv_textures.sort(key=uvtex_unit_number)
+ self.uv_layers = [UvLayer(u) for u in self.uv_layers]
+ for i in range(len(self.uv_layers)):
+ self.uv_layers[i].name = self.uv_textures[i].name
+ self.uv_layers = [u for u in self.uv_layers if not u.name.endswith(".hidden")]
+ self.uv_layers.sort(key=uvtex_unit_number)
for f in self.faces:
f.vertices = [self.vertices[i] for i in f.vertices]
for v in f.vertices:
v.faces.append(f)
- for u in self.uv_textures:
- r = u.data[f.index].uv_raw;
- f.uvs.append([(r[i], r[i+1]) for i in range(0, 8, 2)])
+ for u in self.uv_layers:
+ f.uvs.append([u.data[f.loop_indices[i]].uv for i in range(len(f.vertices))])
self.edges = dict([(e.key, Edge(e)) for e in self.edges])
for f in self.faces:
e.check_smooth(1)
def generate_material_uv(self):
- self.uv_textures.append(FakeUvTex("material_tex"))
+ self.uv_layers.append(FakeUvLayer("material_tex"))
for f in self.faces:
f.uvs.append([((f.material_index+0.5)/len(self.materials), 0.5)]*len(f.vertices))
v.uvs = [u[i] for u in f.uvs]
def compute_tbn(self, index):
- if not self.uv_textures:
+ if not self.uv_layers:
return
for v in self.vertices: