SanguinettiMods Posted September 10, 2011 Share Posted September 10, 2011 I was wondering if any of you out there could help me come up with a .mtl file to go along with a .obj. The .mtl file would use the same texture coordinates as you would see if you viewed a display list in UoT. If you need further information on what I mean, please reply, and I'll explain it in Greater Detail. Link to comment Share on other sites More sharing options...
0 spinout Posted September 10, 2011 Share Posted September 10, 2011 Texture coordinates are in OBJ files. What are you talking about? Perhaps an example of what you would like to do would help. Link to comment Share on other sites More sharing options...
0 SanguinettiMods Posted September 10, 2011 Author Share Posted September 10, 2011 Alright. I have control over the texture coordinates in the .obj file itself, but it won't show up textured unless a .mtl file is included. As far as I know, it's like this in the .obj file. v = vertex vt = vertex texture v ex: v X Y Z vt ex: vt U V So, My obj file is like this. (Excluding the header, I added the usemtl and things, in preperation for a .mtl file) mtllib test.mtl g Mesh1 Model usemtl mat1 v -50 -30 0 vt -683 2048 v 50 -30 0 vt 2731 2048 v 0 70 0 vt 1024 -1365 f 1/1/1 2/2/1 3/3/1 f 4/4/1 5/5/1 6/6/1 f 7/7/1 8/8/1 9/9/1 Now, I have it all set up like I want it, unless it's missing something. But all I need is a .mtl file, and I'm not sure how to go about doing that. Link to comment Share on other sites More sharing options...
0 spinout Posted September 10, 2011 Share Posted September 10, 2011 Aha. The 'mtllib' command loads the file associated with it - 'test.mtl' in this case. The 'usemtl' command specifies to use a material named 'mat1', which should be defined in the file 'test.mtl' as so: newmtl mat1 map_Kd texture_file_name.png Tr <transparency, 0.0 - 1.0> (Other mtl commands) Link to comment Share on other sites More sharing options...
0 SanguinettiMods Posted September 10, 2011 Author Share Posted September 10, 2011 What do you mean by "Other mtl commands" ? There are other things located withing an MTL, and I'm not completely sure what they mean... (This MTL is for some random Triangle that I exported from Google Sketchup) newmtl Material1 Ka 0.000000 0.000000 0.000000 Kd 0.000000 0.000000 0.000000 Ks 0.330000 0.330000 0.330000 mapKd Material1.bmp and edited to work with model_convert.py Link to comment Share on other sites More sharing options...
0 Arcaith Posted September 12, 2011 Share Posted September 12, 2011 When you export an obj file, it should export a matching mtl file with it. Writing one from scratch is completely redundant. Link to comment Share on other sites More sharing options...
0 spinout Posted September 13, 2011 Share Posted September 13, 2011 libobj maps MTL files to a structure like this - the names (with their comments) should explain it: [tt] char *name; //newmtl <name> char *diffuse_tex; //mapKd / map_Kd (texture in white light) char *specular_tex; // mapKs / map_Ks (texture when "shiny") char *ambient_tex; // mapKa / map_Ka (texture in shadow) objrgb ambient; //color in shadow ("ka") objrgb diffuse; //color in white light ("kd") objrgb specular;//color when shining ("ks") float alpha; //"Tr" or "a" float shinyness; //"ns" int is_shiny; //"illum" [/tt] It should be noted that the illum value has very specific values. Link to comment Share on other sites More sharing options...
Question
SanguinettiModsI was wondering if any of you out there could help me come up with a .mtl file to go along with a .obj.
The .mtl file would use the same texture coordinates as you would see if you viewed a display list in UoT.
If you need further information on what I mean, please reply, and I'll explain it in Greater Detail.
Link to comment
Share on other sites
6 answers to this question
Recommended Posts