OSDN Git Service

add pymeshio.
[meshio/meshio.git] / swig / blender / bl24.py
index 034d461..349e2db 100755 (executable)
@@ -27,6 +27,11 @@ def to_internal_encoding(fn):
             for v in args])
     return newfn
 
+def register():
+    pass
+
+def unregister():
+    pass
 
 SCENE=None
 def initialize(name, scene):
@@ -155,6 +160,11 @@ class object:
         return empty
 
     @staticmethod
+    def each():
+        for o in SCENE.objects:
+            yield o
+
+    @staticmethod
     def makeParent(parent, child):
         parent.makeParent([child])
 
@@ -272,6 +282,10 @@ class object:
         g.name=name
         g.color_set=color_set
 
+    @staticmethod
+    def boneGroups(o):
+        return object.getPose(o).bone_groups
+
 
 class modifier:
     @staticmethod
@@ -327,6 +341,12 @@ class texture:
         texture.imageFlags|=Blender.Texture.ImageFlags.USEALPHA
         return texture, image
 
+    @staticmethod
+    def getPath(t):
+        image=t.getImage()
+        if image:
+            return image.getFilename()
+
 
 class material:
     @staticmethod
@@ -354,7 +374,7 @@ class material:
 
     @staticmethod
     def getTexture(m, index):
-        return m.textures[index]
+        return m.textures[index].tex
 
     @staticmethod
     def hasTexture(m):
@@ -362,10 +382,10 @@ class material:
 
     @staticmethod
     def setUseTexture(m, index, enable):
-        enable_textures=set(m.enabledTextures)
+        enabledTextures=set(m.enabledTextures)
         if enable:
             enabledTextures.add(index)
-        else;
+        else:
             enabledTextures.remove(index)
         m.enabledTextures=list(enabledTextures)
 
@@ -378,6 +398,15 @@ class material:
                     continue
                 yield image.getFilename()
 
+    @staticmethod
+    def eachEnalbeTexturePath(m, dirname):
+        for i, texture in enumerate(m.getTextures()):
+            if (i in m.enabledTextures) and texture and texture.tex and texture.tex.getImage():
+                image=texture.tex.getImage()
+                if not image:
+                    continue
+                yield image.getFilename()
+
 
 class mesh:
     @staticmethod
@@ -445,15 +474,23 @@ class mesh:
     def addMaterial(m, material):
         m.materials+=[material]
 
+    @staticmethod
+    def getMaterial(m, index):
+        return m.materials[index]
+
 
 class vertex:
     @staticmethod
-    def setNormal(mvert, normal):
-        mvert.no=Mathutils.Vector(*normal)
+    def getNormal(v):
+        return v.no
 
     @staticmethod
-    def setUv(mvert, uv):
-        mvert.uvco=uv
+    def setNormal(v, normal):
+        v.no=Mathutils.Vector(*normal)
+
+    @staticmethod
+    def setUv(v, uv):
+        v.uvco=uv
 
 
 class face:
@@ -588,4 +625,3 @@ class constraint:
     def isIKSolver(c):
         return c.type==Blender.Constraint.Type.IKSOLVER
 
-