Using the new BinaryImporter with XML

First Post! Here it is…



I'm trying to load a model exported from blender using hevee's script (thanks hevee). My loading routine has worked for me in the past (jme v.10) and I'm now using the nightly build, so I'm updating to use the new BinaryImporter.



I'm getting an IOException to the likes of:

Sep 25, 2006 9:37:05 AM com.jme.scene.Node attachChild
INFO: Child (FPS label) attached to this node (FPS node)
java.io.IOException: Not in GZIP format
   at java.util.zip.GZIPInputStream.readHeader(Unknown Source)
   at java.util.zip.GZIPInputStream.<init>(Unknown Source)
   at java.util.zip.GZIPInputStream.<init>(Unknown Source)
   at com.jme.util.export.binary.BinaryImporter.load(Unknown Source)
   at src.TestBinaryXML.loadFromXML(TestBinaryXML.java:123)
   at src.TestBinaryXML.simpleInitGame(TestBinaryXML.java:66)
   at com.jme.app.BaseSimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at src.TestBinaryXML.main(TestBinaryXML.java:61)
   at src.Main.main(Main.java:16)


when loading. I noticed the the TestBinaryXML in the src still uses the JMEBinaryReader, so I replaced it with my own method for testing.

Here's my code:

loadFromXML(String file) {

        Node model = null;
        
        try {

           URL url = TestBinaryXML.class.getClassLoader().getResource(file);

           ByteArrayOutputStream BO = new ByteArrayOutputStream();

           new XMLtoBinary().sendXMLtoBinary(url.openStream(), BO);
                      
           model = (Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
        }
        catch(IOException e) {
           e.printStackTrace();
        }
        
        return model;
     }



I've scoured the forum and can't seem to solve this! I hope its a simple solution, thanks.

ps - For hevee, I have your latest version exporter for jme xml, I noticed in one recent post you had "hacked" a fix for something but didn't test the animation. Well I was playing with the animation export and was getting an error for 'fps' referenced before declaration, I fixed it in mine, if you search for the first occurance of fps you should find it. Awesome tool, thanks!

Same problem here.

For the XML format, do not use BinaryImporter…



All *toJme classes have been updated to convert to the new binary format, but for BinaryToXML and XMLToBinary this is impossible because there are no classes that import/export XML from/into the SceneGraph (from which it can be exported with BinaryImporter), only classes that convert XML to the old binary format.



So yes, the current XML format depends on the old Binary fileformat, which is replaced cause it was so hard to maintain or even makes sense of. But as long as hevee's exporter relies on the current XML format we'll not remove any of the parts needed for it from CVS.



In the future there will probably be a new independant XML file format, based on the Savable system, just like BinaryImporter. I already messed around with this a bit, it's very easy to create a DOM tree with the Savable system… it just needs to do some of the things that BinaryImporter does too, to make sure nothing is duplicated and renderstates work properly (this should probably just reuse the BinaryLoaderModule system from BinaryImporter). It's on my TODO list, but at a pretty low place for now…


Thanks for the info. I've decided to go with MD5 for my new project, but my current one still relies on this XMLtoBinary stuff.