.obj with more textures

Started by drdla, September 01, 2016, 04:02:10 PM

Previous topic - Next topic

drdla

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

EgonOlsen

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

EgonOlsen

In addition to that: If you don't know the names, look at the log output at load time. It should print them out.