OSDN Git Service

fix.
[meshio/meshio.git] / swig / blender / bl25.py
index 24b1d8b..85284f3 100644 (file)
@@ -3,9 +3,19 @@ import bpy
 import mathutils
 
 import os
+import sys
 import time
 import functools
 
+# \e$B%U%!%$%k%7%9%F%`$NJ8;z%3!<%I\e(B
+# \e$B2~B$HG$H$N6&MQ$N$?$a\e(B
+FS_ENCODING=sys.getfilesystemencoding()
+if os.path.exists(os.path.dirname(sys.argv[0])+"/utf8"):
+    INTERNAL_ENCODING='utf-8'
+else:
+    INTERNAL_ENCODING=FS_ENCODING
+
+
 ###############################################################################
 # ProgressBar
 ###############################################################################
@@ -75,6 +85,7 @@ def createPmdMaterial(m):
     material.specular_hardness=int(m.shinness)
     material.specular_color=([m.specular.r, m.specular.g, m.specular.b])
     material.mirror_color=([m.ambient.r, m.ambient.g, m.ambient.b])
+    material.subsurface_scattering.enabled=True if m.flag==1 else False
     # temporary
     material.emit=1.0
     return material
@@ -225,6 +236,9 @@ def objectDuplicate(scene, obj):
     bpy.ops.object.location_apply()
     return dumy.data, dumy
 
+def objectDelete(scene, obj):
+    scene.objects.unlink(obj)
+
 def faceVertexCount(face):
     return len(face.verts)
 
@@ -327,8 +341,12 @@ def meshAddUV(mesh):
 def meshVertsDelete(mesh, remove_vertices):
     enterEditMode()
     bpy.ops.mesh.select_all(action='DESELECT')
+    exitEditMode()
+
     for i in remove_vertices:
         mesh.verts[i].selected=True
+
+    enterEditMode()
     bpy.ops.mesh.delete(type='VERT')
     exitEditMode()
 
@@ -358,6 +376,9 @@ def createIkConstraint(armature_object, p_bone, effector_name, ik):
     constraint.target=armature_object
     constraint.subtarget=effector_name
     constraint.use_tail=False
+    # not used. place folder when export.
+    constraint.weight=ik.weight
+    constraint.iterations=ik.iterations * 10
     return constraint
 
 def createArmatureBone(armature, name):
@@ -393,3 +414,70 @@ def objectActivateShapeKey(o, index):
 def shapeKeyAssign(shapeKey, index, pos):
     shapeKey.data[index].co=pos
 
+def objectIsVisible(obj):
+    return obj.restrict_view
+
+def meshVertexGroupNames(meshObject):
+    for g in meshObject.vertex_groups:
+        yield g.name
+
+def faceNormal(face):
+    return face.normal
+
+def meshFaceUv(mesh, i, face):
+    return mesh.uv_textures[0].data[i].uv
+
+def armatureModifierGetObject(m):
+    return m.object
+
+def objectHasShapeKey(o):
+    return o.data.shape_keys
+
+def objectShapeKeys(o):
+    return o.data.shape_keys.keys
+
+def meshVertexGroup(meshObject, name):
+    indices=[]
+    for i, v in enumerate(meshObject.data.verts):
+        for g in v.groups:
+            if meshObject.vertex_groups[g.group].name==name:
+                indices.append(i)
+    return indices
+
+def materialGet(scene, material_name):
+    return bpy.data.materials[material_name]
+
+def modifierIsArmature(m):
+    return m.type=="ARMATURE"
+
+def boneHeadLocal(b):
+    return b.head_local[0:3]
+
+def boneTailLocal(b):
+    return b.tail_local[0:3]
+
+def boneIsConnected(b):
+    return b.connected
+
+def constraintIsIKSolver(c):
+    return c.type=='IK'
+
+def ikChainLen(c):
+    return c.chain_length
+
+def ikTarget(c):
+    return c.subtarget
+
+def ikItration(c):
+    return c.iterations
+
+def ikRotationWeight(c):
+    return c.weight
+
+def shapeKeyGet(b, index):
+    return b.data[index].co
+
+def shapeKeys(b):
+    for k in b.data:
+        yield k.co
+