Skip to content

Instantly share code, notes, and snippets.

@donmccurdy
Created December 23, 2017 16:17
Show Gist options
  • Save donmccurdy/21feef08cbbc349cda587dcd331789db to your computer and use it in GitHub Desktop.
Save donmccurdy/21feef08cbbc349cda587dcd331789db to your computer and use it in GitHub Desktop.
glTF-Sample-Models COLLADA regen script
#!/usr/bin/env python
import glob
from subprocess import call
import sys
import os
if len(sys.argv) > 1:
target = sys.argv[1]
collada2gltf = os.path.realpath(sys.argv[1])
modelsDir = os.path.realpath(sys.argv[2])
sourceModelsDir = os.path.join(modelsDir, 'sourceModels')
outputModelsDir = os.path.join(modelsDir, '2.0')
print 'COLLADA2GLTF: ' + collada2gltf
print 'SOURCE: ' + sourceModelsDir
print 'OUT: ' + outputModelsDir
variantFlags = {
'' : ['-s'],
'-Embedded' : [],
'-Binary' : ['-b'],
'-pbrSpecularGlossiness' : ['--specularGlossiness', '-s'],
}
for model in os.listdir(sourceModelsDir):
colladaFile = None
for f in glob.glob(os.path.join(sourceModelsDir, model + '/*.dae')):
colladaFile = os.path.relpath(f)
break
if colladaFile is None:
continue
outputPath = os.path.join(outputModelsDir, model + '/')
for variant in variantFlags:
flags = variantFlags[variant]
call([collada2gltf, '-i', colladaFile, '-o', os.path.join(outputPath, 'glTF' + variant, model + '.gltf')] + flags)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment