mtl files in obj

4 views
Skip to first unread message

kakarlus

unread,
May 12, 2009, 2:02:10 AM5/12/09
to away3d.dev
are materials with type .mtl in .obj file loaded automatically?

Fabrice3D

unread,
May 12, 2009, 3:25:38 AM5/12/09
to away3...@googlegroups.com
yes, if your obj exporter and mtl do respect the wavefront format.
which means, that the mtl is located in same dir as the obj.file

Fabrice

kakarlus

unread,
May 12, 2009, 4:22:03 AM5/12/09
to away3d.dev
are .mtl's images? sorry for my ignorance x_X

Fabrice3D

unread,
May 12, 2009, 5:01:26 AM5/12/09
to away3...@googlegroups.com
no, these files are holding material information

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

kakarlus

unread,
May 12, 2009, 5:19:31 AM5/12/09
to away3d.dev
sweeeet tnx for the info
Reply all
Reply to author
Forward
0 new messages