mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
1687bfd6ed
This PR adds support for BVH animation files, with a custom animation player and retargeting solution for our Blender Rigify-based skeletal meshes. --------- Co-authored-by: Brooks Palin <brookspalin710@gmail.com>
38 lines
797 B
Rust
38 lines
797 B
Rust
use bevy::{
|
|
asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext},
|
|
utils::BoxedFuture,
|
|
};
|
|
|
|
use super::{
|
|
error::{Anyhow, Error},
|
|
Bvh,
|
|
};
|
|
|
|
#[derive(Default)]
|
|
pub struct BvhLoader;
|
|
|
|
impl AssetLoader for BvhLoader {
|
|
type Asset = Bvh;
|
|
type Settings = ();
|
|
type Error = Error;
|
|
|
|
fn load<'a>(
|
|
&'a self,
|
|
reader: &'a mut Reader,
|
|
_settings: &'a Self::Settings,
|
|
_cx: &'a mut LoadContext,
|
|
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
|
|
Box::pin(async move {
|
|
let mut buf = vec![];
|
|
reader.read_to_end(&mut buf).await.anyhow()?;
|
|
let bvh = studio_bvh::from_bytes(&buf).anyhow()?;
|
|
|
|
Ok(Bvh(bvh))
|
|
})
|
|
}
|
|
|
|
fn extensions(&self) -> &[&str] {
|
|
&["bvh"]
|
|
}
|
|
}
|