BinaryImporter throwing an ArrayIndexOutOfBounds [RESOLVED]

Hey,



I had a working program that could import a .jme model into StandardGame. However, I decided to update to jME 2.0.

After fixing all the broken code, I ran the program and this is what i got:


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 16
   at com.jme.scene.Spatial.read(Spatial.java:1073)
   at com.jme.scene.Geometry.read(Geometry.java:874)
   at com.jme.scene.TriMesh.read(TriMesh.java:628)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:256)
   at com.jme.util.export.binary.BinaryInputCapsule.resolveIDs(BinaryInputCapsule.java:472)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArray(BinaryInputCapsule.java:460)
   at com.jme.util.export.binary.BinaryInputCapsule.readSavableArrayList(BinaryInputCapsule.java:564)
   at com.jme.scene.Node.read(Node.java:679)
   at com.jme.util.export.binary.BinaryImporter.readObject(BinaryImporter.java:256)
   at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:164)
   at com.jme.util.export.binary.BinaryImporter.load(BinaryImporter.java:86)
   at jmectftest.jmectfGameState.buildPlayer(jmectfGameState.java:185)
   at jmectftest.jmectfGameState.<init>(jmectfGameState.java:126)
   at jmectftest.jmectfTest.start(jmectfTest.java:25)
   at jmectftest.jmectfTest.main(jmectfTest.java:17)



the code worked before:


Spatial model = null;
      try {
         File file = new File("data/tank.jme");
         URL path = file.toURI().toURL();
         BinaryImporter importer = new BinaryImporter();
         model = (Spatial)importer.load(path.openStream());
         model.setModelBound(new BoundingBox());
         model.updateModelBound();
         model.setLocalScale(2.0f);
         model.rotateUpTo(new Vector3f(0.0f, 0.0f, -1.0f));
         model.rotateUpTo(new Vector3f(.5f , 0.0f, 0.0f));
      } catch (IOException e) {
         System.out.println("Could not load model.");
         System.exit(1);
      }

You'll need to re-export the binary model from your new jME version.

LordOfChaos said:

However, I decided to update to jME 1.0.


I suppose you updated to jME 2.0?

and yes, that is quite expected.

models converted from format .xyz to .jme with jme1.0 are not loading in jme2.0, you have to convert them again with jme2.0.

so long,
Andy

Thanks for the replies!



I think I already did - I used ModelLoader to write it again and then replaced the old tank.jme with the new one.



OH WAIT



I copied it into the wrong workspace (I had two copies of my project)

It works perfectly now, thanks

:smiley: