diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-09 20:08:04 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-10 18:25:48 +0300 |
commit | 227fafdfcf4fb441ba1b8477331d543d2cf087af (patch) | |
tree | 26a0ac762d8985007286884992194c690696cb46 /io_mesh_ply/export_ply.py | |
parent | adb4f822ca2383ec269c529d62419f3e6998bd48 (diff) |
Update for removal of tessfaces.
This ports the already working addons. The disabled x3d, psk, lwo, 3ds,
raw, dxf addons still need to be converted.
Diffstat (limited to 'io_mesh_ply/export_ply.py')
-rw-r--r-- | io_mesh_ply/export_ply.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/io_mesh_ply/export_ply.py b/io_mesh_ply/export_ply.py index b6ab8810..b50b6544 100644 --- a/io_mesh_ply/export_ply.py +++ b/io_mesh_ply/export_ply.py @@ -44,12 +44,12 @@ def save_mesh(filepath, file = open(filepath, "w", encoding="utf8", newline="\n") fw = file.write - # Be sure tessface & co are available! - if not mesh.tessfaces and mesh.polygons: - mesh.calc_tessface() + # Be sure tessellated loop trianlges are available! + if not mesh.loop_triangles and mesh.polygons: + mesh.calc_loop_triangles() - has_uv = bool(mesh.tessface_uv_textures) - has_vcol = bool(mesh.tessface_vertex_colors) + has_uv = bool(mesh.uv_layers) + has_vcol = bool(mesh.vertex_colors) if not has_uv: use_uv_coords = False @@ -62,7 +62,7 @@ def save_mesh(filepath, has_vcol = False if has_uv: - active_uv_layer = mesh.tessface_uv_textures.active + active_uv_layer = mesh.uv_layers.active if not active_uv_layer: use_uv_coords = False has_uv = False @@ -70,7 +70,7 @@ def save_mesh(filepath, active_uv_layer = active_uv_layer.data if has_vcol: - active_col_layer = mesh.tessface_vertex_colors.active + active_col_layer = mesh.vertex_colors.active if not active_col_layer: use_colors = False has_vcol = False @@ -84,9 +84,9 @@ def save_mesh(filepath, ply_verts = [] # list of dictionaries # vdict = {} # (index, normal, uv) -> new index vdict = [{} for i in range(len(mesh_verts))] - ply_faces = [[] for f in range(len(mesh.tessfaces))] + ply_faces = [[] for f in range(len(mesh.loop_triangles))] vert_count = 0 - for i, f in enumerate(mesh.tessfaces): + for i, f in enumerate(mesh.loop_triangles): smooth = not use_normals or f.use_smooth if not smooth: @@ -94,11 +94,9 @@ def save_mesh(filepath, normal_key = rvec3d(normal) if has_uv: - uv = active_uv_layer[i] - uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 + uv = [active_uv_layer[l].uv[:] for l in f.loops] if has_vcol: - col = active_col_layer[i] - col = col.color1[:], col.color2[:], col.color3[:], col.color4[:] + col = [active_col_layer[l].color[:] for l in f.loops] pf = ply_faces[i] for j, vidx in enumerate(f.vertices): @@ -156,7 +154,7 @@ def save_mesh(filepath, "property uchar blue\n" "property uchar alpha\n") - fw("element face %d\n" % len(mesh.tessfaces)) + fw("element face %d\n" % len(mesh.loop_triangles)) fw("property list uchar uint vertex_indices\n") fw("end_header\n") |