Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion blender-4.1/iqm_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,33 @@ def collectBones(context, armature, scale):
worklist.append(child)
print('Collected %d bones' % len(worklist))
return bones


def clearArmaturePose(armature, clear_object=False):
"""Reset every pose-bone to identity (rest) so sampling starts clean."""
for pb in armature.pose.bones:
pb.location = mathutils.Vector((0.0, 0.0, 0.0))
if pb.rotation_mode == 'QUATERNION':
pb.rotation_quaternion = mathutils.Quaternion((1.0, 0.0, 0.0, 0.0))
else:
pb.rotation_euler = mathutils.Euler((0.0, 0.0, 0.0), pb.rotation_mode)
pb.scale = mathutils.Vector((1.0, 1.0, 1.0))
pb.matrix_basis = mathutils.Matrix.Identity(4)

if clear_object:
armature.location = mathutils.Vector((0.0, 0.0, 0.0))
if armature.rotation_mode == 'QUATERNION':
armature.rotation_quaternion = mathutils.Quaternion((1.0, 0.0, 0.0, 0.0))
else:
armature.rotation_euler = mathutils.Euler((0.0, 0.0, 0.0), armature.rotation_mode)
armature.scale = Vector((1.0, 1.0, 1.0))

def collectAnim(context, armature, scale, bones, action, startframe = None, endframe = None):
scene = context.scene
depsgraph = context.evaluated_depsgraph_get()

clearArmaturePose(armature, clear_object=False)
depsgraph.update()

if startframe is None or endframe is None:
startframe, endframe = action.frame_range
startframe = int(startframe)
Expand Down Expand Up @@ -1161,3 +1185,4 @@ def unregister():
if __name__ == "__main__":
register()