Browse Source

Merge pull request #6725 from ov/blender-material-transparent-dev

export material's transparency attribute in blender
Ricardo Cabello 10 years ago
parent
commit
a78c914ac5

+ 5 - 0
utils/exporters/blender/addons/io_three/__init__.py

@@ -116,6 +116,7 @@ bpy.types.Material.THREE_blending_type = EnumProperty(
 
 bpy.types.Material.THREE_depth_write = BoolProperty(default=True)
 bpy.types.Material.THREE_depth_test = BoolProperty(default=True)
+bpy.types.Material.THREE_double_sided = BoolProperty(default=False)
 
 class ThreeMaterial(bpy.types.Panel):
     """Adds custom properties to the Materials of an object"""
@@ -150,6 +151,10 @@ class ThreeMaterial(bpy.types.Panel):
             row.prop(mat, 'THREE_depth_test',
                      text="Enable depth testing")
 
+            row = layout.row()
+            row.prop(mat, 'THREE_double_sided',
+                     text="Double-sided")
+
 def _mag_filters(index):
     """Three.js mag filters
 

+ 2 - 0
utils/exporters/blender/addons/io_three/constants.py

@@ -302,6 +302,8 @@ NORMAL_BLENDING = 0
 VERTEX_COLORS_ON = 2
 VERTEX_COLORS_OFF = 0
 
+SIDE_DOUBLE = 2
+
 THREE_BASIC = 'MeshBasicMaterial'
 THREE_LAMBERT = 'MeshLambertMaterial'
 THREE_PHONG = 'MeshPhongMaterial'

+ 18 - 0
utils/exporters/blender/addons/io_three/exporter/api/material.py

@@ -124,6 +124,24 @@ def depth_write(material):
     return write
 
 
+@_material
+def double_sided(material):
+    """
+
+    :param material:
+    :return: THREE_double_sided value
+    :rtype: bool
+
+    """
+    logger.debug("material.double_sided(%s)", material)
+    try:
+        write = material.THREE_double_sided
+    except AttributeError:
+        logger.debug("No THREE_double_sided attribute found")
+        write = False
+    return write
+
+
 @_material
 def diffuse_color(material):
     """

+ 6 - 0
utils/exporters/blender/addons/io_three/exporter/material.py

@@ -43,6 +43,12 @@ class Material(base_classes.BaseNode):
 
         self[constants.BLENDING] = api.material.blending(self.node)
 
+        if api.material.transparent(self.node):
+            self[constants.TRANSPARENT] = True
+
+        if api.material.double_sided(self.node):
+            self[constants.SIDE] = constants.SIDE_DOUBLE
+
         self[constants.DEPTH_TEST] = api.material.depth_test(self.node)
 
         self[constants.DEPTH_WRITE] = api.material.depth_write(self.node)