def enterEditMode():
bpy.ops.object.mode_set(mode='EDIT', toggle=False)
-def exitEditMode():
+def enterObjectMode():
bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+def enterPoseMode():
+ bpy.ops.object.mode_set(mode='POSE', toggle=False)
+
def createVector(x, y, z):
return mathutils.Vector([x, y, z])
o.add_vertex_to_group(index,
o.vertex_groups[name], weight, 'ADD')
+ @staticmethod
+ def createBoneGroup(o, name, color_set='DEFAULT'):
+ # create group
+ object.activate(o)
+ enterPoseMode()
+ bpy.ops.pose.group_add()
+ # set name
+ pose=object.getPose(o)
+ g=pose.active_bone_group
+ g.name=name
+ g.color_set=color_set
+
class modifier:
@staticmethod
texture=texture.recast_type()
image=bpy.data.images.load(path)
texture.image=image
- texture.mipmap = True
- texture.interpolation = True
- texture.use_alpha = True
+ texture.mipmap=True
+ texture.interpolation=True
+ texture.use_alpha=True
return texture, image
@staticmethod
def addTexture(material, texture):
- #material.add_texture(texture, "UV", {"COLOR", "ALPHA"})
material.add_texture(texture, "UV", "COLOR")
+ slot=material.texture_slots[material.active_texture_index]
+ slot.blend_type='MULTIPLY'
+ slot.map_alpha=True
@staticmethod
def hasTexture(material):
return material.texture_slots[0]
@staticmethod
- def getTexturePath(m, dirname):
- tex=""
- aplane=""
- # texture
+ def eachTexturePath(m):
for slot in m.texture_slots:
if slot and slot.texture:
texture=slot.texture
image=texture.image
if not image:
continue
- imagePath=image.filename
- if len(dirname)>0 and imagePath.startswith(dirname):
- # \e$BAjBP%Q%9$KJQ49$9$k\e(B
- imagePath=imagePath[len(dirname)+1:len(imagePath)]
- #imagePath=Blender.sys.expandpath(
- # imagePath).replace("\\", '/')
- if slot.map_colordiff:
- tex=" tex(\"%s\")" % imagePath
- elif slot.map_alpha:
- aplane=" aplane(\"%s\")" % imagePath
- return tex, aplane
-
+ yield image.filename
class mesh:
@staticmethod
def vertsDelete(mesh, remove_vertices):
enterEditMode()
bpy.ops.mesh.select_all(action='DESELECT')
- exitEditMode()
+ enterObjectMode()
for i in remove_vertices:
mesh.verts[i].selected=True
enterEditMode()
bpy.ops.mesh.delete(type='VERT')
- exitEditMode()
+ enterObjectMode()
@staticmethod
def setSmooth(mesh, smoothing):
object.activate(mesh_object)
enterEditMode()
bpy.ops.mesh.normals_make_consistent()
- exitEditMode()
+ enterObjectMode()
@staticmethod
def flipNormals(mesh):
return face.verts[:]
@staticmethod
- def getIndices(face):
- return [face.verts[0], face.verts[1], face.verts[2]]
+ def getIndices(face, count=3):
+ if count==3:
+ return [face.verts[0], face.verts[1], face.verts[2]]
+ elif count==4:
+ return [face.verts[0], face.verts[1], face.verts[2], face.verts[3]]
+ else:
+ assert(False)
@staticmethod
def setMaterial(face, material_index):
armature_object.x_ray=True
armature.draw_names=True
- armature.drawtype='OCTAHEDRAL'
+ #armature.drawtype='OCTAHEDRAL'
+ armature.drawtype='STICK'
armature.deform_envelope=False
armature.deform_vertexgroups=True
armature.x_axis_mirror=True