]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_material.py
Recognize transparent materials in Blender and export them accordingly
[libs/gl.git] / blender / io_mspgl / export_material.py
index 69782b64cbb4cd7c3edf4fb3ebcd8064313141d3..62319b8a93efcf878bdd751e52a38894f564e19a 100644 (file)
@@ -1,8 +1,7 @@
 import os
 
 def create_technique_resource(material, resources):
-       # This operates on a Blender material, not a custom object
-       from .datafile import Resource, Statement
+       from .datafile import Resource, Statement, Token
        tech_res = Resource(material.name+".tech", "technique")
 
        mat_res = resources[material.name+".mat"]
@@ -26,10 +25,14 @@ def create_technique_resource(material, resources):
 
                        tech_res.statements.append(st)
        else:
-               st = Statement("method", "")
+               base_method = "blended" if material.blended else ""
+               st = Statement("method", base_method)
                if mat_res:
                        st.sub.append(tech_res.create_embed_statement("material", mat_res))
 
+               if material.blended:
+                       ss.sub.append(Statement("blend", Token("SRC_ALPHA"), Token("ONE_MINUS_SRC_ALPHA")))
+
                if material.render_mode!='CUSTOM':
                        if material.receive_shadows:
                                st.sub.append(Statement("receive_shadows", True))
@@ -38,7 +41,7 @@ def create_technique_resource(material, resources):
 
                tech_res.statements.append(st)
 
-               if material.shadow_method!='NONE':
+               if material.cast_shadows:
                        st = Statement("method", "shadow")
                        st.sub.append(Statement("shader", "occluder.glsl.shader"))
                        tech_res.statements.append(st)
@@ -50,18 +53,14 @@ def create_technique_resource(material, resources):
        return tech_res
 
 class MaterialExporter:
-       def create_texture_exporter(self):
-               from .export_texture import TextureExporter
-               texture_export = TextureExporter()
-               return texture_export
-
        def export_technique_resources(self, material, resources):
-               from .export_texture import SamplerExporter
-               texture_export = self.create_texture_exporter()
+               from .export_texture import SamplerExporter, TextureExporter
+               texture_export = TextureExporter()
                sampler_export = SamplerExporter()
 
                from .material import Material
-               material = Material(material)
+               if type(material)!=Material:
+                       material = Material(material)
 
                for p in material.properties:
                        if p.texture:
@@ -81,6 +80,10 @@ class MaterialExporter:
                                resources[mat_name] = None
 
        def export_technique(self, material, resources):
+               from .material import Material
+               if type(material)!=Material:
+                       material = Material(material)
+
                return create_technique_resource(material, resources)
 
        def export_material(self, material, resources):