OSDN Git Service

fix for Blender2.54.
authorousttrue <ousttrue@gmail.com>
Wed, 6 Oct 2010 14:55:18 +0000 (23:55 +0900)
committerousttrue <ousttrue@gmail.com>
Wed, 6 Oct 2010 14:55:18 +0000 (23:55 +0900)
swig/blender/bl25.py
swig/blender/pmd_import.py

index 0754796..c9b72d2 100755 (executable)
@@ -205,7 +205,7 @@ class object:
 
     @staticmethod
     def pinShape(o, enable):
-        o.shape_key_lock=enable
+        o.show_shape_key=enable
 
     @staticmethod
     def setActivateShapeKey(o, index):
@@ -218,7 +218,7 @@ class object:
     @staticmethod
     def getVertexGroup(o, name):
         indices=[]
-        for i, v in enumerate(o.data.verts):
+        for i, v in enumerate(o.data.vertices):
             for g in v.groups:
                 if o.vertex_groups[g.group].name==name:
                     indices.append(i)
@@ -231,12 +231,12 @@ class object:
 
     @staticmethod
     def addVertexGroup(o, name):
-        o.add_vertex_group(name)
+        o.vertex_groups.new(name)
 
     @staticmethod
     def assignVertexGroup(o, name, index, weight):
-        o.add_vertex_to_group(index, 
-                    o.vertex_groups[name], weight, 'ADD')
+        g=o.vertex_groups[name]
+        o.vertex_groups.assign([index], g, weight, 'ADD')
 
     @staticmethod
     def createBoneGroup(o, name, color_set='DEFAULT'):
@@ -246,7 +246,7 @@ class object:
         bpy.ops.pose.group_add()
         # set name
         pose=object.getPose(o)
-        g=pose.active_bone_group
+        g=pose.bone_groups.active
         g.name=name
         g.color_set=color_set
 
@@ -398,7 +398,7 @@ class mesh:
         unpackedVertices=[]
         for v in vertices:
             unpackedVertices.extend(v)
-        mesh.verts.foreach_set("co", unpackedVertices)
+        mesh.vertices.foreach_set("co", unpackedVertices)
         # add face
         unpackedFaces = []
         for face in faces:
@@ -463,7 +463,7 @@ class mesh:
         enterObjectMode()
 
         for i in remove_vertices:
-            m.verts[i].select=True
+            m.vertices[i].select=True
 
         enterEditMode()
         bpy.ops.mesh.delete(type='VERT')
@@ -513,18 +513,18 @@ class vertex:
 class face:
     @staticmethod
     def getVertexCount(face):
-        return len(face.verts)
+        return len(face.vertices)
 
     @staticmethod
     def getVertices(face):
-        return face.verts[:]
+        return face.vertices[:]
 
     @staticmethod
     def getIndices(face, count=3):
         if count==3:
-            return [face.verts[0], face.verts[1], face.verts[2]]
+            return [face.vertices[0], face.vertices[1], face.vertices[2]]
         elif count==4:
-            return [face.verts[0], face.verts[1], face.verts[2], face.verts[3]]
+            return [face.vertices[0], face.vertices[1], face.vertices[2], face.vertices[3]]
         else:
             assert(False)
 
@@ -557,13 +557,13 @@ class armature:
         armature_object=bpy.data.objects.new('Armature', armature)
         SCENE.objects.link(armature_object)
 
-        armature_object.x_ray=True
-        armature.draw_names=True
-        #armature.drawtype='OCTAHEDRAL'
-        armature.drawtype='STICK'
-        armature.deform_envelope=False
-        armature.deform_vertexgroups=True
-        armature.x_axis_mirror=True
+        armature_object.show_x_ray=True
+        armature.show_names=True
+        #armature.draw_type='OCTAHEDRAL'
+        armature.draw_type='STICK'
+        armature.use_deform_envelopes=False
+        armature.use_deform_vertex_groups=True
+        armature.use_mirror_x=True
 
         return armature, armature_object
 
@@ -578,7 +578,7 @@ class armature:
     @staticmethod
     def createIkConstraint(armature_object, p_bone, effector_name, ik):
         constraint = p_bone.constraints.new('IK')
-        constraint.chain_length=len(ik.children)
+        constraint.chain_count=len(ik.children)
         constraint.target=armature_object
         constraint.subtarget=effector_name
         constraint.use_tail=False
