Browse Source

convert_obj_three: split d and Tr. Removed TRANSPARENCY. See #7520

Mr.doob 9 years ago
parent
commit
10bef8e6a9
1 changed files with 12 additions and 12 deletions
  1. 12 12
      utils/converters/obj/convert_obj_three.py

+ 12 - 12
utils/converters/obj/convert_obj_three.py

@@ -138,7 +138,6 @@ import glob
 ALIGN = "none"        	# center centerxz bottom top none
 SHADING = "smooth"      # smooth flat
 TYPE = "ascii"          # ascii binary
-TRANSPARENCY = "normal" # normal invert
 
 TRUNCATE = False
 SCALE = 1.0
@@ -428,14 +427,19 @@ def parse_mtl(fname):
             if chunks[0] == "Ns" and len(chunks) == 2:
                 materials[identifier]["specularCoef"] = float(chunks[1])
 
+            # Dissolves
+            # d 0.9
+            if chunks[0] == "d" and len(chunks) == 2:
+                materials[identifier]["opacity"] = float(chunks[1])
+                if materials[identifier]["opacity"] < 1.0:
+                    materials[identifier]["transparent"] = True
+
             # Transparency
-            # Tr 0.9 or d 0.9
-            if (chunks[0] == "Tr" or chunks[0] == "d") and len(chunks) == 2:
-                materials[identifier]["transparent"] = True
-                if TRANSPARENCY == "invert":
-                    materials[identifier]["opacity"] = float(chunks[1])
-                else:
-                    materials[identifier]["opacity"] = 1.0 - float(chunks[1])
+            # Tr 0.1
+            if chunks[0] == "Tr" and len(chunks) == 2:
+                materials[identifier]["opacity"] = 1.0 - float(chunks[1])
+                if materials[identifier]["opacity"] < 1.0:
+                    materials[identifier]["transparent"] = True
 
             # Optical density
             # Ni 1.0
@@ -1574,10 +1578,6 @@ if __name__ == "__main__":
             if a in ("binary", "ascii"):
                 TYPE = a
 
-        elif o in ("-d", "--dissolve"):
-            if a in ("normal", "invert"):
-                TRANSPARENCY = a
-
         elif o in ("-b", "--bakecolors"):
             BAKE_COLORS = True