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

148 Views Asked by At

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.

1

There are 1 best solutions below

0
Rockcat On

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')