How to put texture in .obj file when using libgdx libs for android?

How to add texture to .obj file from .mtl file because libgdx cannot display .mtl file.

+3


source to share


1 answer


Two problems:

  • You cannot use it .mtl

    yet (Jun 2012) in libgdx.
  • .obj

    the format does not include textures (textures are described in the file .mtl

    ).

But the solution is to completely ignore the MTL file and manually add the texture when you load your model.



example code:

public load3dModel( String objfile, String texfile )
{
   ModelLoaderHints hint = new ModelLoaderHints(false);             
   m_mesh = ModelLoaderRegistry.loadStillModel(Gdx.files.internal(objfile), hint);
   Texture texture = new Texture(Gdx.files.internal(texfile), Format.RGBA4444, false);
   Material mat = new Material("mat",
                               new TextureAttribute(texture, 0, "u_Texture"));
   m_mesh.setMaterial(mat);
   ...

      

+3


source







All Articles