diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2012-02-28 19:35:49 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2012-02-28 19:35:49 +0400 |
commit | e3f5cd8fd462d54961a6d87400b3b67a92f734d6 (patch) | |
tree | bd62335724c14ebd70d65dfd92bc63dc2937f1e0 /io_mesh_uv_layout/__init__.py | |
parent | 55d1a5020af9fa652dd2af9bea4e01986284ef9c (diff) |
Updated io_mesh_uv_layout addon to work with bmesh.
Note: would have loved to add an option to export tesselated layout (instead of ngon one), but currently I often get mesh without tesselation, and seems there is no way to call ensure_tesselated from python...
Diffstat (limited to 'io_mesh_uv_layout/__init__.py')
-rw-r--r-- | io_mesh_uv_layout/__init__.py | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/io_mesh_uv_layout/__init__.py b/io_mesh_uv_layout/__init__.py index 3682e569..2e706965 100644 --- a/io_mesh_uv_layout/__init__.py +++ b/io_mesh_uv_layout/__init__.py @@ -21,8 +21,8 @@ bl_info = { "name": "UV Layout", "author": "Campbell Barton, Matt Ebb", - "version": (1, 0), - "blender": (2, 5, 8), + "version": (1, 1), + "blender": (2, 6, 2), "location": "Image-Window > UVs > Export UV Layout", "description": "Export the UV layout as a 2D graphic", "warning": "", @@ -103,6 +103,12 @@ class ExportUVLayout(bpy.types.Operator): min=0.0, max=1.0, default=0.25, ) + tesselated = BoolProperty( + name="Tesselated UVs", + description="Export tesselated UVs instead of polygons ones", + default=False, + options={'HIDDEN'}, # As not working currently :/ + ) @classmethod def poll(cls, context): @@ -131,12 +137,12 @@ class ExportUVLayout(bpy.types.Operator): return image_width, image_height - def _face_uv_iter(self, context, mesh): - uv_layer = mesh.uv_textures.active.data - uv_layer_len = len(uv_layer) + def _face_uv_iter(self, context, mesh, tesselated): + uv_layer = mesh.uv_loop_layers.active.data + polys = mesh.polygons if not self.export_all: - + uv_tex = mesh.uv_textures.active.data local_image = Ellipsis if context.tool_settings.show_uv_local_view: @@ -144,23 +150,27 @@ class ExportUVLayout(bpy.types.Operator): if space_data: local_image = space_data.image - faces = mesh.faces - - for i in range(uv_layer_len): - uv_elem = uv_layer[i] + for i, p in enumerate(polys): # context checks - if faces[i].select and (local_image is Ellipsis or - local_image == uv_elem.image): + if polys[i].select and local_image in {Ellipsis, + uv_tex[i].image}: + start = p.loop_start + end = start + p.loop_total + uvs = tuple((uv.uv[0], uv.uv[1]) + for uv in uv_layer[start:end]) #~ uv = uv_elem.uv #~ if False not in uv_elem.select_uv[:len(uv)]: #~ yield (i, uv) # just write what we see. - yield (i, uv_layer[i].uv) + yield (i, uvs) else: # all, simple - for i in range(uv_layer_len): - yield (i, uv_layer[i].uv) + for i, p in enumerate(polys): + start = p.loop_start + end = start + p.loop_total + uvs = tuple((uv.uv[0], uv.uv[1]) for uv in uv_layer[start:end]) + yield (i, uvs) def execute(self, context): @@ -192,7 +202,8 @@ class ExportUVLayout(bpy.types.Operator): mesh = obj.data func(fw, mesh, self.size[0], self.size[1], self.opacity, - lambda: self._face_uv_iter(context, mesh)) +# self.tesselated, + lambda: self._face_uv_iter(context, mesh, self.tesselated)) if self.modified: bpy.data.meshes.remove(mesh) |