Fix convert-mesh script
This commit is contained in:
parent
2b46b38da2
commit
463cb5372b
1 changed files with 31 additions and 28 deletions
|
|
@ -190,37 +190,38 @@ if armature is not None:
|
|||
bones.append((p, tuple(b.head_local), tuple(map(tuple, b.matrix_local.to_3x3()))))
|
||||
|
||||
poses = []
|
||||
for index, pose in enumerate(bpy.data.objects['armature'].pose_library.pose_markers):
|
||||
print("Found pose", pose.name)
|
||||
if armature is not None:
|
||||
for index, pose in enumerate(bpy.data.objects['armature'].pose_library.pose_markers):
|
||||
print("Found pose", pose.name)
|
||||
|
||||
# [rotation, scale, translation]
|
||||
data = []
|
||||
for i in range(len(bone_names)):
|
||||
data.append([[None, None, None, None], [None, None, None], [None, None, None]])
|
||||
# [rotation, scale, translation]
|
||||
data = []
|
||||
for i in range(len(bone_names)):
|
||||
data.append([[1.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [0.0, 0.0, 0.0]])
|
||||
|
||||
marker = armature.pose_library.pose_markers[index]
|
||||
frame = marker.frame
|
||||
action = bpy.data.actions[armature.pose_library.name]
|
||||
for g in action.groups:
|
||||
if not g.name in bone_names:
|
||||
continue
|
||||
bone_index = bone_names.index(g.name)
|
||||
for ch in g.channels:
|
||||
value = ch.evaluate(float(frame))
|
||||
if ch.data_path.find('rotation_quaternion') != -1:
|
||||
data[bone_index][0][ch.array_index] = value
|
||||
elif ch.data_path.find('scale') != -1:
|
||||
data[bone_index][1][ch.array_index] = value
|
||||
elif ch.data_path.find('location') != -1:
|
||||
data[bone_index][2][ch.array_index] = value
|
||||
marker = armature.pose_library.pose_markers[index]
|
||||
frame = marker.frame
|
||||
action = bpy.data.actions[armature.pose_library.name]
|
||||
for g in action.groups:
|
||||
if not g.name in bone_names:
|
||||
continue
|
||||
bone_index = bone_names.index(g.name)
|
||||
for ch in g.channels:
|
||||
value = ch.evaluate(float(frame))
|
||||
if ch.data_path.find('rotation_quaternion') != -1:
|
||||
data[bone_index][0][ch.array_index] = value
|
||||
elif ch.data_path.find('scale') != -1:
|
||||
data[bone_index][1][ch.array_index] = value
|
||||
elif ch.data_path.find('location') != -1:
|
||||
data[bone_index][2][ch.array_index] = value
|
||||
|
||||
new_data = []
|
||||
for d in data:
|
||||
rotation = tuple([d[0][1], d[0][2], d[0][3], d[0][0]])
|
||||
scale = d[1][0]
|
||||
translation = tuple(d[2])
|
||||
new_data.append((rotation, scale, translation))
|
||||
poses.append((pose.name, new_data))
|
||||
new_data = []
|
||||
for d in data:
|
||||
rotation = tuple([d[0][1], d[0][2], d[0][3], d[0][0]])
|
||||
scale = d[1][0]
|
||||
translation = tuple(d[2])
|
||||
new_data.append((rotation, scale, translation))
|
||||
poses.append((pose.name, new_data))
|
||||
|
||||
def to_bytes(obj):
|
||||
if type(obj) == Uint8:
|
||||
|
|
@ -245,6 +246,8 @@ def to_bytes(obj):
|
|||
if type(obj) == str:
|
||||
b = obj.encode('utf-8')
|
||||
return struct.pack('<I', len(b)) + b
|
||||
print("Type", type(obj), "not supported")
|
||||
sys.exit(1)
|
||||
|
||||
SECTION_MESH = 1
|
||||
SECTION_BONES = 2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue