transform: f(vertices, faces) --> transformed (vertices, faces)
(dir, meshes, transform=lambda v,f:(v,f))
| 24 | |
| 25 | |
| 26 | def export_to_obj(dir, meshes, transform=lambda v,f:(v,f)): |
| 27 | ''' |
| 28 | transform: f(vertices, faces) --> transformed (vertices, faces) |
| 29 | ''' |
| 30 | Path(dir).mkdir(parents=True, exist_ok=True) |
| 31 | for i, data in enumerate(meshes): |
| 32 | v, f = transform(data[0], data[1]) |
| 33 | if len(data) > 2: |
| 34 | v_color = data[2] |
| 35 | else: |
| 36 | v_color = None |
| 37 | mesh = trimesh.Trimesh(v, f, vertex_colors=v_color) |
| 38 | out = trimesh.exchange.obj.export_obj(mesh) |
| 39 | with open(os.path.join(dir, 'sample_'+str(i)+'.obj'), 'w') as f: |
| 40 | f.write(out) |
| 41 | f.close() |
| 42 | |
| 43 | def export_to_obj_single(path, data, transform=lambda v,f:(v,f)): |
| 44 | ''' |
nothing calls this directly
no outgoing calls
no test coverage detected