mirror of
https://github.com/storytold/bevy-mocap.git
synced 2026-10-23 08:05:24 +00:00
initial test
This commit is contained in:
+3
-9
@@ -4,19 +4,13 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
[lib]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.12", default-features = false, features = ["bevy_pbr", "bevy_render", "bevy_asset", "animation", "bevy_animation"]}
|
bevy = { version = "0.12", default-features = false, features = ["bevy_pbr", "bevy_render", "bevy_asset", "animation", "bevy_animation"]}
|
||||||
serde = "1"
|
serde = { version = "1", features = ["derive"] }
|
||||||
|
csv = "1.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bevy = { version = "0.12", default-features = true }
|
bevy = { version = "0.12", default-features = true }
|
||||||
dexterous_developer = "0.1"
|
|
||||||
bevy-inspector-egui = "0.22"
|
bevy-inspector-egui = "0.22"
|
||||||
|
|
||||||
|
|
||||||
[[example]]
|
|
||||||
name = "simple_example"
|
|
||||||
path = "examples/simple_example.rs"
|
|
||||||
crate-type = ["dylib"]
|
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
use bevy::{pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap}, prelude::*};
|
use bevy::{pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap}, prelude::*};
|
||||||
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
||||||
use dexterous_developer::{hot_bevy_main, InitialPlugins};
|
|
||||||
|
|
||||||
#[hot_bevy_main]
|
fn main() {
|
||||||
pub fn bevy_main(initial_plugins: impl InitialPlugins) {
|
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(initial_plugins.initialize::<DefaultPlugins>())
|
|
||||||
.add_plugins(WorldInspectorPlugin::new())
|
|
||||||
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(WorldInspectorPlugin::new())
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@@ -45,4 +43,3 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+55
-6
@@ -1,14 +1,63 @@
|
|||||||
pub fn add(left: usize, right: usize) -> usize {
|
use std::{path::Display, sync::Arc};
|
||||||
left + right
|
|
||||||
|
use bevy::utils::{default, HashMap, Instant};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub struct MorphID {
|
||||||
|
id: usize,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
|
pub struct RelativeFrameTime(f32);
|
||||||
|
|
||||||
|
impl MorphID {
|
||||||
|
pub fn new(id: usize) -> Self {
|
||||||
|
Self {
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct CSVFrame {
|
||||||
|
timestamp: RelativeFrameTime,
|
||||||
|
morphs: HashMap<MorphID, f32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
pub struct CSVAnimation {
|
||||||
|
frames: Vec<CSVFrame>,
|
||||||
|
morph_names: Vec<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
|
pub enum CSVParseError {
|
||||||
|
NoData
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::fmt::Display for CSVParseError {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.write_str(&format!("{self:?}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::error::Error for CSVParseError {}
|
||||||
|
|
||||||
|
impl CSVAnimation {
|
||||||
|
pub fn parse(csv: &str) -> Result<CSVAnimation, CSVParseError> {
|
||||||
|
Err(CSVParseError::NoData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use crate::{CSVAnimation, CSVParseError};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn given_no_data_the_csv_doesnt_parse() {
|
||||||
let result = add(2, 2);
|
assert_eq!(CSVAnimation::parse("").err().unwrap(), CSVParseError::NoData)
|
||||||
assert_eq!(result, 4);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user