@@ -599,7 +599,7 @@ class armature:
 class bone:
     @staticmethod
     def setConnected(bone):
-        bone.connected=True
+        bone.use_connect=True
 
     @staticmethod
     def isConnected(b):
@@ -613,7 +613,7 @@ class bone:
                 layer.append(True if layers[i]!=0 else False)
             except IndexError:
                 layer.append(False)
-        bone.layer=layer
+        bone.layers=layer
 
     @staticmethod
     def getHeadLocal(b):
index ac4accb..007f955 100755 (executable)
@@ -169,21 +169,22 @@ else:
         # ambient
         material.mirror_color=([m.ambient.r, m.ambient.g, m.ambient.b])
         # flag
-        material.subsurface_scattering.enabled=True if m.flag==1 else False
+        material.subsurface_scattering.use=True if m.flag==1 else False
         # other
         material.name="m_%02d" % index
         material.preview_render_type='FLAT'
-        material.transparency=True
+        material.use_transparency=True
         return material
 
     def poseBoneLimit(n, b):
         if n.endswith("_t"):
             return
         if n.startswith("knee_"):
-            b.ik_dof_y=False
-            b.ik_dof_z=False
-            b.ik_dof_x=True
-            b.ik_limit_x=True
+            b.lock_ik_y=True
+            b.lock_ik_z=True
+            b.lock_ik_x=False
+            # IK limit
+            b.use_ik_limit_x=True
             b.ik_min_x=0
             b.ik_max_x=180
         elif n.startswith("ankle_"):
@@ -192,7 +193,7 @@ else:
 
     def setSphereMap(material, index, blend_type='MULTIPLY'):
         slot=material.texture_slots[index]
-        slot.texture_coordinates='NORMAL'
+        slot.texture_coords='NORMAL'
         slot.mapping='SPHERE'
         slot.blend_type=blend_type
 
@@ -291,7 +292,7 @@ def __importShape(obj, l, vertex_map):
             for index, offset in zip(s.indices, s.pos_list):
                 try:
                     vertex_index=vertex_map[base.indices[index]]
-                    v=mesh.verts[vertex_index].co
+                    v=mesh.vertices[vertex_index].co
                     offset=convert_coord(offset)
                     v[0]+=offset[0]
                     v[1]+=offset[1]
@@ -299,7 +300,7 @@ def __importShape(obj, l, vertex_map):
                 except IndexError as msg:
                     print(msg)
                     print(index, len(base.indices), len(vertex_map))
-                    print(len(mesh.verts))
+                    print(len(mesh.vertices))
                     print(base.indices[index])
                     print(vertex_index)
                     break
@@ -314,7 +315,7 @@ def __importShape(obj, l, vertex_map):
             mesh.update()
             
             # restore
-            for mv, v in zip(mesh.verts, baseShapeBlock.getData()):
+            for mv, v in zip(mesh.vertices, baseShapeBlock.getData()):
                 mv.co[0] = v[0]
                 mv.co[1] = v[1]
                 mv.co[2] = v[2]
@@ -328,12 +329,12 @@ def __importShape(obj, l, vertex_map):
                 try:
                     vertex_index=vertex_map[base.indices[index]]
                     bl.shapekey.assign(new_shape_key, vertex_index,
-                            mesh.verts[vertex_index].co+
+                            mesh.vertices[vertex_index].co+
                             bl.createVector(*convert_coord(offset)))
                 except IndexError as msg:
                     print(msg)
                     print(index, len(base.indices), len(vertex_map))
-                    print(len(mesh.verts))
+                    print(len(mesh.vertices))
                     print(base.indices[index])
                     print(vertex_index)
                     break
@@ -568,7 +569,7 @@ def __import16MaerialAndMesh(meshObject, l,
     # vertex params
     bl.mesh.useVertexUV(mesh)
     for i, v, mvert in zip(xrange(len(l.vertices)), 
-        l.each_vertex(), mesh.verts):
+        l.each_vertex(), mesh.vertices):
         # normal, uv
         bl.vertex.setNormal(mvert, convert_coord(v.normal))
         # bone weight
@@ -602,7 +603,7 @@ def __import16MaerialAndMesh(meshObject, l,
                     imageMap.get(index, None))
 
         # set smooth
-        face.smooth = 1
+        bl.face.setSmooth(face, True)
 
     mesh.update()