网格导出无法构建可读的层文件

问题描述

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

到目前为止一切顺利。但是生成的 ply-file 无法读取。如果我尝试在 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')

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

我该如何做对?

解决方法

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

该方法试图保存存储在网格中的所有信息,此时是 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 指的是每个顶点的纹理坐标!!!

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...