lwjglgamedev/lwjglbook-leg

Able to run CH28 with the RenderDoc but not with cmd.exe

Ramh5 opened this issue · 3 comments

Ramh5 commented

Hi, I am at a loss here. While working on my own code I noticed I am not able to use the assimp function aiImportFile(resourcePath, flags); to load models when running the jar from the cmd line. It works well when inside eclipse or even in RenderDoc. I build the jar and copied the models and textures folders inside the target folder to have them adjacent to the jar but this is the error I get. Did I miss an obvious step?

C:\Users\ramho\Desktop>java -jar F:\GIT\lwjglb\lwjglbook\chapter28\target\game-c28-1.0.jar
java.lang.Exception: Error loading model [resourcePath: models/buffer_pass_mess.obj, texturesDir:models]
        at org.lwjglb.engine.loaders.assimp.StaticMeshesLoader.load(StaticMeshesLoader.java:44)
        at org.lwjglb.engine.loaders.assimp.StaticMeshesLoader.load(StaticMeshesLoader.java:36)
        at org.lwjglb.engine.graph.Renderer.init(Renderer.java:85)
        at org.lwjglb.game.DummyGame.init(DummyGame.java:57)
        at org.lwjglb.engine.GameEngine.init(GameEngine.java:53)
        at org.lwjglb.engine.GameEngine.run(GameEngine.java:40)
        at org.lwjglb.game.Main.main(Main.java:20)
java.lang.NullPointerException
        at org.lwjglb.game.DummyGame.cleanup(DummyGame.java:200)
        at org.lwjglb.engine.GameEngine.cleanup(GameEngine.java:84)
        at org.lwjglb.engine.GameEngine.run(GameEngine.java:45)
        at org.lwjglb.game.Main.main(Main.java:20)

Your working directory is "C:\Users\ramho\Desktop" and you are using a relative path. When you use a relative path it will use as the root your working dir, so it is trying to ding the models under "C:\Users\ramho\Desktop\models", not in the target dir. You should move to the target directory or use an absolute path.

Hope it helps.

Ramh5 commented

Awesome, I was aware of some of that but I am barely starting to understand all these concepts. I had a batch file with java -jar F:\GIT\lwjglb\lwjglbook\chapter28\target\game-c28-1.0.jar and I was expecting that to set the working directory properly. With your help I figured out I had to do this instead : cd /d "F:\GIT\lwjglb\lwjglbook\chapter28\target" java -jar game-c28-1.0.jar

Now I can run this batch file from my desktop and it works. Cheers. Now I just have to figure out how to have Maven copy models and textures folders to the target folder. Is it something that can be done? That way it would be all automated.

Just included aumatic copy of models and textures using maven resources plugin