Created
December 23, 2017 16:17
-
-
Save donmccurdy/21feef08cbbc349cda587dcd331789db to your computer and use it in GitHub Desktop.
glTF-Sample-Models COLLADA regen script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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