]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/mesh.py
Make resource handling in the Blender exporter more flexible
[libs/gl.git] / blender / io_mspgl / mesh.py
index f357936275ae6d352a5c6ad983dccf4d809c4421..609f89a1566ae3848efa9404cb0358e537528e09 100644 (file)
@@ -167,6 +167,7 @@ class UvLayer:
 class Mesh:
        def __init__(self, mesh):
                self._mesh = mesh
+               self.name = mesh.name
 
                self.winding_test = mesh.winding_test
                self.tbn_vecs = mesh.tbn_vecs
@@ -387,23 +388,7 @@ class Mesh:
                                for g in v.groups:
                                        g.group = group_index_map[g.group]
 
-       def prepare_uv(self, obj, progress):
-               if obj.material_tex and self.use_uv!='NONE':
-                       layer = UvLayer("material_tex")
-
-                       if self.use_uv=='UNIT0':
-                               self.uv_layers = [layer]
-                               layer.unit = 0
-                       else:
-                               self.uv_layers.append(layer)
-                               layer.unit = max((u.unit+1 for u in self.uv_layers if u.unit is not None), default=0)
-
-                       layer.uvs = [None]*len(self.loops)
-                       for f in self.faces:
-                               uv = mathutils.Vector(((f.material_index+0.5)/len(self.materials), 0.5))
-                               for i in f.loop_indices:
-                                       layer.uvs[i] = uv
-
+       def prepare_uv(self, progress):
                # Form a list of UV layers referenced by materials with the array atlas
                # property set
                array_uv_layers = [t.uv_layer for m in self.materials if m.array_atlas for t in m.texture_slots if t and t.texture_coords=='UV']
@@ -789,6 +774,8 @@ def create_mesh_from_object(context, obj, progress):
                else:
                        mesh = me
 
+       mesh.name = obj.data.name
+
        progress.set_task("Triangulating", 0.2, 0.3)
        mesh.prepare_triangles(progress)
        progress.set_task("Smoothing", 0.3, 0.5)
@@ -796,7 +783,7 @@ def create_mesh_from_object(context, obj, progress):
        progress.set_task("Vertex groups", 0.5, 0.6)
        mesh.prepare_vertex_groups(obj)
        progress.set_task("Preparing UVs", 0.6, 0.8)
-       mesh.prepare_uv(obj, progress)
+       mesh.prepare_uv(progress)
        progress.set_task("Render sequence", 0.8, 1.0)
        mesh.prepare_sequence(progress)