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()))))
|
bones.append((p, tuple(b.head_local), tuple(map(tuple, b.matrix_local.to_3x3()))))
|
||||||
|
|
||||||
poses = []
|
poses = []
|
||||||
for index, pose in enumerate(bpy.data.objects['armature'].pose_library.pose_markers):
|
if armature is not None:
|
||||||
print("Found pose", pose.name)
|
for index, pose in enumerate(bpy.data.objects['armature'].pose_library.pose_markers):
|
||||||
|
print("Found pose", pose.name)
|
||||||
|
|
||||||
# [rotation, scale, translation]
|
# [rotation, scale, translation]
|
||||||
data = []
|
data = []
|
||||||
for i in range(len(bone_names)):
|
for i in range(len(bone_names)):
|
||||||
data.append([[None, None, None, None], [None, None, None], [None, None, None]])
|
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]
|
marker = armature.pose_library.pose_markers[index]
|
||||||
frame = marker.frame
|
frame = marker.frame
|
||||||
action = bpy.data.actions[armature.pose_library.name]
|
action = bpy.data.actions[armature.pose_library.name]
|
||||||
for g in action.groups:
|
for g in action.groups:
|
||||||
if not g.name in bone_names:
|
if not g.name in bone_names:
|
||||||
continue
|
continue
|
||||||
bone_index = bone_names.index(g.name)
|
bone_index = bone_names.index(g.name)
|
||||||
for ch in g.channels:
|
for ch in g.channels:
|
||||||
value = ch.evaluate(float(frame))
|
value = ch.evaluate(float(frame))
|
||||||
if ch.data_path.find('rotation_quaternion') != -1:
|
if ch.data_path.find('rotation_quaternion') != -1:
|
||||||
data[bone_index][0][ch.array_index] = value
|
data[bone_index][0][ch.array_index] = value
|
||||||
elif ch.data_path.find('scale') != -1:
|
elif ch.data_path.find('scale') != -1:
|
||||||
data[bone_index][1][ch.array_index] = value
|
data[bone_index][1][ch.array_index] = value
|
||||||
elif ch.data_path.find('location') != -1:
|
elif ch.data_path.find('location') != -1:
|
||||||
data[bone_index][2][ch.array_index] = value
|
data[bone_index][2][ch.array_index] = value
|
||||||
|
|
||||||
new_data = []
|
new_data = []
|
||||||
for d in data:
|
for d in data:
|
||||||
rotation = tuple([d[0][1], d[0][2], d[0][3], d[0][0]])
|
rotation = tuple([d[0][1], d[0][2], d[0][3], d[0][0]])
|
||||||
scale = d[1][0]
|
scale = d[1][0]
|
||||||
translation = tuple(d[2])
|
translation = tuple(d[2])
|
||||||
new_data.append((rotation, scale, translation))
|
new_data.append((rotation, scale, translation))
|
||||||
poses.append((pose.name, new_data))
|
poses.append((pose.name, new_data))
|
||||||
|
|
||||||
def to_bytes(obj):
|
def to_bytes(obj):
|
||||||
if type(obj) == Uint8:
|
if type(obj) == Uint8:
|
||||||
|
|
@ -245,6 +246,8 @@ def to_bytes(obj):
|
||||||
if type(obj) == str:
|
if type(obj) == str:
|
||||||
b = obj.encode('utf-8')
|
b = obj.encode('utf-8')
|
||||||
return struct.pack('<I', len(b)) + b
|
return struct.pack('<I', len(b)) + b
|
||||||
|
print("Type", type(obj), "not supported")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
SECTION_MESH = 1
|
SECTION_MESH = 1
|
||||||
SECTION_BONES = 2
|
SECTION_BONES = 2
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue