Improved obj exporter to export materials to fileName.mtl instead of fileName.obj.mtl
authorAndrej <Andrej@HOMEWIN10>
Tue, 16 May 2017 13:55:40 +0000 (15:55 +0200)
committerAndrej <Andrej@HOMEWIN10>
Tue, 16 May 2017 13:55:40 +0000 (15:55 +0200)
code/ObjExporter.cpp

index 564de1c..c1a6677 100644 (file)
@@ -124,6 +124,11 @@ std::string ObjExporter :: GetMaterialLibName()
 // ------------------------------------------------------------------------------------------------
 std::string ObjExporter :: GetMaterialLibFileName()
 {
+    // Remove existing .obj file extention so that the final material file name will be fileName.mtl and not fileName.obj.mtl
+    size_t lastdot = filename.find_last_of(".");
+    if (lastdot != std::string::npos)
+        filename = filename.substr(0, lastdot);
+
     return filename + MaterialExt;
 }