Wasserwecken / bvhio

Read, write, edit and create .bvh files with hierarchical 3D transforms
MIT License
47 stars 11 forks source link

Processing of Bandai-Namco-Research-Motion Dataset #9

Closed zhou-fy closed 1 year ago

zhou-fy commented 1 year ago

Hello, I am using your method to process Bandai-Namco-Research-Motion Dataset. Thank you very much for your great work! But I wonder if there is any way to converting non-root 6 channels to 3, while keeping the channel with root joint at 6? And how to ensure that the three channels of non- root are in the order of "Zrotation Yrotation Xrotation"? As the picture below shows: Snipaste_2023-09-13_21-40-15 Thank you very much!

Wasserwecken commented 1 year ago

Hey thank you! There already has been an issue with this exact problem. I gonna add this request to the readme now :) Heres the code:

import bvhio

bvh = bvhio.readAsBvh('combat_idle_turn_270_R_001__A373.bvh')

# this removes the root bone if you want
bvh.Root = bvh.Root.Children[0]

for joint, index, depth in bvh.Root.layout():

    # keep positons if it is the hip
    joint.Channels = ['Xposition', 'Yposition', 'Zposition'] if joint.Name == "Hips" else []

    # set order for euler rotation
    joint.Channels.extend(['Zrotation', 'Yrotation', 'Xrotation'])

bvhio.writeBvh('new.bvh', bvh, percision=6)
zhou-fy commented 1 year ago

Oh, I neglected that before. Your work is great and has helped me a lot. Thank you very much!