PDA

View Full Version : MTL format specification


martinB
11-21-2007, 10:04 PM
Can anyone point me to an official specification of the MTL file format that carries the material definitions of the Wavefront OBJ format?

In particular, I'd like to know how texture map filenames with spaces in the name should be saved, and whether filenames with a full path can be used (and if so, what to do with spaces in the path).

Thanks in advance
Martin

Carina
11-21-2007, 11:23 PM
I'd avoid spaces in filenames. While some OBJ importers may be able to handle them, many do not (especially as OBJ/MTL files are generally tokenised by spaces).

Full pathname support, again, may vary across implementations of importers/exporters. If you have a specific application in mind that you want to import into/export from, you are probably best off looking at what works/doesn't work with them. I'd play it as safe as possible if you aim for cross compatibility between several applications and platforms.

rendermaniac
11-22-2007, 08:43 AM
There is some information about MTL here - http://www.wotsit.org/list.asp?fc=2 . How acurate it is I do not know.

Simon

martinB
11-22-2007, 10:41 AM
Thanks very much, Simon and Carina.

Carina: I agree that spaces in paths and/or filenames is asking for trouble.

But what can you do if the default user data path on a Windows XP machine is 'C:\Documents and Settings\username' and Autodesk installs 3ds Max by default into 'C:\Program Files (x86)\Autodesk\3ds Max 2008'...

plenty of spaces. :\

Simon: Thanks for the link. Unfortunately, they do not say anything about how a filename has to be constructed and they do not mention anything about full path names.

Cheers
Martin

Carina
11-22-2007, 11:45 AM
Thanks very much, Simon and Carina.

Carina: I agree that spaces in paths and/or filenames is asking for trouble.

But what can you do if the default user data path on a Windows XP machine is 'C:\Documents and Settings\username' and Autodesk installs 3ds Max by default into 'C:\Program Files (x86)\Autodesk\3ds Max 2008'...

plenty of spaces. :\


I think you'll find that MTL files are normally in a path relative to their OBJ files. The application will normally know where your OBJ file was, and will normally look for the MTL file in a location relative to that path.. (I say will normally as this is completely implementation dependent, but it's the sane way of doing it)

So for example, if my OBJ file and MTL file are both in C:\Documents and Settings\Carina, I would use "mtllib mymaterialfile.mtl" in my OBJ file without any path. The application should be clever enough to know where to look for it..

martinB
11-22-2007, 12:43 PM
I think you'll find that MTL files are normally in a path relative to their OBJ files. The application will normally know where your OBJ file was, and will normally look for the MTL file in a location relative to that path.. (I say will normally as this is completely implementation dependent, but it's the sane way of doing it)

So for example, if my OBJ file and MTL file are both in C:\Documents and Settings\Carina, I would use "mtllib mymaterialfile.mtl" in my OBJ file without any path. The application should be clever enough to know where to look for it..

Very true, in fact I am not sure I understand the reason for splitting the data up into two files (obj and mtl). But what about the bitmap filenames and pathnames that are referenced WITHIN the MTL file?

Martin

Carina
11-23-2007, 07:08 AM
Very true, in fact I am not sure I understand the reason for splitting the data up into two files (obj and mtl). But what about the bitmap filenames and pathnames that are referenced WITHIN the MTL file?


Splitting the data up in obj and mtl allows you to easily reuse mtl files should you want to. It also allows you to distinguish so that the geometry and material details can easily be found if you need to edit them. With regards to files referenced within the html, i'd still go for relative paths. They're a lot easier to support than absolute ones.. For example:
Matierial in Foldername/Materials could be referenced by OBJ in Foldername/OBJs/ using ../Materials/mtlfile.mtl. The problem is that different applications may use for different deliminators. For example Windows would use \ while linux would use / etc. Some applications may support both, some may support only the one.

All OBJ exporters I've used, mind you, only allows you to choose one output folder, i.e. it doesn't distinguish between where each file will go, both types will go to the same folder.

I suppose it all depends what you actually want to do? Are you going to import from OBJ, export to OBJ, or both? What sort of application are you working on?

CGTalk Moderation
11-23-2007, 07:08 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.