Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MartensCedric opened this issue Nov 7, 2024 · 3 comments

Comments

@MartensCedric
Copy link

  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

@mikedh
Copy link
Owner

mikedh commented Nov 8, 2024

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)
  

@MartensCedric
Copy link
Author

MartensCedric commented Nov 8, 2024

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

@mikedh
Copy link
Owner

mikedh commented Nov 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants