trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

Creating a new mesh from indices changes the number of vertices in an unnexpected way.

Open MartensCedric opened this issue 1 year ago • 3 comments


  mesh = trimesh.load(obj_filename)
  print(mesh)

  new_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces)
  print(new_mesh)
  

Output:

Notice how the vertices go from 555 to 505.

<trimesh.Trimesh(vertices.shape=(555, 3), faces.shape=(968, 3), name=`suzanne.obj`)>
<trimesh.Trimesh(vertices.shape=(505, 3), faces.shape=(968, 3))>


suzanne.zip

MartensCedric avatar Nov 07 '24 19:11 MartensCedric

Hey, I think you probably want process=False to turn off vertex merging, which is on by default mostly so STL files don't show up as a triangle soup:

  mesh = trimesh.load(obj_filename, process=False)
  print(mesh)

  new_mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, process=False)
  print(new_mesh)
  

mikedh avatar Nov 08 '24 01:11 mikedh

but why is vertex merging off by default in the load but on when creating the object? Seems it should be consistent

MartensCedric avatar Nov 08 '24 01:11 MartensCedric

It's actually on for loading too, probably what's happening is since OBJ has explicit vertex normals it will only merge vertices if they have the same position AND normal, where in the second case it's only getting position passed in.

mikedh avatar Nov 08 '24 02:11 mikedh