MCPcopy Create free account
hub / github.com/Zhiyuan-R/Tiger-Diffusion / export_to_obj

Function export_to_obj

utils/visualize.py:26–41  ·  view source on GitHub ↗

transform: f(vertices, faces) --> transformed (vertices, faces)

(dir, meshes, transform=lambda v,f:(v,f))

Source from the content-addressed store, hash-verified

24
25
26def 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
43def export_to_obj_single(path, data, transform=lambda v,f:(v,f)):
44 '''

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected