mirror of
https://github.com/storytold/bevy-mocap.git
synced 2026-10-13 23:52:47 +00:00
initial test
This commit is contained in:
+3
-9
@@ -4,19 +4,13 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
|
||||
[dependencies]
|
||||
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]
|
||||
bevy = { version = "0.12", default-features = true }
|
||||
dexterous_developer = "0.1"
|
||||
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_inspector_egui::quick::WorldInspectorPlugin;
|
||||
use dexterous_developer::{hot_bevy_main, InitialPlugins};
|
||||
|
||||
#[hot_bevy_main]
|
||||
pub fn bevy_main(initial_plugins: impl InitialPlugins) {
|
||||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(initial_plugins.initialize::<DefaultPlugins>())
|
||||
.add_plugins(WorldInspectorPlugin::new())
|
||||
.insert_resource(DirectionalLightShadowMap { size: 4096 })
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugins(WorldInspectorPlugin::new())
|
||||
.add_systems(Startup, setup)
|
||||
.run();
|
||||
}
|
||||
@@ -44,5 +42,4 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
scene: asset_server.load("example.gltf#Scene0"),
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+55
-6
@@ -1,14 +1,63 @@
|
||||
pub fn add(left: usize, right: usize) -> usize {
|
||||
left + right
|
||||
use std::{path::Display, sync::Arc};
|
||||
|
||||
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)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{CSVAnimation, CSVParseError};
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
fn given_no_data_the_csv_doesnt_parse() {
|
||||
assert_eq!(CSVAnimation::parse("").err().unwrap(), CSVParseError::NoData)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user