XML loader not working with texturestates

Is the  XML loader currently broken in regard to texture states? I just stumbled upon texture loading issues from xml files, and tried exporting a programmatically generated scene to xml, and then reimporting it right away, which resulted in some exceptions. is this a known issue, or maybe related to this: http://www.jmonkeyengine.com/jmeforum/index.php?topic=2191.0 ? If this is a bug, and not yet known, I can do more tests and elaborate.

Please elaborate… could it be related to http://www.jmonkeyengine.com/jmeforum/index.php?topic=2489.0 ?

I don't think the problem is serialization related, since it occurs while loading a scene from xml. Of course, that's just a vague guess, I have not yet understood how that xml to binary converter works. The Exceptions thrown vary between:



java.lang.RuntimeException: Unable to do IO correctly:Invalid byte 1 of 1-byte UTF-8 sequence.

at com.jmex.model.XMLparser.XMLtoBinary.sendXMLtoBinary(Unknown Source)



and, much more frequently:



java.lang.ClassCastException: java.lang.String

at com.jmex.model.XMLparser.JmeBinaryReader.buildTexture(Unknown Source)

at com.jmex.model.XMLparser.JmeBinaryReader.readBegining(Unknown Source)

at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)

at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)



with the TextureState set up in the xml file like this:


    <texturestate><texture file="leaves1.png"/>
    </texturestate>


(BTW, the "texturestate" xml node is a direct child of the "mesh" xml node)
That is the way a scene gets written when using the current BinaryToXML class. The example scene in cvs data/XML docs/newSampleScene.xml, however, is set up like so:


    <texturestate file="leaves1.png"/>


Using this arrangement, the exceptions will not be thrown, since the offensive "texture" node is not present, but there is still no TextureState in the loaded scene.

Hold on, my bad!

Turns out that I was using an old loading method, which did not, as it is required now, put an URL into JmeBinaryReader's property map, but a String. Oh well. Sorry for bothering you all, and thanks for looking at this, renanse. I think this thread can now safely be deleted.

By old loading method, do you mean something you wrote, or a method in TextureManager…  if the latter, we need to fix it so others don't have the same issue…  or at least document why it is that way.

It was something I wrote back when JmeBinaryReader's "texurl" property took a String, rather than an URL. Completely not jME's fault, at all. Sorry for not being clear about that.

cool