Fabrice
on example.obj, at first non commented line there is:
mtllib example.mtl
this is saying to the obj class, there is some material informations
for the or a part of the geometry.
the mtl file is then loaded and parsed.
a typical mtl looks like this:
newmtl acmat_0
Kd 1 1 1
Ka 0.2 0.2 0.2
Ks 0.2 0.2 0.2
Ns 128
Tr 0
map_Kd someniceimage.jpg
for each mesh definition in the obj file, before the "f" tag (face
definition) is started
if the parser encounters a line like this:
usemtl acmat_0
it says: use the material id"acmat_0" for this mesh.
if you look again at the mtl definition above, you'll find the id
"acmat_0" back.
the block of material information holds the url to the image file. in
this example: someniceimage.jpg
the obj internally generates temp material (usefull for debug), and
loads the image automatically.
On success loaded the material with the right image is applied.
note that depending on generators, mtl and tags of materials may
differ and can be custom. for instance
if you are able to give a name to a given material in your editor,
chances are high the same name will be used in the output.
Fabrice