Author Topic: Obj Models not loading after exporting  (Read 2361 times)

Offline ForOhFor Error

  • byte
  • *
  • Posts: 10
    • View Profile
Obj Models not loading after exporting
« 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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Models not loading after exporting
« Reply #1 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");

Offline ForOhFor Error

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Obj Models not loading after exporting
« Reply #2 on: May 13, 2013, 03:41:41 pm »
And that's for loading files that are contained in the jar, correct?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Models not loading after exporting
« Reply #3 on: May 13, 2013, 03:44:58 pm »
Yes.

Offline ForOhFor Error

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Obj Models not loading after exporting
« Reply #4 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 :/

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Models not loading after exporting
« Reply #5 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.

Offline ForOhFor Error

  • byte
  • *
  • Posts: 10
    • View Profile
Re: Obj Models not loading after exporting
« Reply #6 on: May 14, 2013, 11:53:47 pm »
Thanks, I got it working now.