www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: drdla on September 01, 2016, 04:02:10 pm

Title: .obj with more textures
Post by: drdla 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.
Title: Re: .obj with more textures
Post by: EgonOlsen 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 (http://www.jpct.net/wiki/index.php?title=Loading_models)
Title: Re: .obj with more textures
Post by: EgonOlsen 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.