kuroyume0161 opened this issue on Jul 07, 2002 ยท 28 posts
Spanki posted Tue, 09 July 2002 at 1:28 PM
Let me see if I can clear up a few things (without muddying them up more ;)...
First off, the 'regions' that UVMapper creates... these are a completetly arbitrary means of grouping vertices. A user may group any number of vertices from any section of the model into any number of regions... you can't rely on that grouping to 'mean' anything (ie. they don't mean one region is one map and one is another). The region info is written to the .obj file as #comments (which, btw, every other app in the world will delete when it writes the file back out).
UVMapper regions are there simply as an operational/interface use within the UVMapper program to provide a new way (layer) to group vertices. As Nance says, one use of them is to identify materials using different maps.
Kuroyume, If your application loads an .obj file (which has all the usemtl records), does it also load the .mtl file? If so, you can just use it as a guide... each material has the texture map file listed in that. Using that file as a guide keeps you from having to 'hard-code' any particular mapping... and even if it's missing, you could let the user select from several 'default' .mtl files, to keep things data-driven.
I've spent quite a lot of time researching the .mtl lib file format and there are some inconsistancies, but here's what I've found:
Ns = Phong specular component. Ranges from 0 to 1000. (I've seen various statements about this range (see below))
Kd = Diffuse color weighted by the diffuse coefficient.
Ka = Ambient color weighted by the ambient coefficient.
Ks = Specular color weighted by the specular coefficient.
d = Dissolve factor (pseudo-transparency). Values are from 0-1. 0 is completely transparent, 1 is opaque.
Ni = Refraction index. Values range from 1 upwards. A value of 1 will cause no refraction. A higher value implies refraction.
illum = (0, 1, or 2) 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting (see below)
sharpness = ? (see below)
map_Kd = Diffuse color texture map.
map_Ks = Specular color texture map.
map_Ka = Ambient color texture map.
map_Bump = Bump texture map.
map_d = Opacity texture map.
refl = reflection type and filename (?)
...I've also seen values of 3 and 4 for 'illum'... when there's a 3 there, there's often a 'sharpness' attribute, but I didn't find any explanation. And I think the 4 illum value is supposed to denote two-sided polygons, but I kinda get the impression that some people just make stuff up and add whatever they want to these files, so there could be anything in there ;). Of course Poser only writes out a few of the above and apparently ignores many of the above when reading as well.
Also for the Ns (OpenGL Shininess) value, OpenGL wants this range to be 0-128... one source said tha the wavefront spec was 0-1000 (and I've seen many .obj files with values in the 400-700 range), but the PolyTrans people say 0-200 and they've been refining thier converter program for over a decade (shrug). Of course Poser seems to use a range of 1-100, so I don't suppose you can ever get this value 'correct' for all apps. I haven't checked Bryce or other apps yet... since my app is mostly geared towards Poser, I decided to cap it at 100.
For the 'd' record (transparency), when I read this value in my program, I store it as the alpha value of the Diffuse component (which OpenGL uses) and just write that value back out from there on export.
Cheers,
Cinema4D Plugins (Home of Riptide, Riptide Pro, Undertow, Morph Mill, KyamaSlide and I/Ogre plugins) Poser products Freelance Modelling, Poser Rigging, UV-mapping work for hire.