PyMeshLab icon indicating copy to clipboard operation
PyMeshLab copied to clipboard

ms.transfer_attributes_to_texture_per_vertex doesn't write the texture file.

Open jsusgin-aist opened this issue 7 months ago • 0 comments

Certainly! Here's your original text with Markdown formatting applied to the code parts:


Hi,

I would like to generate a mapping between two objects, one being the parametrized xatlas export of the second one, with the function: ms.transfer_attributes_to_texture_per_vertex. I tried to use this filter on MeshLab and it worked, but I need to automatize it, and PyMeshLab doesn't generate the texture.png file.

This is my code:

import xatlas
import trimesh

atlas = xatlas.Atlas()
mesh = trimesh.load_mesh("input.obj")
vmapping, indices, uvs = xatlas.parametrize(mesh.vertices, mesh.faces)
xatlas.export("output.obj", mesh.vertices[vmapping], indices, uvs)

In another Python kernel:

import pymeshlab

ms = pymeshlab.MeshSet()
srcmesh = ms.load_new_mesh("input.obj")
tgtmesh = ms.load_new_mesh("output.obj")  # Assuming "output.obj" is the parametrized mesh
tex_out = 'texture.png'

assert len(ms) == 2  # True

ms.transfer_attributes_to_texture_per_vertex(sourcemesh=0, targetmesh=1, textname=tex_out)
# Got console output: "Similar Triangles face sampling" but the tex_out is not created.

I also tried to create an empty file with with open(tex_out, 'w') as f: pass before running the transfer_attributes_to_texture_per_vertex function, but it didn't change anything. I also tried to set "overwrite" to True, but it didn't change anything, whether the file was created initially or not... Did I miss something?

Thank you for your help.

jsusgin-aist avatar Jul 24 '24 08:07 jsusgin-aist