diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-09-29 11:16:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-09-29 11:18:56 +0300 |
commit | 1542092295c92adfaff687050a74cd7c34747c22 (patch) | |
tree | d623a0f4c9dfdb92bcb13f761e7b0c75066adf06 /io_mesh_ply | |
parent | 88f0d4f89e03da4b6972c1b17569f668d98b06ea (diff) |
I/O script changes for GSoC 2017 Vertex Paint
These are changes to the ply and fbx export functions, and the ply
import function, to deal with vertex color alphas as implemented in the
GSoC 2017 Vertex Paint project - see T52910 & D2855
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() |