From fe5684ec04ae2ff4dd59d1fdeec2db4dbc903bfe Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 10 Apr 2024 01:04:18 +0200 Subject: OBJ converter now supports specular and emissive maps --- MagicEx/src/ModelFileOBJ.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MagicEx/src/ModelFileOBJ.cpp b/MagicEx/src/ModelFileOBJ.cpp index 9ab7e69..03c8cde 100644 --- a/MagicEx/src/ModelFileOBJ.cpp +++ b/MagicEx/src/ModelFileOBJ.cpp @@ -212,6 +212,20 @@ static int LoadMatls(const char* lpszPathName, Model* m) LoadTexture(src, mtl->tex_diffuse, Bitmap::BMP_SOLID); } + + else if (strstr(line, "map_Ks")) { + const char* src = strstr(line, "map_Ks") + 7; + while (!isalnum(*src)) src++; + + LoadTexture(src, mtl->tex_specular, Bitmap::BMP_SOLID); + } + + else if (strstr(line, "map_Ke")) { + const char* src = strstr(line, "map_Ke") + 7; + while (!isalnum(*src)) src++; + + LoadTexture(src, mtl->tex_emissive, Bitmap::BMP_SOLID); + } } fclose(fp); @@ -641,6 +655,10 @@ SaveWaveFrontMatLib(const char* path, const char* root, Model* model) fprintf(f, "illum 2\n"); if (mtl->tex_diffuse) fprintf(f, "map_Kd %s\n", mtl->tex_diffuse->GetFilename()); + if (mtl->tex_specular) + fprintf(f, "map_Ks %s\n", mtl->tex_specular->GetFilename()); + if (mtl->tex_emissive) + fprintf(f, "map_Ke %s\n", mtl->tex_emissive->GetFilename()); fprintf(f, "\n"); } -- cgit v1.1