23 from xml.dom.minidom
import parse, parseString
26 parser = argparse.ArgumentParser(usage=
'convert offset of all dae files in a directory')
27 parser.add_argument(
'-i',
'--input', default=
None, help=
'inputDirectory')
28 parser.add_argument(
'-o',
'--output', default=
None, help=
'outputDirectory')
29 parser.add_argument(
'-s',
'--scale', default=1, help=
'scale factor for the meshes')
31 args = parser.parse_args()
33 directory = args.input
37 file_list = sorted(os.listdir(directory))
38 for file
in file_list:
39 if file.endswith(
'.dae'):
40 dom = parse(directory +
'/' + file)
42 for node
in dom.getElementsByTagName(
'matrix'):
43 if node.nodeName ==
'matrix':
44 node.firstChild.nodeValue = args.scale +
" 0 0 0 0 " + args.scale +
" 0 0 0 0 " + args.scale +
" 0 0 0 0 1" 46 for node
in dom.getElementsByTagName(
'init_from'):
47 if node.firstChild.nodeValue.startswith(
'/'):
48 node.firstChild.nodeValue=
'../../texture/' +str(node.firstChild.nodeValue[node.firstChild.nodeValue.rfind(
'/')+1:])
49 print 'processing ' + file
50 f = open(os.path.join(directory, file),
'w+')