]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_object.py
Use image path as texture identifier if available
[libs/gl.git] / blender / io_mspgl / export_object.py
index a8af6d1f9b6a87e2334fa4deeafe74062c66821c..00410a23ff0d071ea9b500967f406ef1daed2393 100644 (file)
@@ -6,6 +6,13 @@ def linear_to_srgb(l):
        else:
                return 1.055*(l**(1/2.4))-0.055
 
+def image_name(i):
+       fp = i.filepath
+       if fp:
+               return os.path.split(fp)[1]
+       else:
+               return i.name
+
 
 class ObjectExporter:
        def __init__(self):
@@ -82,7 +89,7 @@ class ObjectExporter:
                                out_file.write("storage", "RGB", len(mesh.materials), 1)
                                texdata = '"'
                                for m in mesh.materials:
-                                       color = [int(cm(c)*255) for c in m.diffuse_color]
+                                       color = [int(cm(c)*255) for c in m.diffuse_color*mat.diffuse_intensity]
                                        texdata += "\\x%02X\\x%02X\\x%02X"%tuple(color)
                                texdata += '"'
                                out_file.write("raw_data", texdata)
@@ -96,7 +103,7 @@ class ObjectExporter:
                                        amb = cm(mat.ambient)
                                        out_file.write("ambient", amb, amb, amb, 1.0)
                                else:
-                                       diff = mat.diffuse_color
+                                       diff = mat.diffuse_color*mat.diffuse_intensity
                                        out_file.write("diffuse", cm(diff.r), cm(diff.g), cm(diff.b), 1.0)
                                        amb = diff*mat.ambient
                                        out_file.write("ambient", cm(amb.r), cm(amb.g), cm(amb.b), 1.0)
@@ -133,7 +140,7 @@ class ObjectExporter:
                                                out_file.write("raw_data", texdata)
                                                out_file.end()
                                        else:
-                                               out_file.write("texture", '"%s"'%tex.image.name)
+                                               out_file.write("texture", '"%s"'%image_name(tex.image))
                                        out_file.end()
 
                out_file.end()