Author Topic: Obj Loader!!!  (Read 3426 times)

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Obj Loader!!!
« on: May 03, 2014, 12:01:48 pm »
Hi,
   I am trying to load obj with mtl file.
Code: [Select]
Object 3D[] obj = Loader.loadObj("level.obj", "level.mtl", 1f);
level = obj[0];
level.buil();
world.addObject(level);
I am getting error in second line, array index out of bound.

Thanks.
« Last Edit: May 04, 2014, 02:33:18 pm by Birdron »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Loader!!!
« Reply #1 on: May 03, 2014, 02:24:31 pm »
Because it doesn't load anything. Have a look at the log output or, even better, do a Logger.setOnError(Logger.ON_ERROR_THROW_EXCEPTION); at the start of your application.

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Obj Loader!!!
« Reply #2 on: May 03, 2014, 03:08:23 pm »
In cmd console, it is showing every texture is loaded and all poligons r created. Just not rendering on viewport. I can export the jar file and run it. Just it is not rendering the object.
Edit: ok, I understand, when I run it from eclipse I get this error, because it cant find the file.
But when I export the jar and run it runs ok.
Still nothing is rendering on viewport.
Edit: ok, everything works, just not showing the textures. Can u just tell me how load a multitextured obj file. Ur all example uses 3ds file.
Thanks.
« Last Edit: May 03, 2014, 07:07:10 pm by Birdron »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Loader!!!
« Reply #3 on: May 03, 2014, 07:24:13 pm »
It's basically the same idea. You need a valid .mtl file in addition to your obj file and your textures have to have the names in the TextureManager that match those of the ones in the mtl file.

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Obj Loader!!!
« Reply #4 on: May 03, 2014, 07:40:01 pm »
I hv a mtl file and I can see on console engine loading all the textures. Does engine assign the textures automaticaly or I hv to assign it manually?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Loader!!!
« Reply #5 on: May 03, 2014, 09:14:26 pm »

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Obj Loader!!!
« Reply #6 on: May 03, 2014, 11:22:09 pm »
Actually, that example is for single texture, which is working fine here too. What I am trying to do is multitexturing.
Thanks for the reply.
« Last Edit: May 03, 2014, 11:29:05 pm by Birdron »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Loader!!!
« Reply #7 on: May 04, 2014, 01:05:52 pm »
Depends on what you mean with multi-texturing....multiple textures on one object (but not on one polygon). If that's the case, it works exactly in the same way. If you mean multiple textures per polygon...OBJ-format doesn't support this anyway...

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Obj Loader!!!
« Reply #8 on: May 04, 2014, 02:42:28 pm »
Ok, last question, on my first post, should not that code  load an obj file with textures?

The app is loading all textures and drawing all the level, but without texture means white.

So, even if app is loading all textures, I still hv to load same textures twice!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Obj Loader!!!
« Reply #9 on: May 04, 2014, 03:02:36 pm »
No, just read the Wiki page again. The engine doesn't load any textures. You do! The engine only takes the names from the mtl file and looks for these names in the TextureManager. If it finds them, it will use them. Otherwise, it will insert a white dummy texture of the same name. You'll see this in the log output.

Offline Birdron

  • byte
  • *
  • Posts: 22
    • View Profile
Re: Obj Loader!!!
« Reply #10 on: May 04, 2014, 07:46:48 pm »
Took me a little time to understand that.

Thanks for your help.