Hi! Thanks for giving me a real testing file! It let me fix several issues with the material export/import.
There are three issues with the file you gave.
Material is a per-polygon attribute in OBJ. So if two materials are linked to an object and both of them apply to _all_ of the faces, then only one is referenced by the OBJ file.
# OBJ file
usemtl mat 1
f 1 2 3
f 2 3 4
But if one material is assigned to one face, and the other to another, then you can expect
# OBJ file
usemtl mat 1
f 1 2 3
usemtl mat 2
f 2 3 4
What happens in the MTL file is different. Python exporter stores only the materials used in the usemtl
lines and writes them to the MTL file. C++ exporter writes all materials linked to an Object to the MTL file even if they’re not referenced by the OBJ file. But in the OBJ file, only one material is referenced since you have not made any per-polygon distinction, so both importers grab only one material.
You use the same name for the materials! How is a parser supposed to disambiguate between two materials ?
# MTL file
newmtl mat1
Ni 1
newmtl mat1
Ni 2
The python exporter uses Dictionary for material list and will override the material and keep only the last encountered material. C++ one writes one object’s all materials at once so it doesn’t know if a material with the same name has been written or not.
But any importer that uses a hashing container with material name as key will only import one of the materials. Python used dict for importing, C++ used Map.
Packed images!
map_Ns Main File/Textures/T_Corona_Virus_roughness.png
This path doesn’t exist!
Python exporter will write this and expect user to create the folders and unpack images into them.
C++ exporter writes only the filename and expects user to unpack images in the current directory. (Or unpack into default textures
directory and move to the same folder as the MTL file).
We will not modify the blend file and inform user that a packed file is found and that they should do as they please.