Loading JME file

I have used per’s converter to convert my milkshape model to JME. Then try to read it using this code:



        URL JmeFile=TestNav.class.getClassLoader().getResource(modeldir + "/" + modelname);       
        JmeBinaryReader jbr=new JmeBinaryReader();
        URL TEXdir=TestNav.class.getClassLoader().getResource(modeldir+"/");
        jbr.setProperty("texurl",TEXdir);
        Node i=null;
        try
        {
            i=jbr.loadBinaryFormat(JmeFile.openStream());
        } catch (IOException e)
        {
            System.out.println("Couldnt load JME file: " + e.getMessage());
        }
        return i;



but I am keep getting this error:

INFO: Unable to load file: null
com.jme.system.JmeException: Illegale Qualified name: texture
at com.jme.scene.model.XMLparser.JmeBinaryReader.readBegining(Unknown Source)
at com.jme.scene.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at com.jme.scene.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at TestNav.loadJmeModel(TestNav.java:757)
at TestNav.populateTerrain(TestNav.java:768)
at TestNav.initGame(TestNav.java:554)
at com.jme.app.VariableTimestepGame.start(Unknown Source)
at TestNav.main(TestNav.java:138)
15-Feb-2005 10:39:15 com.jme.app.VariableTimestepGame start
INFO: Application ending.


have I missed something out?
tomcat
protected void simpleInitGame() {
LoaderNode aFighter = new LoaderNode("Fighter");
try {
aFighter.loadFromFilePath("binary", "/Volumes/Data/Users/atze/Desktop/SOL2Stuff/LittleFighter/Fighter.jme", new HashMap());
} catch (IOException e) {
e.printStackTrace();
}
lightState.detachAll();
rootNode.attachChild(aFighter);
}


taken from a post on this forum just replace the paths and it should work
had the same issue a while back ;)

Ok, I have tried that and still getting the same error. I get this error on several files which have been converted using the third party converters (I used the one by Per)


16-Feb-2005 16:06:47 com.jme.scene.model.XMLparser.JmeBinaryReader buildTexture
INFO: Unable to load file: null
com.jme.system.JmeException: Illegale Qualified name: texture
at com.jme.scene.model.XMLparser.JmeBinaryReader.readBegining(Unknown Source)
at com.jme.scene.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at com.jme.scene.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)
at TestNav.loadJmeModel(TestNav.java:757)
at TestNav.populateTerrain(TestNav.java:768)
at TestNav.initGame(TestNav.java:554)
at com.jme.app.VariableTimestepGame.start(Unknown Source)
at TestNav.main(TestNav.java:138)
15-Feb-2005 10:39:15 com.jme.app.VariableTimestepGame start
INFO: Application ending.


Both the texture and the file are in the same directory.
Another thing is that if I load the MilkShape file and do the convertion in the program i.e. calling MilkToJme and using the JmeBinaryReader, it works. This is a very strange problem. (!)
tomcat

Hmm, have you tried the latest from cvs? I put in some fixes from the board not too long ago. I also just put in a quick addition to the error message because it doesn’t make a lot of sense when comparing it to the code.

Note: the converts available in the “Third Party Apps” section are just GUI’s. The real work is done by jME, so if there’s been jME updates concerning the converters, you might have to put a new jme.jar in the libs directory of the GUI. Mine is using v0.8.

Mmm, good point Per.

I just changed the jar file as per suggested, and it now works. thanks guys. :slight_smile:

tomcat

I get the following error using the code above to load a model (either one). This is a ms3d file converted to jme with per’s gui (using a recent cvs and the current cvs). I replaced the jme.jar in the gui lib directory a few different times but always got the same result. I also made sure that I didn’t screw up and point to the wrong location for the file, and I didn’t screw that up (whole different error for that). Any ideas?



java.lang.NullPointerException

at com.jme.math.Quaternion.slerp(Unknown Source)

at com.jme.animation.JointController.createJointTransforms(Unknown Source)

at com.jme.animation.JointController.update(Unknown Source)

at com.jme.scene.Spatial.updateWorldData(Unknown Source)

at com.jme.scene.Node.updateWorldData(Unknown Source)

at com.jme.scene.Spatial.updateGeometricState(Unknown Source)

at com.jme.scene.Node.updateWorldData(Unknown Source)

at com.jme.scene.Spatial.updateGeometricState(Unknown Source)

at com.jme.scene.Node.updateWorldData(Unknown Source)

at com.jme.scene.Spatial.updateGeometricState(Unknown Source)

at com.jme.app.SimpleGame.update(Unknown Source)

at com.jme.app.BaseGame.start(Unknown Source)

The only way to get an NPE in that section of the code is by passing in a null Quat to slerp… So it looks like one of the joint rotations is null in the animation. Probably a problem in the ms3d conversion… maybe one of the model specialists on here can have a look at your model and the convertor.

You shouldn’t get null slerps. Can you email me the file so I can look at it?

cep would also be the one to talk to concerning this

http://www.jmonkeyengine.com/jmeforum/viewtopic.php?t=1358

cep21: the email address on the website seems to have bounced. I’ve uploaded the files to http://dan.gufbal.com/temp/ , these files are free for anyones use (except for the humiliation you would feel for actually using them… it’s a very basic test model).



Minor update… removed the keyframes from the model (which seemed to have gotten hosed up somehow anyway) and reconverted it with no change in behavior.

the email address on the website seems to have bounced.


I'm trying to figure this out... sorry about that guys.

I thought maybe not having a texture is making something go crazy, so I slap a texture onto my model and I get a different error, I don’t know if this counts as an improvement or not.



java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at com.jme.animation.JointController.processController(Unknown Source)

at com.jme.scene.model.XMLparser.JmeBinaryReader.readEnd(Unknown Source)

at com.jme.scene.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)

at com.jme.scene.model.XMLparser.LoaderNode.loadFromFilePath(Unknown Source)

at Role.simpleInitGame(Role.java:105)

at com.jme.app.SimpleGame.initGame(Unknown Source)

at com.jme.app.BaseGame.start(Unknown Source)

THought I’d post here instead of making a new thread. I’m getting a NullPointerException when I try to load my jme model (it’s a converted ms3d modell) I converted it using Per’s converter.


java.lang.NullPointerException
   at com.meka.system.GameEntity.<init>(GameEntity.java:147)
   at com.meka.app.Game.initSceneGraph(Game.java:275)
   at com.meka.app.Game.initGame(Game.java:204)
   at com.jme.app.BaseGame.start(Unknown Source)
   at com.meka.app.Game.main(Game.java:41)



Here's my model loading code.

      Node model = null;
      try {
         JmeBinaryReader jbr = new JmeBinaryReader();
         URL modelURL = GameEntity.class.getClassLoader().getResource(src);
//THis line below is where the NULL Pointer Exception is thrown
         model = jbr.loadBinaryFormat(modelURL.openStream());
      } catch (IOException ioe) {
         LoggingSystem.getLogger().log(Level.WARNING,
               "Could not load model: " + src + ", from Entity: "
                     + getName());
      }



From what I've read the only way I can get a NULL point error is if there is something wrong with my model? THe model is pretty simple. No animations and just one texture. If it helps you can get the model here.

Milkshape 3d Model: http://www.mekamedia.com/model/spaceship.ms3d
Texture: http://www.mekamedia.com/model/tut-ship.jpg

is it converted if it is then use the method in the second post.



somebody should really make that more obivious a sticky or something.

You’re getting an NPE because the URL is null… In other words, the URL you constructed to point at your model file is invalid.