Merge pull request #7519 from Hubhubhurra/master

Issue #7510 - rectified transparency in importOBJ.py
This commit is contained in:
Yorik van Havre
2022-09-27 10:54:43 +02:00
committed by GitHub

View File

@@ -247,7 +247,7 @@ def export(exportList,filename,colors=None):
outfile = pythonopen(filenamemtl,"w")
outfile.write("# FreeCAD v" + ver[0] + "." + ver[1] + " build" + ver[2] + " Arch module\n")
outfile.write("# https://www.freecadweb.org\n")
kinds = {"AmbientColor":"Ka ","DiffuseColor":"Kd ","SpecularColor":"Ks ","EmissiveColor":"Ke ","Transparency":"Tr "}
kinds = {"AmbientColor":"Ka ","DiffuseColor":"Kd ","SpecularColor":"Ks ","EmissiveColor":"Ke ","Transparency":"Tr ","Dissolve":"d "}
done = [] # store names to avoid duplicates
for mat in materials:
if isinstance(mat,tuple):
@@ -255,6 +255,7 @@ def export(exportList,filename,colors=None):
outfile.write("newmtl " + mat[0] + "\n")
outfile.write("Kd " + str(mat[1][0]) + " " + str(mat[1][1]) + " " + str(mat[1][2]) + "\n")
outfile.write("Tr " + str(mat[2]/100) + "\n")
outfile.write("d " + str(1-mat[2]/100) + "\n")
done.append(mat[0])
else:
if not mat.Name in done:
@@ -337,7 +338,7 @@ def insert(filename,docname):
elif mline[:3] == "Kd ":
color = tuple([float(i) for i in mline[3:].split()])
elif mline[:2] == "d ":
trans = int(float(mline[2:])*100)
trans = int((1-float(mline[2:]))*100)
if mname and color:
colortable[mname] = [color,trans]
elif line[:2] == "o ":