I've recently commissioned some artwork for my mobile game. The artist has provided me with a separate SCML file for each different animation. Is there an easy way to combine these animations into a single entity in one SCML file or is this something I will have to write a script for? edit: a couple of small python scripts kind of do what I want. The second one being unfinished but workable. entitymerge.py
from xml.dom import minidomtext_file = open("output.scml", "w")xmldoc1 = minidom.parse('sideview.scml')xmldoc2 = minidom.parse('famine3.scml')# add files from secondfile1count = len(xmldoc1.childNodes[0].childNodes[1].childNodes)file2count = len(xmldoc2.childNodes[0].childNodes[1].childNodes)fileList1 = xmldoc1.getElementsByTagName('file')fileList2 = xmldoc2.getElementsByTagName('file')for s in fileList2: s.attributes['id'] = str(int(s.attributes['id'].value) + len(fileList1)) xmldoc1.childNodes[0].childNodes[1].appendChild(s)# rename file references in secondobjectList2 = xmldoc2.childNodes[0].childNodes[3].getElementsByTagName("object")for s in objectList2: s.attributes['file'] = str(int(s.attributes['file'].value) + len(fileList1))# add entities from secondentityList2 = xmldoc2.getElementsByTagName('entity')for s in entityList2: xmldoc1.childNodes[0].appendChild(s)text_file.write(xmldoc1.toxml())text_file.close()
animationmerge.py
from xml.dom import minidomtext_file = open("output2.scml", "w")xmldoc1 = minidom.parse('output.scml')# record first entityentityList = xmldoc1.getElementsByTagName('entity')i = 0animId = len(entityList[0].getElementsByTagName('animation'))# iterate through non first entityfor s in entityList: if(i > 0): # modify entities bone references # add entity bone refs to first entity bone references # re-ID animations in entity and add to entity 0 animationList = s.getElementsByTagName('animation') for s in animationList: s.attributes['id'] = str(animId) s.attributes['name'] = "anim_" + str(animId) animId += 1 entityList[0].appendChild(s) #remove entity from file i += 1text_file.write(xmldoc1.toxml())text_file.close()