0

我写了一个小脚本,它的任务是加载网格(层),然后应用一些过滤器,最后将整个东西导出为层。

到现在为止还挺好。但是生成的 ply 文件无法读取。如果我尝试在 MeshLab 中打开它,它会显示:“面超过 3 个顶点”

这是涉及 pymeshlab 的代码部分(已清理):

import pymeshlab as ml
ms = ml.MeshSet()
ms.load_new_mesh(path + mesh_name)
ms.apply_filter('convert_pervertex_uv_into_perwedge_uv')
ms.apply_filter('transfer_color_texture_to_vertex')
ms.save_current_mesh(path + 'AutomatedGeneration3.ply')

我错过了什么?执行此脚本实际上没有错误消息。我还尝试为保存过滤器使用一些参数,但它没有改变任何东西。

我怎样才能正确?

4

1 回答 1

0

这似乎是方法内部使用的 .ply 导出器中的一个错误ms.save_current_mesh()

该方法试图保存存储在网格中的所有信息,此时为 texture_per_vertex、texture_per_wedge 和 color_per_vertex,并且那里出了点问题。

我通过禁用保存 texture_per_wedge 来管理解决方法(这对于transfer_color_texture_to_vertex过滤器是必需的。

import pymeshlab as ml
ms = ml.MeshSet()
#Load a mesh with texture per wedge
ms.load_new_mesh('input_pervertex_uv.ply')
m = ms.current_mesh()

print("Input mesh has", m.vertex_number(), 'vertex and', m.face_number(), 'faces' )

ms.apply_filter('convert_pervertex_uv_into_perwedge_uv')
ms.apply_filter('transfer_color_texture_to_vertex')

#Export mesh with color_per_vertex but without texture
ms.save_current_mesh('output.ply',save_wedge_texcoord=False,save_vertex_coord=False )

save_current_mesh可以在此处阅读 有效参数列表https://pymeshlab.readthedocs.io/en/latest/filter_list.html#save-parameters

请注意,save_vertex_coord指的是每个顶点的纹理坐标!!!

于 2021-01-25T11:51:53.020 回答