]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/util.py
Implement material maps for exporting objects with multiple materials
[libs/gl.git] / blender / io_mspgl / util.py
index 3b5e8cd56f3349d6ab1f094b8a25cde41015f558..70b005f6df60e84db38ea8c35c03fc0bbcc79123 100644 (file)
@@ -1,3 +1,5 @@
+import os
+
 class Progress:
        def __init__(self, context):
                self.task = ""
@@ -48,3 +50,23 @@ class Progress:
                        if self.window_manager:
                                self.window_manager.progress_update(value)
                        self.last = value
+
+
+def linear_to_srgb(l):
+       if l<0.0031308:
+               return 12.92*l
+       else:
+               return 1.055*(l**(1/2.4))-0.055
+
+def get_colormap(srgb):
+       if srgb:
+               return linear_to_srgb
+       else:
+               return lambda x: x
+
+def image_name(img):
+       fp = img.filepath
+       if fp:
+               return os.path.split(fp)[1]
+       else:
+               return img.name