Problem loading models

Hello everyone,



I used the Flag Rush tutorial as a starting point. The code works as expected and loads the bike.jme model just fine. However, now I am trying to load other models (3DS files in particular) and am getting the following stack trace:



java.io.IOException: Binary Header doesn't match.

use the BinaryImporter instead of JMEBinaryReader

Thanks, Mr. Coder! That got me to the point of loading the model, but now I'm getting FileNotFoundExceptions for several texture files. I purchased this model and the files (several .tga files) it's asking about were not delivered in the download. Are texture files and the like stored inside the 3DS file and I just need to sort out getting to them or is it that I need to contact the model's author and get these files from him/her?

There used to be a "tex_dir" property for the old loaders, not sure if it was replaced, though.

Try TextureKey.setOverridingLocation(final URL overridingLocation)

Hi, I’m getting the same sort of problem. I’m using the starter:hello_modelloading page as my run through. The tutorial has been good so far, but I had to correct some stuff on that page to get it to build (change the “com.jme.scene.model." imports to "com.jmex.model.”, as well as put on the brace to close the class definition. My code is exactly what’s on that page except for those changes). I get the same error as the OP described when I try to run it.



Damn exceptions!java.io.IOException: Header data doesn’t match

java.io.IOException: Header data doesn’t match

at com.jmex.model.XMLparser.BinaryToXML.readHeader(BinaryToXML.java:305)

at com.jmex.model.XMLparser.BinaryToXML.sendBinarytoXML(BinaryToXML.java:101)

at pkgMain.HelloModelLoading.simpleInitGame(HelloModelLoading.java:49)

at com.jme.app.BaseSimpleGame.initGame(BaseSimpleGame.java:474)

at com.jme.app.BaseGame.start(BaseGame.java:56)

at pkgMain.HelloModelLoading.main(HelloModelLoading.java:29)



I tried swapping to loading a .3ds file, using a MaxToJme and removing the line setting the “mtllib” property, and the same thing happened.



I tried switching to a BinaryImporter, as Mr. Coder suggested, but now get an error later on in the line:


Node maggie=jbr.loadBinaryFormat(
    new ByteArrayInputStream(BO.toByteArray()));



because jbr (now a BinaryImporter), doesn't have a loadBinaryFormat method.

Thanks in advance for your help! When somebody figures out what's wrong here, maybe we should update the wiki, eh?

use:


protected void simpleInitGame() {
        // Point to a URL of my model
        URL model=HelloModelLoading.class.getClassLoader().getResource("jmetest/data/model/maggie.obj");

        // Create something to convert .obj format to .jme
        FormatConverter converter=new ObjToJme();
        // Point the converter to where it will find the .mtl file from
        converter.setProperty("mtllib",model);

        // This byte array will hold my .jme file
        ByteArrayOutputStream BO=new ByteArrayOutputStream();
        try {
            // Use the format converter to convert .obj to .jme
            converter.convert(model.openStream(), BO);
            Node maggie=(Node)BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
            // shrink this baby down some
            maggie.setLocalScale(.1f);
            maggie.setModelBound(new BoundingSphere());
            maggie.updateModelBound();
            // Put her on the scene graph
            rootNode.attachChild(maggie);
        } catch (IOException e) {   // Just in case anything happens
            System.out.println("Damn exceptions!" + e);
            e.printStackTrace();
            System.exit(0);
        }
    }



I'll update the wiki.

Wow! Thanks for the quickest reply ever!

That's pretty standard here, which is one of the best parts of working with jME, IMHO.  :slight_smile:

Wiki updated, a bit hurried though…



Maybe it's because of the wiki was ut of date we got so many questions on this specific topic…