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:
@@ -8,6 +8,10 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy::input::mouse::{MouseMotion, MouseWheel};
|
||||
use bevy::render::render_asset::RenderAssetUsages;
|
||||
use bevy::render::render_resource::{
|
||||
Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor, TextureViewDimension,
|
||||
};
|
||||
|
||||
pub struct OrbitCameraPlugin;
|
||||
|
||||
@@ -54,10 +58,17 @@ impl Default for OrbitCamera {
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_camera(mut commands: Commands) {
|
||||
fn spawn_camera(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
||||
let orbit = OrbitCamera::default();
|
||||
let transform = orbit_transform(&orbit);
|
||||
|
||||
// The game's ship shader reflects a shared HDR environment cubemap off the
|
||||
// hull (three cube samples — see the shader RE). Reproduce that "look" with a
|
||||
// procedural sky cube feeding Bevy's image-based lighting, so metallic
|
||||
// surfaces reflect an environment instead of reading flat. Procedural (not a
|
||||
// bundled KTX2) so it also works on WASM with no extra assets.
|
||||
let env = make_env_cubemap(&mut images);
|
||||
|
||||
commands.spawn((
|
||||
Camera3d::default(),
|
||||
// Wide near/far so both tiny weapons and multi-thousand-unit stages fit;
|
||||
@@ -69,9 +80,78 @@ fn spawn_camera(mut commands: Commands) {
|
||||
}),
|
||||
transform,
|
||||
orbit,
|
||||
EnvironmentMapLight {
|
||||
diffuse_map: env.clone(),
|
||||
specular_map: env,
|
||||
intensity: 900.0,
|
||||
..default()
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
/// Build a small procedural sky cubemap (6 faces) for image-based lighting.
|
||||
///
|
||||
/// A vertical gradient (bright zenith → warm horizon → dark ground) plus a warm
|
||||
/// "sun" highlight roughly where the game's key light sits — enough for a
|
||||
/// metallic hull to read as reflective rather than flat. Stored as an sRGB cube
|
||||
/// (filterable, no half-float encoding needed); a single mip means reflections
|
||||
/// stay sharp (fine for a shiny ship).
|
||||
fn make_env_cubemap(images: &mut Assets<Image>) -> Handle<Image> {
|
||||
let size: i32 = 64;
|
||||
// Approx key-light direction from the RE (PS c32 ≈ (0,-0.76,-0.65), i.e. light
|
||||
// arriving from top-front); place the bright spot there.
|
||||
let sun = Vec3::new(0.0, 0.85, 0.5).normalize();
|
||||
let zenith = Vec3::new(0.70, 0.80, 0.95);
|
||||
let horizon = Vec3::new(0.42, 0.45, 0.50);
|
||||
let ground = Vec3::new(0.09, 0.09, 0.11);
|
||||
let srgb = |c: f32| (c.clamp(0.0, 1.0).powf(1.0 / 2.2) * 255.0).round() as u8;
|
||||
|
||||
let mut data: Vec<u8> = Vec::with_capacity((size * size * 6 * 4) as usize);
|
||||
for face in 0..6 {
|
||||
for y in 0..size {
|
||||
for x in 0..size {
|
||||
let u = (x as f32 + 0.5) / size as f32 * 2.0 - 1.0;
|
||||
let v = (y as f32 + 0.5) / size as f32 * 2.0 - 1.0;
|
||||
// Standard cube-face → direction mapping.
|
||||
let d = match face {
|
||||
0 => Vec3::new(1.0, -v, -u),
|
||||
1 => Vec3::new(-1.0, -v, u),
|
||||
2 => Vec3::new(u, 1.0, v),
|
||||
3 => Vec3::new(u, -1.0, -v),
|
||||
4 => Vec3::new(u, -v, 1.0),
|
||||
_ => Vec3::new(-u, -v, -1.0),
|
||||
}
|
||||
.normalize();
|
||||
let mut col = if d.y >= 0.0 {
|
||||
horizon.lerp(zenith, (d.y).powf(0.6))
|
||||
} else {
|
||||
horizon.lerp(ground, (-d.y).powf(0.5))
|
||||
};
|
||||
let s = d.dot(sun).max(0.0).powf(60.0);
|
||||
col += Vec3::new(1.0, 0.85, 0.6) * s * 1.5;
|
||||
data.extend_from_slice(&[srgb(col.x), srgb(col.y), srgb(col.z), 255]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut image = Image::new(
|
||||
Extent3d {
|
||||
width: size as u32,
|
||||
height: size as u32,
|
||||
depth_or_array_layers: 6,
|
||||
},
|
||||
TextureDimension::D2,
|
||||
data,
|
||||
TextureFormat::Rgba8UnormSrgb,
|
||||
RenderAssetUsages::RENDER_WORLD,
|
||||
);
|
||||
image.texture_view_descriptor = Some(TextureViewDescriptor {
|
||||
dimension: Some(TextureViewDimension::Cube),
|
||||
..default()
|
||||
});
|
||||
images.add(image)
|
||||
}
|
||||
|
||||
fn orbit_camera(
|
||||
mut query: Query<(&mut OrbitCamera, &mut Transform, &mut Projection)>,
|
||||
mouse_buttons: Res<ButtonInput<MouseButton>>,
|
||||
|
||||
Reference in New Issue
Block a user