Game Development Community

Problems with DIF -> Collada

by Thomas -elfprince13- Dickerson · in Artist Corner · 01/30/2013 (8:57 pm) · 8 replies

Hi guys, I'm trying to resuscitate some of my old .dif interior models as Collada, and running into some problems. The "export as Collada" option runs without any problems (using the code from the GitHub repo), but when I reimport the created Collada file into a scene all of the texture files are upside down. Worse yet, none of the other editors I've tried (SketchUp, Blender, meshlab) are able to locate the textures at all.

Quote:1/30/13 11:48:31.074 PM [0x0-0x3e03e].org.blenderfoundation.blender: Sax FWL Error: Texture with sid "ERODEDDARKGREY-Diffuse" not found in effect with id "ERODEDDARKGREY-fx".

Quote:1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ** instance_geometry has a material binding
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++ Found 12 instance_material binding
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ ERODEDDARKGREY -> #ERODEDDARKGREY
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ BRIDGESTONES -> #BRIDGESTONES
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ ERODEDGREY -> #ERODEDGREY
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ FLATDARKGREY -> #FLATDARKGREY
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ FLATBLACK -> #FLATBLACK
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ ERODEDBLACK -> #ERODEDBLACK
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ BLACK -> #BLACK
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ DRAGONWINDOW -> #DRAGONWINDOW
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ FLATRED -> #FLATRED
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ WINDOW1X3X4 -> #WINDOW1X3X4
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ WINDOW1X2X4 -> #WINDOW1X2X4
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: ++++++ FLATBROWN -> #FLATBROWN
1/30/13 11:45:02.474 PM [0x0-0x3c03c].meshlab: **** Loading a Geometry Mesh **** (initial mesh size 0 0)
1/30/13 11:45:02.477 PM [0x0-0x3c03c].meshlab: Warning valueStringList returned and emtpy list. nothing inside element with tag 'vcount'
1/30/13 11:45:02.477 PM [0x0-0x3c03c].meshlab: ****** LoadTriangularMesh (initial mesh size 1830 0)
1/30/13 11:45:02.477 PM [0x0-0x3c03c].meshlab: ****** material id 'ERODEDDARKGREY' -> '#ERODEDDARKGREY'
1/30/13 11:45:02.477 PM [0x0-0x3c03c].meshlab: ====== searching among library_effects the effect with id 'ERODEDDARKGREY-fx'
1/30/13 11:45:02.477 PM [0x0-0x3c03c].meshlab: ****** but we were not able to find the corresponding image node
1/30/13 11:45:02.482 PM [0x0-0x3c03c].meshlab: ****** material id 'BRIDGESTONES' -> '#BRIDGESTONES'
1/30/13 11:45:02.482 PM [0x0-0x3c03c].meshlab: ====== searching among library_effects the effect with id 'BRIDGESTONES-fx'
1/30/13 11:45:02.482 PM [0x0-0x3c03c].meshlab: ****** but we were not able to find the corresponding image node
...

Has anyone done this successfully in recent times? If so, with what software combo or which patches to the Collada support in game?

About the author

C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.


#1
01/31/2013 (6:38 am)
Your modeling apps are unable to find the textures because they don't load the Torque material scripts and the texture locations are separated by the material system. You can simply reapply your textures by updating the texture locations in your application of choice.
#2
01/31/2013 (7:31 am)
Thomas,

Richard is correct. I ran into the texture flipping issue before. Found it easier to export the dif to collada. Open the collada file in a 3D app and remap it there. Export it back to collada. This is one of the reasons DIF will be cut out of T3D soon. It's an old format and has not been properly maintained for years.

Good luck, I know its not an easy task.

Ron
#3
01/31/2013 (8:42 am)
Richard: At first I thought that was the problem as well, but after fiddling around I think this is actually not the case. In this case ALL of the texture locations are already in the same folder, and opening up the .dae and inspecting the XML shows the correct file locations. And reading carefully, both of those errors seem to be complaining about the XML structure and not about missing files. Finally, I was hoping I would be able to reapply textures by updating the locations (I've had to do this on many occasions with other application/file-type switches), but Blender fails to import it at all, and both SketchUp and Meshlab complain about the missing textures, and then, as far as I can tell, simply strip the information off, because I can't find any reference to updating them within the applications.

Ron: are you familiar with any tools to globally invert UV coordinates, or am I better off doing this by hand?



Thanks for both of your response! Hoping I can get this figured out :)
#4
01/31/2013 (2:39 pm)
A handful of bug reports on the OpenCOLLADA GitHub page suggest that the fault may lie there. <_<
#5
01/31/2013 (3:59 pm)
Thomas, No tools come to mind. I usually just set them by hand. Painful at times but.... worth it usually and yes, I noticed a few of those reports on OpenCollada's gitHub as well.

Ron
#6
01/31/2013 (4:08 pm)
After further investigation, I'm not sure whose fault it is, but script will patch your files so that the programs I mentioned above can actually import them without dropping the textures. I'll try and automate the texture flipping and post it as a resource.
#!/usr/bin/env python
import xml.etree.ElementTree as ET
import sys

ET.register_namespace("","http://www.collada.org/2005/11/COLLADASchema")

tree = ET.parse(sys.argv[1])#"bridge_bdbd9598.dae")
root = tree.getroot()
fx = root.find("{http://www.collada.org/2005/11/COLLADASchema}library_effects")
for child in fx:
	name = child.attrib['id'][:-3]
	prof = child.find("{http://www.collada.org/2005/11/COLLADASchema}profile_COMMON")
	surparam = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}newparam",attrib={'sid':"%s-Surface"%(name)})
	surface = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}surface",attrib={'type':"2D"})
	sur_init = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}init_from")
	sur_init.text = "%s-Diffuse" % (name)
	surface.append(sur_init)
	surparam.append(surface)
	prof.insert(0,surparam)
	samplerparam = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}newparam",attrib={'sid':"%s-Sampler"%(name)})
	sampler = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}sampler2D")
	source = ET.Element("{http://www.collada.org/2005/11/COLLADASchema}source")
	source.text = "%s-Surface" % (name)
	sampler.append(source)
	samplerparam.append(sampler)
	prof.insert(1,samplerparam)
	tex = prof.find("{http://www.collada.org/2005/11/COLLADASchema}technique").find("{http://www.collada.org/2005/11/COLLADASchema}phong").find("{http://www.collada.org/2005/11/COLLADASchema}diffuse").find("{http://www.collada.org/2005/11/COLLADASchema}texture")
	tex.set("texture","%s-Sampler" %(name))
tree.write(sys.argv[2],encoding="utf-8",xml_declaration=True)
#7
01/31/2013 (10:31 pm)
About a year ago I tried exporting an old DIF as a Collada file (7 story medieval fantasy tower base part) into Blender and it worked except the model was broken up into about a hundred separate cubes. Is there a proper process in reformatting old DIF's or do I need to actually painstakingly merge hundreds of vertices in order to reconstruct the model?
#8
02/01/2013 (6:38 am)
You might try using meshlab to automate it.