[x3d-public] Blender Python for exporting HAnimMotion animation data. Please doublecheck my work
John Carlson
yottzumm at gmail.com
Wed Sep 20 02:15:22 PDT 2023
I'll work on getting this integrated with the Blender X3DV plugin. Should
be fun! I'm wondering if the numpy research listed here
https://www.web3d.org/x3d/stylesheets/python/python.html has paid off? I
could be a happy guinea pig!
if armature:
animation_data = armature.animation_data
if animation_data:
action = animation_data.action
if action:
values = []
for frame in range(int(action.frame_range.x),
int(action.frame_range.y) + 1):
# frame is frame number
bpy.context.scene.frame_set(frame)
for bone in armature.pose.bones:
values.append(bone.location[0]) # location
values.append(bone.location[1]) # location
values.append(bone.location[2]) # location
values.append(bone.rotation_euler[0]) # rotation_euler
values.append(bone.rotation_euler[1]) # rotation_euler
values.append(bone.rotation_euler[2]) # rotation_euler
# values.append(bone.scale[0]) # scale
# values.append(bone.scale[1]) # scale
# values.append(bone.scale[2]) # scale
numbones = len(armature.pose.bones)
hAnimMotion = HAnimMotion(
channels="6 Xposition Yposition Zposition Xrotation
Yrotation Zrotation " * numbones,
joints=" ".join(bone.name for bone in armature.pose.bones),
values=MFFloat(values)
)
print(hAnimMotion.JSON())
else:
print("No animation data associated with the armature.")
else:
print("No animation data found for the armature.")
else:
print("No armature found in the scene.")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20230920/e211f71d/attachment.html>
More information about the x3d-public
mailing list