feat(formats,viewer): movie subtitles, voice decode, and the movie manifest
The movie cutscene subtitle + voice pipeline, driven by the ADVERTISE_MOVIE manifest (the authoritative movie -> subtitle -> voice index). Also flushes several sessions of local WIP (async viewer loading, grouped-pool XBG7/hero-ship decode, drawlog tooling). See docs/HANDOFF-movie-voice-subtitles-2026-07-19.md. Subtitles (movie_subtitle.rs): - Full movie->track->text chain; join multi-line captions sharing one timing (fixes S13A dropped "Look at it father" line); overlap-safe active_cues(); Latin-1 accents preserved. Voice (slb.rs): XACT .slb -> XMA1 RIFF; take the FIRST sub-wave bounded by its declared data size (fixes S10-S16 alternate-take garble); list_voice_clips. Manifest (movie_manifest.rs): parse ADVERTISE_MOVIE (0x5B983A08) for the real movie->voice binding (not always VOICE_<movie>; e.g. hokyu -> VOICE_D_* in etc\). Resolve the token's sound.pak path via sounds.tbl. DIRECT bindings only — the demo-id shared-clip fallback for unbound hokyu movies was verified WRONG in-game and reverted (unbound hokyu stay unvoiced; correct join key is an OPEN problem). Viewer: manifest-driven voice (movie player toggle + solo button), standalone "Voice Lines" browser, stacked caption overlay. Tests: 46 formats-lib + 11 viewer-lib + movie_manifest/movie_subtitle/slb disc tests; full workspace green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
//! Run: `cargo test -p sylpheed-formats --test mesh_disc -- --ignored --nocapture`
|
||||
|
||||
use std::path::PathBuf;
|
||||
use sylpheed_formats::mesh::Xbg7Model;
|
||||
use sylpheed_formats::mesh::{material_groups, node_transforms, submesh_albedos, Xbg7Model};
|
||||
|
||||
fn res3d_dir() -> Option<PathBuf> {
|
||||
if let Ok(p) = std::env::var("SYLPHEED_RES3D") {
|
||||
@@ -21,6 +21,119 @@ fn res3d_dir() -> Option<PathBuf> {
|
||||
default.is_dir().then_some(default)
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires extracted disc models — set SYLPHEED_RES3D"]
|
||||
fn hero_ship_submesh_material_graph() {
|
||||
let Some(dir) = res3d_dir() else {
|
||||
eprintln!("SKIP: resource3d dir not found (set SYLPHEED_RES3D)");
|
||||
return;
|
||||
};
|
||||
// The XBG7 node/material graph tags each sub-mesh record with its own albedo
|
||||
// (`rou_…_col` → TX2D name). DeltaSaber_T `f001`: the 7 detail parts use
|
||||
// bdy_04/06/07 — NOT the body's bdy_01a — which is the per-part texturing the
|
||||
// viewer needs so fins aren't painted with the hull map.
|
||||
let bytes = std::fs::read(dir.join("DeltaSaber_T.xpr")).unwrap();
|
||||
let mut map = std::collections::HashMap::new();
|
||||
for (v, i, name) in submesh_albedos(&bytes, "f001") {
|
||||
map.insert((v, i), name);
|
||||
}
|
||||
// (vtx, idx) → expected albedo (rou_ stripped = TX2D name).
|
||||
assert_eq!(map.get(&(314, 645)).map(String::as_str), Some("f001_bdy_04_col"));
|
||||
assert_eq!(map.get(&(48, 84)).map(String::as_str), Some("f001_bdy_04_col"));
|
||||
assert_eq!(map.get(&(96, 180)).map(String::as_str), Some("f001_bdy_06_col"));
|
||||
assert_eq!(map.get(&(60, 108)).map(String::as_str), Some("f001_bdy_07_col"));
|
||||
// Names strip cleanly to real TX2D resources.
|
||||
let tex = sylpheed_formats::texture::X360Texture::texture_names(&bytes);
|
||||
for name in map.values() {
|
||||
assert!(tex.iter().any(|t| t == name), "albedo {name} not a TX2D resource");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires extracted disc models — set SYLPHEED_RES3D"]
|
||||
fn hero_ship_body_splits_by_material() {
|
||||
let Some(dir) = res3d_dir() else {
|
||||
eprintln!("SKIP: resource3d dir not found (set SYLPHEED_RES3D)");
|
||||
return;
|
||||
};
|
||||
// The merged body (sub0 = 24561 indices / 8187 tris) is drawn as 9 groups
|
||||
// sharing one index buffer, each with its own albedo (bdy_01a hull, bdy_01b,
|
||||
// bdy_02/03, and the `daiza` hangar stand). `material_groups` recovers the
|
||||
// cumulative-offset chain so the viewer can texture each slice.
|
||||
let bytes = std::fs::read(dir.join("DeltaSaber_T.xpr")).unwrap();
|
||||
let groups = material_groups(&bytes, "f001", 24561);
|
||||
assert_eq!(groups.len(), 9, "body must split into 9 material groups");
|
||||
// Offsets chain from 0 and cover the whole index buffer exactly.
|
||||
let mut cursor = 0usize;
|
||||
for g in &groups {
|
||||
assert_eq!(g.idx_offset, cursor, "group offsets must be contiguous");
|
||||
cursor += g.idx_count;
|
||||
}
|
||||
assert_eq!(cursor, 24561, "groups must cover all body indices");
|
||||
// Expected per-group albedo (verified against the GPU draw log).
|
||||
let albedos: Vec<&str> = groups.iter().map(|g| g.albedo.as_str()).collect();
|
||||
assert_eq!(
|
||||
albedos,
|
||||
[
|
||||
"f001_bdy_01a_col",
|
||||
"f001_bdy_01a_col",
|
||||
"f001_bdy_01a_col",
|
||||
"f001_bdy_01b_col",
|
||||
"f001_bdy_01a_col",
|
||||
"f001_bdy_01b_col",
|
||||
"f001_bdy_02_col",
|
||||
"f001_bdy_03_col",
|
||||
"f001_bdy_daiza_col",
|
||||
]
|
||||
);
|
||||
// A single-material detail part (sub1 = 645 indices) → one group, bdy_04.
|
||||
let fin = material_groups(&bytes, "f001", 645);
|
||||
assert_eq!(fin.len(), 1);
|
||||
assert_eq!(fin[0].albedo, "f001_bdy_04_col");
|
||||
assert_eq!(fin[0].idx_offset, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires extracted disc models — set SYLPHEED_RES3D"]
|
||||
fn hero_ship_node_transforms_move_fins_to_tail() {
|
||||
let Some(dir) = res3d_dir() else {
|
||||
eprintln!("SKIP: resource3d dir not found (set SYLPHEED_RES3D)");
|
||||
return;
|
||||
};
|
||||
// For the DeltaSaber, node_transforms returns the MEASURED runtime placements
|
||||
// (Canary draw-log WVP; see mesh.rs::DELTASABER_MEASURED) — the fin assemblies
|
||||
// are mounted OUT on the nacelles (world X ≈ −4.4..−6.6), an offset the static
|
||||
// graph omits. Body identity; each part a left/right mirrored pair. Vertex
|
||||
// space: X right, Y up, Z fore/aft (engines at −Z).
|
||||
let bytes = std::fs::read(dir.join("DeltaSaber_T.xpr")).unwrap();
|
||||
let places = node_transforms(&bytes, "f001");
|
||||
assert!(!places.is_empty(), "expected node placements");
|
||||
// Body (sub 0) identity, drawn once.
|
||||
let body: Vec<_> = places.iter().filter(|p| p.sub_index == 0).collect();
|
||||
assert_eq!(body.len(), 1, "body drawn once");
|
||||
assert!(body[0].t.iter().all(|c| c.abs() < 0.1), "body must not translate");
|
||||
assert!(!body[0].reflect, "body is not mirrored");
|
||||
// Fin bdy_04 (sub 1): mirrored pair near the tail, mounted OUT on the nacelle
|
||||
// (|X| ≈ 5.2, not the graph's inboard ≈1.1).
|
||||
let fins: Vec<_> = places.iter().filter(|p| p.sub_index == 1).collect();
|
||||
assert_eq!(fins.len(), 2, "V-tail is a mirrored pair");
|
||||
assert!(fins.iter().all(|f| (f.t[2] + 9.72).abs() < 0.3), "fin fore/aft ≈ −9.7");
|
||||
assert!(fins.iter().all(|f| f.t[0].abs() > 4.0), "fin mounted out on the nacelle");
|
||||
assert!(fins[0].t[0] * fins[1].t[0] < 0.0, "the pair mirrors across X");
|
||||
assert!(fins.iter().any(|f| f.reflect), "one of the pair is reflected");
|
||||
// Winglet bdy_06 (sub 4): on the nacelle (|X| ≈ 6.6, Z ≈ −15.5).
|
||||
let wings: Vec<_> = places.iter().filter(|p| p.sub_index == 4).collect();
|
||||
assert_eq!(wings.len(), 2, "L/R winglet pair");
|
||||
assert!(wings.iter().all(|p| p.t[0].abs() > 6.0 && (p.t[2] + 15.5).abs() < 0.3),
|
||||
"winglets out on the nacelle");
|
||||
assert!(wings[0].t[0] * wings[1].t[0] < 0.0, "winglets mirror across X");
|
||||
// Small fin bdy_10 (sub 6): inboard nacelle stub (|X| ≈ 4.45, Z ≈ −17).
|
||||
let sfins: Vec<_> = places.iter().filter(|p| p.sub_index == 6).collect();
|
||||
assert_eq!(sfins.len(), 2, "L/R small-fin pair");
|
||||
assert!(sfins.iter().all(|p| (p.t[0].abs() - 4.45).abs() < 0.3), "small fins on the stub");
|
||||
assert!(sfins[0].t[0] * sfins[1].t[0] < 0.0, "small fins mirror across X");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "requires extracted disc models — set SYLPHEED_RES3D"]
|
||||
fn weapon_model_decodes_to_expected_geometry() {
|
||||
|
||||
Reference in New Issue
Block a user