Error, i don't know whats happening, eclipse don't report any errors, i'm running the last episode code.
oiramu opened this issue · 6 comments
java.lang.Exception: Error loading model
at org.lwjglb.engine.loaders.assimp.StaticMeshesLoader.load(StaticMeshesLoader.java:45)
at org.lwjglb.engine.loaders.assimp.StaticMeshesLoader.load(StaticMeshesLoader.java:37)
at org.lwjglb.game.DummyGame.init(DummyGame.java:72)
at org.lwjglb.engine.GameEngine.init(GameEngine.java:65)
at org.lwjglb.engine.GameEngine.run(GameEngine.java:52)
at java.lang.Thread.run(Unknown Source)
Sorry for the late response.
It seems that ASSIMP is not able to load the model. Can you print the resource path and check that it can be read?
Sorry for a late reply, i've got a busy week in college
Here is my path in dummygame line 72
Mesh[] terrainMesh = StaticMeshesLoader.load(file.getAbsolutePath(), "/models/terrain");
It's difficult to get an idea. Have you checked that the file exists and can be read ? Maybe you can upload the file to see if there's a problem with the model.
I encountered an issue with this as well. To troubleshoot, added the output of aiGetErrorString()
to the exception where it gets thrown in StaticMeshesLoader
. The stack trace is the same as that seen in the reporter's description, but with some added information... In my case, the following:
java.lang.Exception: Error loading model: Unable to open file "/home/blufish/gits/lwjglbook/file:/home/blufish/gits/lwjglbook/chapter27/c27-p1/target/game-c27-p1-1.0.jar!/models/house/house.obj".
That absolute path looks suspect to me, and I haven't dug in to what the absolute path for a Java Resource in a jar should look like, but I suspect it should be something more like file:/home/blufish/gits/lwjglbook/chapter27/c27-p1/target/game-c27-p1-1.0.jar!/models/house/house.obj
.
Regardless, I can say with certainty that the file in question is indeed in the jar file:
$ unzip -l chapter27/c27-p1/target/game-c27-p1-1.0.jar | grep house
0 2017-11-15 18:41 models/house/
53 2017-11-15 18:41 models/house/SOURCE.txt
1754174 2017-11-15 18:41 models/house/house_text.jpg
47270 2017-11-15 18:41 models/house/house.obj
146 2017-11-15 18:41 models/house/house.mtl
2491829 2017-11-15 18:41 models/house/house_text_bmap.jpg
I was able to work around this problem by copying the models directory to the local filesystem, and altering DummyGame.init(...)
to point to that location (rather than pulling from resources in the .jar). So, there's a solution, but we really ought to figure out what's going on with the resource, and fix the code in the project so that everything builds and runs without modification.
Ok, I see the problem now. The problem occurs when the reosurces are inside the jar file. If the resources are just in the CLASSPATH it should work, but if they are inside a JAR, assimp is not able to load it. I just tend to embed the resources so they can lodaded via CLASSPATH for convenience, but for this case, it may be confusing.
I will review the code and the chapter to use direct file access, and stress this out in the book.
I've just modified the samples to avoid confussions. I will close now this issue.