]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_material.py
Simplify the resource separation options
[libs/gl.git] / blender / io_mspgl / export_material.py
index 3f0117d40a210909ce5075ec9b952e68619d661a..289fb8810d4beff83826d4a4905c11bdd71e3b39 100644 (file)
@@ -15,13 +15,13 @@ def get_colormap(srgb):
 
 class MaterialExporter:
        def __init__(self):
-               self.textures = 'REF'
+               self.single_file = True
+               self.use_textures = True
 
        def create_texture_exporter(self):
                from .export_texture import TextureExporter
                texture_export = TextureExporter()
-               if self.textures=='INLINE':
-                       texture_export.pixels = 'INLINE'
+               texture_export.inline_data = self.single_file
                return texture_export
 
        def export_technique_resources(self, material, resources):
@@ -31,7 +31,7 @@ class MaterialExporter:
                if mat_name not in resources:
                        resources[mat_name] = self.export_material(material)
 
-               if self.textures!='NONE':
+               if self.use_textures:
                        for s in material.texture_slots:
                                if s and s.texture.type=='IMAGE' and s.texture.image:
                                        tex_name = s.texture.name+".tex2d"
@@ -44,7 +44,7 @@ class MaterialExporter:
 
                mat_res = resources[material.name+".mat"]
                textures = {}
-               if self.textures!='NONE':
+               if self.use_textures:
                        image_texture_slots = [s for s in material.texture_slots if s and s.texture.type=='IMAGE' and s.texture.image]
                        for s in image_texture_slots:
                                if s.use_map_color_diffuse:
@@ -56,6 +56,9 @@ class MaterialExporter:
                        if not obj.inherit_tech:
                                return []
 
+                       if self.single_file:
+                               raise Exception("Can't export inherited technique to a single file")
+
                        st = Statement("inherit", material.technique)
                        for s, t in textures.items():
                                if t.default_filter:
@@ -67,13 +70,16 @@ class MaterialExporter:
                        tech_res.statements.append(st)
                else:
                        st = Statement("pass", "")
-                       st.sub.append(tech_res.create_embed_statement("material", mat_res))
+                       if self.single_file:
+                               st.sub.append(tech_res.create_embed_statement("material", mat_res))
+                       else:
+                               st.sub.append(tech_res.create_reference_statement("material", mat_res))
 
                        if "diffuse_map" in textures:
                                diffuse_tex = textures["diffuse_map"]
                                tex_res = resources[diffuse_tex.name+".tex2d"]
                                ss = Statement("texunit", 0)
-                               if self.textures=='INLINE':
+                               if self.single_file:
                                        ss.sub.append(tech_res.create_embed_statement("texture2d", tex_res))
                                elif not diffuse_tex.default_filter:
                                        ss.sub.append(tech_res.create_reference_statement("texture2d", tex_res))