Problem with textures

Started by Mr. K, April 25, 2016, 10:23:40 AM

Previous topic - Next topic

Mr. K

Hello it's me again, before thanks for the support
I have an issue with the texture when i use Loeader.LoadOBJ i have the following code


try{
                    model = Object3D.mergeAll( Loader.loadOBJ(getResources().getAssets().open("Katarina_Pirate_object.obj"),getResources().getAssets().open("Katarina_Pirate_material.mtl"),10));
                }catch (Exception e){
                    Log.e(TAG,e.getMessage());
                }
                model.setTexture("katarina_pirate_diffuse.png"); // it's the name of the texture in the TextureManager
                model.build();
                world.addObject(model);

but the texture isn't show

EgonOlsen

Maybe the model has no texture coordinates?

Mr. K

the  coordinates were given in the mtl file? or in the obj file? wherever, i tried with another obj model and i have the same problem

EgonOlsen

In the obj file. The mtl only defines the texture names and such.

Mr. K

Yes, the file obj has the coordinates of the texture, could be a problem whit the lights? or i must add another line of code?

Mr. K

thanks for the reply i found the solution, really thanks Egon

Mr. K

Just for the record for load the texture, i put the attribute of material on null and then i followed the tutorial of the wiki


try{
                    skin= new Texture(getResources().getAssets().open("Katarina_pirate_diffuse.png"));
                    model = Object3D.mergeAll( Loader.loadOBJ(getResources().getAssets().open("Katarina_Pirate_object.obj"),null,10));
                }catch (Exception e){
                    Log.e(TAG,e.getMessage());
                }

                TextureManager.getInstance().addTexture("Katarina_pirate_diffuse",skin);
                model.setTexture("katarina_pirate_diffuse.png");
                model.build();
                world.addObject(model);