mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-18 07:35:19 +00:00
BVH animation loading / retargeting (#25)
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>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user