Hi all,
I just started fiddling around a bit with Java-based 3D programming and am currently sort of “evaluating” scenegraph libs and the likes.
So I tried to write a very simple app to learn a bit about the programming model behind jme and got immediately stuck on a problem.
While loading a simple ase-file without textures, I keep getting an ArrayIndexOutOfBounds Exception at com.jme.scene.model.ase.ASEModel.convertToTriMesh(ASEModel.java:266) (btw. I checked out the jme head).
It looks as if the assumption that there is a tempTexVertex at object.faces[j].coordIndex[0] is wrong, since my ase file contains *MESH_NUMTVERTEX 0, so the vector does get initialized to size 0.
I tried to simply implement a check, whether this array index is valid but then I get stuck with a NullPointerException at some other place.
Am I doing anything stupidly wrong here or is this some kind of bug?
BTW., here’s my notsodifficult source:
protected void simpleInitGame() {
display.setTitle(“A Simple Test”);
ASEModel model = new ASEModel(“sphere”);
URL data = JmeEval.class.getClassLoader().getResource(“half.ase”);
model.load(data);
rootNode.attachChild(model);
}
in a class which extends SimpleGame.
The model loaders are probably our current weak point, so it may be a bug therein. If that is the case though, the good news is that Mojo has said he will be focusing on greatly expanding the ASE loader for .7.
That said, it would be a great help to have a copy of your non-working model to test. Could you post a link to it?
Yes, I can
Here we go:
http://www.cli-clan.de/~batman/half.ase
Fairly simple this is half of a sphere with no texture.
Improving ASE and adding 3DS is my goal of the next release, so I’ll tackle issues with the current loader first. Thanks for the model, I’ll try to take care of these problems.
Well, having said that, I found a minor bug in the milkshape loader.
In the method private TextureState loadTexture(String file) you should add a test for an empty texture file string, since in models without textures these values are empty strings. You need to add this in the beginning of the method, since later on you create a fileURL by attaching this file name to the texture directory, so the fileURL is never empty but pointing to a directory instead of a file.
if (file == null || file.trim().length() == 0) {
return null;
}
Alternatively, in TextureManager.loadTexture you could check, whether the given file url really resembles a file and not a directory.
I'm not going to change things in CVS, I am way to n00b in jme still.
Thanks, the check has been committed.
It looks like there are still errors in the ASE loader.
I’m just trying to load a simple geosphere exported as ASE and it gives me the following:
INFO: Node created.
java.lang.ArrayIndexOutOfBoundsException: 0
at com.jme.scene.model.XMLparser.Converters.AseToJme$ASEModelCopy.convertToTriMesh(AseToJme.java:230)
at com.jme.scene.model.XMLparser.Converters.AseToJme$ASEModelCopy.load(AseToJme.java:162)
at com.jme.scene.model.XMLparser.Converters.AseToJme$ASEModelCopy.<init>(AseToJme.java:124)
at com.jme.scene.model.XMLparser.Converters.AseToJme.convert(AseToJme.java:51)
at jmetest.renderer.loader.TestASEJmeWrite.simpleInitGame(TestASEJmeWrite.java:32)
at com.jme.app.SimpleGame.initGame(SimpleGame.java:344)
at com.jme.app.BaseGame.start(BaseGame.java:63)
at jmetest.renderer.loader.TestASEJmeWrite.main(TestASEJmeWrite.java:20)
See also http://www.mojomonkeycoding.com/jmeforum/viewtopic.php?p=9933#9933
I didn’t write that part of the ASE loader (not sure who did), so I can’t comment too much on it. It looks like it’s having trouble setting texture coordinates though from the source. Not sure if that gives you any clue on how to change your model to make it load.