diff options
Diffstat (limited to 'io_mesh_ply')
-rw-r--r-- | io_mesh_ply/export_ply.py | 5 | ||||
-rw-r--r-- | io_mesh_ply/import_ply.py | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/io_mesh_ply/export_ply.py b/io_mesh_ply/export_ply.py index d4db5710..8de5d674 100644 --- a/io_mesh_ply/export_ply.py +++ b/io_mesh_ply/export_ply.py @@ -154,7 +154,8 @@ def save_mesh(filepath, if use_colors: fw("property uchar red\n" "property uchar green\n" - "property uchar blue\n") + "property uchar blue\n" + "property uchar alpha\n") fw("element face %d\n" % len(mesh.tessfaces)) fw("property list uchar uint vertex_indices\n") @@ -167,7 +168,7 @@ def save_mesh(filepath, if use_uv_coords: fw(" %.6f %.6f" % v[2]) # uv if use_colors: - fw(" %u %u %u" % v[3]) # col + fw(" %u %u %u %u" % v[3]) # col fw("\n") for pf in ply_faces: diff --git a/io_mesh_ply/import_ply.py b/io_mesh_ply/import_ply.py index eb097ba9..86fc2e1b 100644 --- a/io_mesh_ply/import_ply.py +++ b/io_mesh_ply/import_ply.py @@ -242,7 +242,7 @@ def load_ply_mesh(filepath, ply_name): uvindices = (el.index(b's'), el.index(b't')) if -1 in uvindices: uvindices = None - colindices = el.index(b'red'), el.index(b'green'), el.index(b'blue') + colindices = el.index(b'red'), el.index(b'green'), el.index(b'blue'), el.index(b'alpha') if -1 in colindices: colindices = None else: # if not a float assume uchar @@ -267,6 +267,7 @@ def load_ply_mesh(filepath, ply_name): mesh_colors.append([(vertices[index][colindices[0]] * colmultiply[0], vertices[index][colindices[1]] * colmultiply[1], vertices[index][colindices[2]] * colmultiply[2], + vertices[index][colindices[3]] * colmultiply[3], ) for index in indices]) if uvindices or colindices: @@ -340,7 +341,10 @@ def load_ply_mesh(filepath, ply_name): f_col = f.color1, f.color2, f.color3 for j, col in enumerate(f_col): - col.r, col.g, col.b = ply_col[j] + col[0] = ply_col[j][0] + col[1] = ply_col[j][1] + col[2] = ply_col[j][2] + col[3] = ply_col[j][3] mesh.validate() mesh.update() |