Jump to content

Hypnos

Community Newbie
  • Posts

    1
  • Joined

  • Last visited

Hypnos's Achievements

Tiro

Tiro (1/14)

0

Reputation

  1. i have written a python script that fixes the static models (non animated), so they can be imported into blender 2.54. just copy all dae and dds files into a directory and run this script (commandline python scriptname.py) within the same directoy. # fixscript filename = "celt_barge-orig.dae" import xml.dom import os from xml.dom.minidom import parse currentEffectId = 'Undefined' currentProfile = None currentTechnique = None currentMaterial = None currentEffectFx = None dom1 = None hasAddedSurfaceAndSampler = False def printAttributes(child): if child.hasAttributes(): if child.attributes: for attrKey in child.attributes.keys(): print "- attrKey:", attrKey, "attrValue:", child.attributes[attrKey].value #pass def recurse(child): global currentEffectId, currentProfile, currentTechnique, currentMaterial global hasAddedSurfaceAndSampler, dom1 #print "type:", child.nodeType, "name:", child.nodeName, "value:", child.nodeValue if child.nodeType != 3: #printAttributes(child) pass if not hasAddedSurfaceAndSampler: if child.nodeName == 'effect': # remember current effect id #print "found effect", child currentEffectId = child.attributes['id'].value if child.nodeName == 'profile_COMMON': #print "found profile", child currentProfile = child if child.nodeName == 'technique': #print "found technique", child currentTechnique = child if child.nodeName == "init_from": #print dir(child.firstChild) #print "init_from", child.firstChild if child.firstChild.data[0:4] == 'file': child.firstChild.data = "./"+child.firstChild.data.split('\\')[-1] # print "init_from", child.firstChild.value if child.nodeName == 'texture': #print "of effect:", currentEffectId #print "in profile:", currentProfile #print dir(currentProfile) """ <newparam sid="Map__344-image-surface"> <surface type="2D"> <init_from>Map__344-image</init_from> <format>A8R8G8B8</format> </surface> </newparam> """ surfaceParm = dom1.createElement("newparam") surfaceParm.setAttribute("sid", "%s-surface" % child.attributes['texture'].value) currentProfile.insertBefore(surfaceParm, currentTechnique) surface = dom1.createElement("surface") surface.setAttribute("type", "2D") surfaceParm.appendChild(surface) initFrom = dom1.createElement("init_from") surface.appendChild(initFrom) initFromText = dom1.createTextNode(child.attributes['texture'].value) initFrom.appendChild(initFromText) # --- """ <newparam sid="Map__344-image-sampler"> <sampler2D> <source>Map__344-image-surface</source> <minfilter>LINEAR_MIPMAP_LINEAR</minfilter> <magfilter>LINEAR</magfilter> </sampler2D> </newparam> """ samplerParm = dom1.createElement("newparam") samplerParm.setAttribute("sid", "%s-sampler" % child.attributes['texture'].value) currentProfile.insertBefore(samplerParm, currentTechnique) sampler = dom1.createElement("sampler2D") samplerParm.appendChild(sampler) source = dom1.createElement("source") sampler.appendChild(source) sourceText = dom1.createTextNode("%s-surface" % child.attributes['texture'].value) source.appendChild(sourceText) minfilter = dom1.createElement("minfilter") sampler.appendChild(minfilter) minfilterText = dom1.createTextNode("LINEAR_MIPMAP_LINEAR") minfilter.appendChild(minfilterText) magfilter = dom1.createElement("magfilter") sampler.appendChild(magfilter) magfilterText = dom1.createTextNode("LINEAR") magfilter.appendChild(magfilterText) child.attributes['texture'].value = "%s-sampler" % child.attributes['texture'].value textureName = child.attributes['texture'].value hasAddedSurfaceAndSampler = True if child.nodeName == "material": currentMaterial = child.attributes["id"].value #print "found material", child, child.firstChild.nodeName for subChild in child.childNodes: if subChild.nodeName == "instance_effect": currentEffectFx = subChild.attributes['url'].value print "found fx", currentEffectFx, "in", child.attributes["id"].value if child.nodeName == "instance_material": if child.hasAttributes(): #print "attr", child.attributes['symbol'].value, currentMaterial if currentMaterial == child.attributes['symbol'].value: #print "YES" """ <bind_vertex_input semantic="CHANNEL0" input_semantic="TEXCOORD" input_set="0"/> """ bindVertexInput = dom1.createElement("bind_vertex_input") bindVertexInput.setAttribute("semantic", "CHANNEL0") bindVertexInput.setAttribute("input_semantic", "TEXCOORD") bindVertexInput.setAttribute("input_set", "0") child.appendChild(bindVertexInput) if child.hasChildNodes(): for subChild in child.childNodes: recurse(subChild) def handleFile(filename): global currentEffectId, currentProfile, currentTechnique, currentMaterial global hasAddedSurfaceAndSampler, dom1 currentEffectId = 'Undefined' currentProfile = None currentTechnique = None currentMaterial = None currentEffectFx = None hasAddedSurfaceAndSampler = False dom1 = parse(filename) for child in dom1.childNodes: recurse(child) #tmp_config = 'celt_barracks_weapons-orig.dae' fw = open("%s-converted.%s" % os.path.splitext(filename), 'w') fw.write(dom1.toxml()) fw.close() for f in os.listdir("."): if os.path.splitext(f)[1] == ".dae": print "handle file", f handleFile(f)
×
×
  • Create New...