Skip to content

Commit

Permalink
Merge pull request #7519 from Hubhubhurra/master
Browse files Browse the repository at this point in the history
Issue #7510 - rectified transparency in importOBJ.py
  • Loading branch information
yorikvanhavre committed Sep 27, 2022
2 parents 0715f8c + bfbb86c commit 5a14ff9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Mod/Arch/importOBJ.py
Expand Up @@ -247,14 +247,15 @@ 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):
if not mat[0] in done:
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:
Expand Down Expand Up @@ -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 ":
Expand Down

0 comments on commit 5a14ff9

Please sign in to comment.