for b in bones:
if not b.parent:
self.__build(armature, b, None, None)
+ armature.update()
def __build(self, armature, b, p, parent):
name=englishmap.getEnglishBoneName(b.getName())
# 先端
assert(b.type==6 or b.type==7)
bone.head = Mathutils.Vector(*convert_coord(b.pos))
- bone.tail=bone.head-Mathutils.Vector(0, 1, 0)
+ bone.tail=bone.head+Mathutils.Vector(0, 1, 0)
assert(parent)
bone.parent=parent
- assert(parent.tail==bone.head)
+ if bone.name=="center_t":
+ # センターボーンは(0, 1, 0)の方向を向いていないと具合が悪い
+ parent.tail=parent.head+Mathutils.Vector(0, 1, 0)
+ else:
+ assert(parent.tail==bone.head)
bone.options=[Blender.Armature.CONNECTED]
+ # armature layer 2
bone.layerMask = (1<<1)
else:
bone.head = Mathutils.Vector(*convert_coord(b.pos))
bone.options=[Blender.Armature.CONNECTED]
if bone.head==bone.tail:
- bone.tail=bone.head-Mathutils.Vector(0, 1, 0)
+ bone.tail=bone.head+Mathutils.Vector(0, 1, 0)
for c in b.children:
self.__build(armature, c, b, bone)
armature_object.drawMode | Blender.Object.DrawModes.XRAY)
# armature settings
armature.drawType = Blender.Armature.OCTAHEDRON
+ armature.drawNames=True
armature.envelopes = False
armature.vertexGroups = True
armature.mirrorEdit = True
# create armature
armature.makeEditable()
+ ############################################################
+ # build bone
+ ############################################################
builder=Builder()
builder.build(armature, l.bones)
- armature.update()
-
############################################################
# IK
############################################################
for ik in l.ik_list:
# IKtarget->parent(=IK).name
target=l.bones[ik.target]
- parent=l.bones[target.parent_index]
- name = englishmap.getEnglishBoneName(parent.getName())
+ name = englishmap.getEnglishBoneName(target.getName())
p_bone = pose.bones[name]
if not p_bone:
print 'not found', name
print 'over MAX_CHAINLEN', ik, len(ik.children)
continue
# IK solver
- ik_const = p_bone.constraints.append(Blender.Constraint.Type.IKSOLVER)
- ik_const[cSetting.CHAINLEN] = len(ik.children)
- ik_const[cSetting.TARGET] = armature_object
+ ik_solver = p_bone.constraints.append(Blender.Constraint.Type.IKSOLVER)
+ ik_solver[cSetting.CHAINLEN] = len(ik.children)
+ ik_solver[cSetting.TARGET] = armature_object
effector_name=englishmap.getEnglishBoneName(
l.bones[ik.index].getName())
if not effector_name:
effector_name=l.bones[ik.index].getName()
- ik_const[cSetting.BONE] = effector_name
- ik_const[cSetting.ITERATIONS]=ik.iterations
- ik_const.influence = ik.weight
- # Limit ROT
- #lrot_const = p_bone.constraints.append(Blender.Constraint.Type.LIMITROT)
- #lrot_const[cSetting.OWNERSPACE] = cSetting.SPACE_LOCAL
- #lrot_const[cSetting.LIMIT] = (cSetting.LIMIT_XROT | cSetting.LIMIT_ZROT)
- #lrot_const[cSetting.XMIN] = 0.1
- #lrot_const[cSetting.XMAX] = 180
- #lrot_const[cSetting.ZMIN] = 180 - 0.1
- #lrot_const[cSetting.ZMAX] = 0
+ ik_solver[cSetting.BONE]=effector_name
+ #ik_solver.influence=ik.weight
+ ik_solver[cSetting.USETIP]=False
armature.makeEditable()
armature.update()
armature_object=importArmature(scene, l)
if armature_object:
armature = armature_object.getData()
- armature.drawNames=True
root.makeParent([armature_object])
# add armature modifier
mod=o.modifiers.append(Blender.Modifier.Types.ARMATURE)
mod[Blender.Modifier.Settings.OBJECT] = armature_object
mod[Blender.Modifier.Settings.ENVELOPES] = False
- o.makeDisplayList()
+ #o.makeDisplayList()
############################################################
# Limitation
############################################################
for n, b in armature_object.getPose().bones.items():
+ if n.endswith("_t"):
+ continue
+
if n.startswith("knee_"):
b.lockYRot=True
b.lockZRot=True
b.limitX=True
b.limitMin=[0, 0, 0]
b.limitMax=[180, 0, 0]
+ elif n.startswith("ankle_"):
+ b.lockYRot=True
# redraw
scene.update(0)