Obj Loader!!!

Started by Birdron, May 03, 2014, 12:01:48 PM

Previous topic - Next topic

Birdron

Hi,
   I am trying to load obj with mtl file.
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.

EgonOlsen

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.

Birdron

#2
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.

EgonOlsen

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.

Birdron

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?


Birdron

#6
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.

EgonOlsen

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...

Birdron

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!

EgonOlsen

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.

Birdron

Took me a little time to understand that.

Thanks for your help.