]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_material.py
Refactor material property handling in the Blender exporter
[libs/gl.git] / blender / io_mspgl / export_material.py
index 41ed287bd3ab1c154ad146c2d760053ff9340455..1df5347098571a3a84d25db46f1df91c3626d229 100644 (file)
@@ -40,7 +40,7 @@ class MaterialExporter:
                material = Material(material)
 
                if self.use_textures:
-                       for p in material.properties.values():
+                       for p in material.properties:
                                if p.texture:
                                        tex_name = p.texture.image.name+".tex2d"
                                        if tex_name not in resources:
@@ -68,12 +68,12 @@ class MaterialExporter:
                        raise Exception("Can't export unknown material type "+material.type)
 
                st = Statement(material.type)
-               for kw, p in material.properties.items():
-                       ss = self.create_property_statement(mat_res, p, kw, resources)
+               for p in material.properties:
+                       ss = self.create_property_statement(mat_res, p, resources)
                        if ss:
                                st.sub.append(ss)
                if self.use_textures:
-                       first_tex = (p.texture for p in material.properties.values() if p.texture).__next__()
+                       first_tex = (p.texture for p in material.properties if p.texture).__next__()
                        if first_tex and not first_tex.default_filter:
                                from .export_texture import SamplerExporter
                                sampler_export = SamplerExporter()
@@ -82,22 +82,22 @@ class MaterialExporter:
 
                return mat_res
 
-       def create_property_statement(self, mat_res, prop, keyword, resources):
+       def create_property_statement(self, mat_res, prop, resources):
                from .datafile import Statement
                if self.use_textures and prop.texture:
                        tex_res = resources[prop.texture.image.name+".tex2d"]
                        from .util import basename
                        fn = basename(prop.texture.image.filepath)
                        if prop.texture.default_filter and fn:
-                               return Statement(keyword+"_map", fn)
+                               return Statement(prop.tex_keyword, fn)
                        else:
-                               return mat_res.create_reference_statement(keyword+"_map", tex_res)
-               elif prop.value is None:
+                               return mat_res.create_reference_statement(prop.tex_keyword, tex_res)
+               elif not prop.keyword:
                        return
                elif type(prop.value)==tuple:
-                       return Statement(keyword, *prop.value)
+                       return Statement(prop.keyword, *prop.value)
                else:
-                       return Statement(keyword, prop.value)
+                       return Statement(prop.keyword, prop.value)
 
 
 class MaterialMapExporter: