point-e icon indicating copy to clipboard operation
point-e copied to clipboard

How to save the point cloud model to .obj file

Open xionghao2000 opened this issue 2 years ago • 3 comments

Any suggestions? Thanks for your time!

xionghao2000 avatar Dec 22 '22 07:12 xionghao2000

hey so you can save it in to a .ply format when you use the pointcloudtomesh example and in blender you can import the .ply model and export it to an obj, fbx, etc

eliecer696 avatar Dec 23 '22 02:12 eliecer696

working on google colab but finding the colours been missing

import trimesh
def ply_to_obj(ply_file, obj_file):
    mesh = trimesh.load(ply_file)
    mesh.export(obj_file)

    return obj_file
in_file = '/content/point-e/mesh.ply'
out_file = '/content/point-e/model.obj'
ply_to_obj(in_file,out_file)


!npm install -g obj2gltf
!node /tools/node/bin/obj2gltf -i {out_file} -o {out_file[:-4]}.glb

1kaiser avatar Dec 25 '22 12:12 1kaiser

In Google Colab, I was able to export to obj and glb like this

import trimesh
# Write the mesh to a PLY file to import into some other program.
with open('mesh.ply', 'wb') as f:
    mesh.write_ply(f)
mesh = trimesh.load('mesh.ply')
mesh.export('mesh.glb')
# mesh.export('mesh.obj')
print('done')

kevincolten avatar Jan 11 '23 23:01 kevincolten