I am having some problem exporting the bone and it not in the right position when I export. I try different ways for the bone and the rotation is off set by a lot. I notice the bone rotation is effect by the position and i don’t know how to tranlate the right position. Can any one help me?
Here the answer.
print '-------------------- Dumping Bone ---------------------- '
# blender_bone <- Bone loop when parenting off
print blender_bone.parent # Child parent of the bone
#If bone does not have parent that mean it the main bone
if not blender_bone.hasParent(): #Root bone
parent_root = blender_bone
#print "---------------PARENT ROOT BONE: ",parent_root
if blender_bone.hasChildren():
child_count = len(blender_bone.children)
else:
child_count = 0
#child of parent
child_parent = blender_bone.parent
if child_parent != None:
if parent_root.name == child_parent.name:
#This one deal rotation for bone for the whole bone that will inherit off from parent to child.
quat_root = blender_bone.matrix['BONESPACE']* parent_mat.rotationPart() #Armature = parent_mat
quat = make_fquat(quat_root.toQuat())
else:
quat_root = blender_bone.matrix['BONESPACE']
quat = make_fquat(quat_root.toQuat())
quat_parent = child_parent.matrix['BONESPACE'].toQuat().inverse()
parent_head = child_parent.head['BONESPACE']* quat_parent
parent_tail = child_parent.tail['BONESPACE']* quat_parent
set_position = (parent_tail - parent_head) + blender_bone.head['BONESPACE']
else:
# ROOT BONE
#This for root
set_position = blender_bone.head['BONESPACE']
rot_mat = blender_bone.matrix['BONESPACE']#* parent_mat.rotationPart()
quat = make_fquat_default(rot_mat.toQuat())
#print "[[======= FINAL POSITION:",set_position
final_parent_id = parent_id
''' #This is how to you get the right position of the head when export
if child_parent != None:
quat_parent = child_parent.matrix['BONESPACE'].toQuat().inverse()
parent_head = child_parent.head['BONESPACE']* quat_parent
parent_tail = child_parent.tail['BONESPACE']* quat_parent
set_position = (parent_tail - parent_head)+ blender_bone.head['BONESPACE']
'''
This is base on unreal export for psk.