Mtl files

Hey everyone, so I have an model loader that currently loads .obj files.  That so far, it does correctly.  But what it's lacking, is the textures.  Now, from what I understand, the textures and such are held in an mtl file.  I have that file, and so far, the loader seems to be reading the file.  However, in this same file, there are some tags that look like this :



map_Kd -s 0.1 0.1 concrete.jpg

map_Kd -mm 0 0.47934 concrete.jpg



and such.  Now, if I remember correctly, map_Kd is something that describes the diffuse color of some texture (or something along those lines).  The problem is, though, that the loader keeps trying to load the file "-s 0.1 0.1 concrete.jpg" instead of just "concrete.jpg" like it shoud be.  Why is it taking in the arguments in its path name, and does anyone know how to fix this ?

interesting, what program are you using to export your .obj files? I use wings3d and havent had this problem. here is a simple example of an .mtl file from wings3d

# Exported from Wings 3D 0.98.32b

newmtl sphere1_auv

Ns 100.000

d 1.00000

illum 2

Kd 1.00000 1.00000 1.00000

Ka 1.00000 1.00000 1.00000

Ks 1.00000 1.00000 1.00000

Ke 0.00000e+0 0.00000e+0 0.00000e+0

map_Kd sphere1_auv.tga



if the rest of your mtl is ok you can just change

map_Kd -mm 0 0.47934 concrete.jpg

to

map_Kd concrete.jpg

but youll have to do that everytime you export

It's not actually me doing the models, so I can't say for sure, but I believe it's maya.

So I did what you suggested, but still no dice, it doesn't give me the file not found exception, but it doesn't quite load properly.



And after checking, the models are made in rhino and the textures are done in maya.

it looks like the loader implements just a part of the obj/mtl file specification: http://www.fileformat.info/format/material/

Ok so using Wings3D now everything seems fixed

what does your mtl file look like now?

because, i had to modify my .mtl file as well.



i added path information into the mtl file, so that the importer finds the textures.



from

map_Kd xwbody.jpg

to

map_Kd bin/data/textures/xwbody.jpg



i wonder if thats the way to go, or if there is another solution to that problem.

Use the texdir property of ObjToJme converter to specify the location of the image files for the material.

Use the mtllib property for the location of the mtl files.



See: http://www.jmonkeyengine.com/doc/com/jmex/model/XMLparser/Converters/ObjToJme.html


doh, its actually well documented in the javadoc of ObjTJme :slight_smile:

I believe this is a bug. I had the same thing. The -s switch has something to do about the texture wrapping. You either need to wait until someone has fixed this bug, or try using another file format.