www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: ForOhFor Error on May 13, 2013, 02:57:58 am

Title: Obj Models not loading after exporting
Post by: ForOhFor Error on May 13, 2013, 02:57:58 am
(Posted this in the wrong section at first - whoops)

So, my problem is fairly simple. I have a call to load a model in my project:
tabletop = Object3D.mergeAll(Loader.loadOBJ("res/model/Tabletop.obj","res/model/Tabletop",260f));
and all is well in eclipse - it loads just fine.

However, when I export the jar (and package it all up with JarSplice), the model doesn't load (none of the models I'm using load, in fact).

I have tried placing the res folder in both the jar itself, and in a folder alongside the jar, and both just load with a blank buffer being rendered.
Title: Re: Obj Models not loading after exporting
Post by: EgonOlsen on May 13, 2013, 10:04:26 am
To load files from a jar, access them via an InputStream like so:

Code: [Select]
getClass().getClassLoader().getResourceAsStream("res/model/Tabletop.obj");
Title: Re: Obj Models not loading after exporting
Post by: ForOhFor Error on May 13, 2013, 03:41:41 pm
And that's for loading files that are contained in the jar, correct?
Title: Re: Obj Models not loading after exporting
Post by: EgonOlsen on May 13, 2013, 03:44:58 pm
Yes.
Title: Re: Obj Models not loading after exporting
Post by: ForOhFor Error on May 14, 2013, 04:18:22 am
Same result :/
Just a blank, blue screen (I can blit onto it, so the buffer is rendering fine).
And it works perfectly in eclipse :/
Title: Re: Obj Models not loading after exporting
Post by: EgonOlsen on May 14, 2013, 07:21:10 am
Then your path to the resources is wrong. If they sit in your jar in a directory "res/model", use "/res/model/Tabletop.obj". This isn't related to jPCT at all, you should be able to find examples for this all over the internet.
Title: Re: Obj Models not loading after exporting
Post by: ForOhFor Error on May 14, 2013, 11:53:47 pm
Thanks, I got it working now.