recording works!

This commit is contained in:
Lee-Orr
2024-02-12 12:36:33 -05:00
parent 9e778e5cc1
commit 670ef03f4b
5 changed files with 78 additions and 3 deletions
+54
View File
@@ -0,0 +1,54 @@
[
["eyeBlinkLeft", "EyeBlinkLeft"],
["eyeLookDownLeft", "EyeLookDownLeft"],
["eyeLookInLeft", "EyeLookInLeft"],
["eyeLookOutLeft", "EyeLookOutLeft"],
["eyeLookUpLeft", "EyeLookUpLeft"],
["eyeSquintLeft", "EyeSquintLeft"],
["eyeWideLeft", "EyeWideLeft"],
["eyeBlinkRight", "EyeBlinkRight"],
["eyeLookDownRight", "EyeLookDownRight"],
["eyeLookInRight", "EyeLookInRight"],
["eyeLookOutRight", "EyeLookOutRight"],
["eyeLookUpRight", "EyeLookUpRight"],
["eyeSquintRight", "EyeSquintRight"],
["eyeWideRight", "EyeWideRight"],
["jawForward", "JawForward"],
["jawLeft", "JawLeft"],
["jawRight", "JawRight"],
["jawOpen", "JawOpen"],
["mouthClose", "MouthClose"],
["mouthFunnel", "MouthFunnel"],
["mouthPucker", "MouthPucker"],
["mouthLeft", "MouthLeft"],
["mouthRight", "MouthRight"],
["mouthSmileLeft", "MouthSmileLeft"],
["mouthSmileRight", "MouthSmileRight"],
["mouthFrownLeft", "MouthFrownLeft"],
["mouthFrownRight", "MouthFrownRight"],
["mouthDimpleLeft", "MouthDimpleLeft"],
["mouthDimpleRight", "MouthDimpleRight"],
["mouthStretchLeft", "MouthStretchLeft"],
["mouthStretchRight", "MouthStretchRight"],
["mouthRollLower", "MouthRollLower"],
["mouthRollUpper", "MouthRollUpper"],
["mouthShrugLower", "MouthShrugLower"],
["mouthShrugUpper", "MouthShrugUpper"],
["mouthPressLeft", "MouthPressLeft"],
["mouthPressRight", "MouthPressRight"],
["mouthLowerDownLeft", "MouthLowerDownLeft"],
["mouthLowerDownRight", "MouthLowerDownRight"],
["mouthUpperUpLeft", "MouthUpperUpLeft"],
["mouthUpperUpRight", "MouthUpperUpRight"],
["browDownLeft", "BrowDownLeft"],
["browDownRight", "BrowDownRight"],
["browInnerUp", "BrowInnerUp"],
["browOuterUpLeft", "BrowOuterUpLeft"],
["browOuterUpRight", "BrowOuterUpRight"],
["cheekPuff", "CheekPuff"],
["cheekSquintLeft", "CheekSquintLeft"],
["cheekSquintRight", "CheekSquintRight"],
["noseSneerLeft", "NoseSneerLeft"],
["noseSneerRight", "NoseSneerRight"],
["tongueOut", "TongueOut"]
]
+2 -1
View File
@@ -1,5 +1,6 @@
{
"csv": "./fake_test.csv",
"root_name": "pascal_Head",
"fps": 4
"fps": 4,
"mapping": "example_mapping.json"
}
+6
View File
@@ -0,0 +1,6 @@
{
"csv": "./20240205_shapekey_BevyImplementationFaceCap_5/shapekey_BevyImplementationFaceCap_5_ScottiPhone_cal.morph_anim.csv",
"root_name": "pascal_Head",
"fps": 60,
"mapping": "example_mapping.json"
}
+1 -1
View File
@@ -57,7 +57,7 @@ fn setup_animation(
mut players: Query<Entity, (With<MorphWeights>, Without<AnimationRunning>)>,
) {
for entity in &mut players {
let handle = asset_server.load("fake_test.morph_anim.json");
let handle = asset_server.load("recorded_test.morph_anim.json");
let mut player = AnimationPlayer::default();
player.play(handle.clone()).repeat();
+15 -1
View File
@@ -278,8 +278,12 @@ struct ClipInfo {
pub csv: PathBuf,
pub root_name: String,
pub fps: Option<f32>,
pub mapping: Option<PathBuf>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
struct CSVAnimationMapping(Vec<(String, String)>);
#[derive(Default)]
pub struct CSVAnimationLoader;
@@ -291,6 +295,8 @@ pub enum CSVAnimationLoaderError {
ClipInfoParseError(serde_json::Error),
CSVReadBytesError(ReadAssetBytesError),
CSVStringError(FromUtf8Error),
MappingReadBytesError(ReadAssetBytesError),
MappingParseError(serde_json::Error),
}
impl std::fmt::Display for CSVAnimationLoaderError {
@@ -341,7 +347,15 @@ impl AssetLoader for CSVAnimationLoader {
csv_animation.frames.len()
);
Ok(csv_animation.generate_clip(&clip_info.root_name, Option::<&[(&str, &str)]>::None))
let mapping = if let Some(mapping) = clip_info.mapping {
let mapping = load_context.read_asset_bytes(mapping).await.map_err(CSVAnimationLoaderError::MappingReadBytesError)?;
let mapping: CSVAnimationMapping = serde_json::from_slice(&mapping).map_err(CSVAnimationLoaderError::MappingParseError)?;
Some(mapping.0)
} else {
None
};
Ok(csv_animation.generate_clip(&clip_info.root_name, mapping.as_deref()))
})
}