OSDN Git Service

export toon textures.
[meshio/meshio.git] / swig / blender / bl25.py
index dc66b7b..a1ed64b 100755 (executable)
@@ -239,6 +239,10 @@ class object:
         g.name=name
         g.color_set=color_set
 
+    @staticmethod
+    def boneGroups(o):
+        return object.getPose(o).bone_groups
+
 
 class modifier:
     @staticmethod
@@ -294,6 +298,13 @@ class texture:
         texture.use_alpha=True
         return texture, image
 
+    @staticmethod
+    def getPath(t):
+        if  t.type=="IMAGE":
+            image=t.image
+            if image:
+                return image.filename
+
 
 class material:
     @staticmethod
@@ -305,17 +316,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].texture
 
     @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:
@@ -326,6 +359,7 @@ class material:
                         continue
                     yield image.filename
 
+
 class mesh:
     @staticmethod
     def create(name):
@@ -395,30 +429,30 @@ class mesh:
             return ((0, 0), (0, 0), (0, 0), (0, 0))
 
     @staticmethod
-    def setFaceUV(mesh, i, face, uv_array, image):
-        uv_face=mesh.uv_textures[0].data[i]
+    def setFaceUV(m, i, face, uv_array, image):
+        uv_face=m.uv_textures[0].data[i]
         uv_face.uv=uv_array
         if image:
             uv_face.image=image
             uv_face.tex=True
 
     @staticmethod
-    def vertsDelete(mesh, remove_vertices):
+    def vertsDelete(m, remove_vertices):
         enterEditMode()
         bpy.ops.mesh.select_all(action='DESELECT')
         enterObjectMode()
 
         for i in remove_vertices:
-            mesh.verts[i].selected=True
+            m.verts[i].selected=True
 
         enterEditMode()
         bpy.ops.mesh.delete(type='VERT')
         enterObjectMode()
 
     @staticmethod
-    def setSmooth(mesh, smoothing):
-        mesh.autosmooth_angle=int(smoothing)
-        mesh.autosmooth=True
+    def setSmooth(m, smoothing):
+        m.autosmooth_angle=int(smoothing)
+        m.autosmooth=True
 
     @staticmethod
     def recalcNormals(mesh_object):
@@ -429,12 +463,16 @@ class mesh:
         enterObjectMode()
 
     @staticmethod
-    def flipNormals(mesh):
-        mesh.flipNormals()
+    def flipNormals(m):
+        m.flipNormals()
+
+    @staticmethod
+    def addMaterial(m, material):
+        m.add_material(material)
 
     @staticmethod
-    def addMaterial(mesh, material):
-        mesh.add_material(material)
+    def getMaterial(m, index):
+        return m.materials[index]
 
 
 class vertex: