Is it possible to load obj files with mtl files (it seems not to work !)?

Hello,

I read in the documentation that loadModel() can load a obj file and use the mtl file and read the textures but it seems not to work at all.

model() draws the meshes but without any textures. I’ve seen a lot of questions about that in the forum but no clear response (I think).

I tried with several obj files…

is there a way to do this ?

:slight_smile:

thanks

(I mean : without applying the texture manually with the texture() function)

Hi! Yes, possible in p5v2. Here’s a fairly minimal working example:
https://openprocessing.org/sketch/2673859

(I don’t know for sure about p5v1.)

Troubleshooting:

You can check your .obj file in a text editor to see if it mentions the expected .mtl filename.

For example, here are the first lines of the .obj file from the above example:

# Blender 4.3.2
# www.blender.org
mtllib pine_tree.mtl

(The first two lines are just comments.)
On the third line you can see the material file mentioned - so p5 tries to load pine_tree.mtl.