X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fexport_material.py;h=46b571a9202e3408662b95f79a11debc8d9c8e8d;hb=0055fd43dc1d3b6ca65823f40dfdf78e65770f15;hp=3f0117d40a210909ce5075ec9b952e68619d661a;hpb=e891021affc89a329d65b526744ebd38589cae32;p=libs%2Fgl.git diff --git a/blender/io_mspgl/export_material.py b/blender/io_mspgl/export_material.py index 3f0117d4..46b571a9 100644 --- a/blender/io_mspgl/export_material.py +++ b/blender/io_mspgl/export_material.py @@ -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,16 +70,19 @@ 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)) + ss.sub.append(tech_res.create_reference_statement("texture", tex_res)) else: ss.sub.append(Statement("texture", image_name(diffuse_tex.image))) st.sub.append(ss)