Open3D
Open3D copied to clipboard
Adding multiple textures to the mesh can only display the first texture
Checklist
- [X] I have searched for similar issues.
- [X] For Python issues, I have tested with the latest development wheel.
- [X] I have checked the release documentation and the latest documentation (for
mainbranch).
Describe the issue
I see that in the output file, there are all the textures, namely test_0. png and test_1. png. But in the obj file, there is only 'usemtl test_0'. How should this problem be solved? From my understanding, other 3D model libraries, such as VTK, do not support independent UVs for each triangle like Open3D and do require duplicate vertex creation for spliting triangles. If this problem cannot be solved temporarily, are there any alternative solutions? Here is a simple code example:
Steps to reproduce the bug
import open3d as o3d
import numpy as np
texture1 = o3d.io.read_image(r'./0.png')
texture2 = o3d.io.read_image(r'./1.png')
cylinder_mesh = o3d.geometry.TriangleMesh.create_cylinder(radius = 0.1, height = 5, create_uv_map=True)
octahedron_mesh = o3d.geometry.TriangleMesh.create_octahedron(create_uv_map=True)
cylinder_uvs = np.array(cylinder_mesh.triangle_uvs)
octahedron_uvs = np.array(octahedron_mesh.triangle_uvs)
combined_mesh = cylinder_mesh + octahedron_mesh
combined_mesh.textures = [texture1, texture2]
combined_mesh.triangle_uvs = o3d.utility.Vector2dVector(np.vstack([cylinder_uvs, octahedron_uvs]))
combined_mesh.triangle_material_ids = o3d.utility.IntVector([0 for _ in range(len(cylinder_uvs))] + [1 for _ in range(len(octahedron_uvs))])
print(np.asarray(combined_mesh.triangle_material_ids), len(combined_mesh.triangles), len(combined_mesh.triangle_uvs), len(combined_mesh.triangle_material_ids ) ) # [0 0 0 ... 1 1 1] 208 624 624
o3d.io.write_triangle_mesh("test.obj", combined_mesh)
o3d.visualization.draw_geometries([combined_mesh])
Error message
The output files:
Model display:
Expected behavior
No response
Open3D, Python and System information
python open3d 0.18
Additional information
No response