]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_object.py
Take material diffuse intensity into account
[libs/gl.git] / blender / io_mspgl / export_object.py
index 7b9ee6a44cfb2c8eb888c237b7e1579e358c1fff..0de98f8446a609692ccd527f8aeddc1bcd599da4 100644 (file)
@@ -17,8 +17,11 @@ class ObjectExporter:
                self.external_tech = True
                self.shared_tech = True
 
-       def export(self, context, out_file):
-               obj = context.active_object
+       def export(self, context, out_file, objs=None, progress=None):
+               if objs is None:
+                       obj = context.active_object
+               else:
+                       obj = objs[0]
 
                from .outfile import open_output
                out_file = open_output(out_file)
@@ -32,11 +35,11 @@ class ObjectExporter:
                        path, base = os.path.split(out_file.filename)
                        base, ext = os.path.splitext(base)
                        mesh_out = open_output(os.path.join(path, base+".mesh"))
-                       mesh = mesh_export.export(context, mesh_out)
-                       out_file.write("mesh", "\""+base+".mesh\"")
+                       mesh = mesh_export.export(context, mesh_out, objs, progress)
+                       out_file.write("mesh", '"{}.mesh"'.format(base))
                else:
                        out_file.begin("mesh")
-                       mesh = mesh_export.export(context, out_file)
+                       mesh = mesh_export.export(context, out_file, objs, progress)
                        out_file.end()
 
                if self.external_tech and obj.technique:
@@ -79,7 +82,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)
@@ -93,7 +96,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)