OSDN Git Service

fix bone group name.
[meshio/meshio.git] / swig / blender / bl25.py
index dc66b7b..52a61b1 100755 (executable)
@@ -305,17 +305,39 @@ class material:
         return bpy.data.materials[material_name]
 
     @staticmethod
-    def addTexture(material, texture):
-        material.add_texture(texture, "UV", "COLOR")
-        slot=material.texture_slots[material.active_texture_index]
-        slot.blend_type='MULTIPLY'
-        slot.map_alpha=True
+    def addTexture(material, texture, enable=True):
+        # search free slot
+        index=None
+        for i, slot in enumerate(material.texture_slots):
+            if not slot:
+                index=i
+                break
+        if index==None:
+            return
+
+        if enable:
+            material.add_texture(texture, "UV", "COLOR")
+            slot=material.texture_slots[index]
+            slot.blend_type='MULTIPLY'
+            slot.map_alpha=True
+        else:
+            material.add_texture(texture)
+            material.use_textures[index]=False
+        return index
+
+    @staticmethod
+    def getTexture(material, index):
+        return material.texture_slots[index]
 
     @staticmethod
     def hasTexture(material):
         return material.texture_slots[0]
 
     @staticmethod
+    def setUseTexture(material, index, enable):
+        material.use_textures[index]=enable
+
+    @staticmethod
     def eachTexturePath(m):
         for slot in m.texture_slots:
             if slot and slot.texture: