@staticmethod
def pinShape(o, enable):
- o.shape_key_lock=enable
+ o.show_shape_key=enable
@staticmethod
def setActivateShapeKey(o, index):
@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)
@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'):
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
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:
enterObjectMode()
for i in remove_vertices:
- m.verts[i].select=True
+ m.vertices[i].select=True
enterEditMode()
bpy.ops.mesh.delete(type='VERT')
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)
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
@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
class bone:
@staticmethod
def setConnected(bone):
- bone.connected=True
+ bone.use_connect=True
@staticmethod
def isConnected(b):
layer.append(True if layers[i]!=0 else False)
except IndexError:
layer.append(False)
- bone.layer=layer
+ bone.layers=layer
@staticmethod
def getHeadLocal(b):
# 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_"):
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
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]
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
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]
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
# 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
imageMap.get(index, None))
# set smooth
- face.smooth = 1
+ bl.face.setSmooth(face, True)
mesh.update()