Browse Source

Added workaround to OBJ converter for unnamed materials.

alteredq 13 years ago
parent
commit
66ad349219
1 changed files with 12 additions and 5 deletions
  1. 12 5
      utils/exporters/obj/convert_obj_three.py

+ 12 - 5
utils/exporters/obj/convert_obj_three.py

@@ -368,8 +368,11 @@ def parse_mtl(fname):
 
             # Material start
             # newmtl identifier
-            if chunks[0] == "newmtl" and len(chunks) == 2:
-                identifier = chunks[1]
+            if chunks[0] == "newmtl":
+                if len(chunks) > 1:
+                    identifier = chunks[1]
+                else:
+                    identifier = ""
                 if not identifier in materials:
                     materials[identifier] = {}
 
@@ -490,6 +493,7 @@ def parse_obj(fname):
     faces = []
 
     materials = {}
+    material = ""
     mcounter = 0
     mcurrent = 0
 
@@ -536,7 +540,7 @@ def parse_obj(fname):
                 uv_index = []
                 normal_index = []
 
-                
+
                 # Precompute vert / normal / uv lists
                 # for negative index lookup
                 vertlen = len(vertices) + 1
@@ -581,8 +585,11 @@ def parse_obj(fname):
                 mtllib = chunks[1]
 
             # Material
-            if chunks[0] == "usemtl" and len(chunks) == 2:
-                material = chunks[1]
+            if chunks[0] == "usemtl":
+                if len(chunks) > 1:
+                    material = chunks[1]
+                else:
+                    material = ""
                 if not material in materials:
                     mcurrent = mcounter
                     materials[material] = mcounter