0

perform batch coverting gltf to textured obj format with texture map.

I can use meshlab App to covert gltf to textured obj format with texture map. how to perform batch coverting gltf to textured obj format with texture map.

ziwenjie
  • 9
  • 3
  • I have tried the obvious script to import a file and export to obj and I can confirm that is not working if the file is obj format (and it is working for output .ply format). This is a bug in current version of pymeshlab and should be resolved by the developpers. – Rockcat Jun 02 '23 at 08:02

1 Answers1

0

Try this script to convert any input filename to filename.obj. It is working with sample.gltf and .glb files generated by blender3D, .

It includes a workaround due to the obj exporter seems to be confused if there is textures defined in per-vertex coordinates.

#!/usr/bin/env python3
import pymeshlab as ml
import sys
 
try:
    #Get input filename from argument 1
    fn=sys.argv[1]
except:
    print(f'Usage: {sys.argv[0]} filename')
    sys.exit(-1)

ms = ml.MeshSet()
ms.set_verbosity(True)

print(f'* Converting input file {fn} to {fn}.obj')
ms.load_new_mesh(fn)
print(f' * Input textures: {list(ms.current_mesh().textures().keys())}')

try:
    ms.apply_filter('compute_texcoord_transfer_vertex_to_wedge')
except:
    pass

ms.save_current_mesh(fn + '.obj')
Rockcat
  • 3,002
  • 2
  • 14
  • 28