Author Topic: .obj with more textures  (Read 432 times)

Offline drdla

  • byte
  • *
  • Posts: 16
    • View Profile
.obj with more textures
« on: September 01, 2016, 04:02:10 pm »
Hi,
if I load .obj file with one texture everithing is ok.
But if .obj have more that one texture, only last texture is on object.

I use this code:
Code: [Select]
Texture texture1 = new Texture(getInputStream("obj/3/texture.jpg"));
                TextureManager.getInstance().addTexture("texture", texture1);
                Texture texture2 = new Texture(getInputStream("obj/3/kola.jpg"));
                TextureManager.getInstance().addTexture("texture2", texture2);
               Texture texture3 = new Texture(getInputStream("obj/3/hlava.jpg"));
                TextureManager.getInstance().addTexture("texture3", texture3);
                object3D = loadModelOBJ("obj/3/robot.obj", "obj/3/robot.mtl", 10);
                object3D.setTexture("texture");
                object3D.setTexture("texture2");
                object3D.setTexture("texture3");

If I detele
Code: [Select]
object3D.setTexture("texture");... there is no texture on object.
If I write setTexture... than only last set texture is on model.

How can I load more texture to one model?

Thank you for any answers.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: .obj with more textures
« Reply #1 on: September 01, 2016, 05:30:01 pm »
setTexture() sets the texture for the whole object. If you need more textures on one object, you have to work with the names at load time to allow the loader to assign them. This wiki entry explains the basic idea: http://www.jpct.net/wiki/index.php?title=Loading_models

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: .obj with more textures
« Reply #2 on: September 01, 2016, 05:31:36 pm »
In addition to that: If you don't know the names, look at the log output at load time. It should print them out.