Merging two 3D Meshes

Viewed 3928

I want to know what would be the best way to take two meshes (constructed using trimmesh) and merge them together. The idea would be to identify a face on each mesh and connect the two using those two faces.

1 Answers

Two main approaches:

  1. Use a boolean mesh operation: trimesh docu . But you must have openSCAD or Blender installed for that.
  1. Merge the vertices with "brute force": (Have the list of trimesh meshes to merge in "yourList")

     vertice_list = [mesh.vertices for mesh in yourList]
     faces_list = [mesh.faces for mesh in yourList]
     faces_offset = np.cumsum([v.shape[0] for v in vertice_list])
     faces_offset = np.insert(faces_offset, 0, 0)[:-1]
    
     vertices = np.vstack(vertice_list)
     faces = np.vstack([face + offset for face, offset in zip(faces_list, faces_offset)])
    
     merged__meshes = trimesh.Trimesh(vertices, faces)
    
Related