Crates.io | bvh_anim_parser |
lib.rs | bvh_anim_parser |
version | 1.0.1 |
source | src |
created_at | 2024-05-18 18:28:29.557788 |
updated_at | 2024-05-20 22:05:28.868942 |
description | A .bvh file parser |
homepage | |
repository | https://github.com/WojtekPachowiak/bvh-anim-parser |
max_upload_size | |
id | 1244441 |
size | 1,199,646 |
A Rust library for parsing .bvh files. It not only parses the HIERARCHY and MOTION, but additionaly calculates implicit properties such as global joint positions and rotations, both for the pose (MOTION section) and the rest pose (HIERARCHY section).
Base package:
cargo add bvh_anim_parser
To enable visualization using a bevy
app:
cargo add bvh_anim_parser --features visualize
See examples/example.rs
for an exhaustive usage. This crate offers nothing more than what's presented in that file.
Currently, modifying and writing .bvh files is not supported (let me know if that's something you need).
bevy
app)The 3 red, green, blue vectors can be associated with the global pose rotations (3 column-vectors of 3x3 rotation matrix). Their origin is literally the global pose position. By pressing "R" you can also view the rest pose with its global rest rotations and positions.
src/types.rs
contains all the custom structs and types.src/parse.rs
contains all the functions involved in parsing bvh files and getting additional info. from them.src/visualize.rs
is a bevy
app for visualizing loaded .bvh files. It's purpose was to help me ensure the bvh parser produces sensible results.There are 2 main structs: BvhMetadata
and BvhData
. BvhData
contains numerical data (in the form of 1D and 2D vectors) of positions and rotations of each joint at each frame (both for pose and rest pose). BvhMetadata
contains info. such as frame count, fps and joint indices for extracting data out of BvhData
.
right handed Y-up coordinate system
Only one animation (the legend says, you can embed multiple animations into a single .bvh) per .bvh file allowed.
Hips have translational and rotational components (6 channels), while all the other joints only the rotational one (3 channels).
All rotational components have the same rotation order. For example, if one joint has YZX order while some other has XYZ, then the parser will parse the rotations incorrectly.
The non-ENDSITE joint names must not start with the regex 'end*' (case insensitive) - this pattern is used to recognize ENDSITEs.
One "{" or "}" per line (i.e newlines matter).
Inspect __get_tail_offset(...)
function in src/parse.rs
. It returns the "forward" vector, which is then used to calculate rotation (using cross products, etc.).
Everyone's welcome. Smash that "New issue" button.