From a29ab0cc4237685db2a7ca9181f96b27d12d983c Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 20 Mar 2024 06:55:54 +0100 Subject: [PATCH] AR now adds AI-generated fake ambient light to the darkness of space --- src/hud.rs | 15 ++++++++++++++- src/world.rs | 5 ----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/hud.rs b/src/hud.rs index 08e102d..203c810 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -10,6 +10,8 @@ pub const FONT: &str = "external/NotoSansSC-Thin.ttf"; pub const LOG_MAX: usize = 20; pub const LOG_MAX_TIME_S: u64 = 20; pub const CHOICE_NONE: &str = ""; +pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK +pub const AMBIENT_LIGHT_AR: f32 = 20.0; pub struct HudPlugin; impl Plugin for HudPlugin { @@ -106,6 +108,7 @@ fn setup( settings: Res, asset_server: Res, mut log: ResMut, + mut ambient_light: ResMut, ) { log.info("Customer wake-up registered.".to_string()); log.info("Systems reactivated.".to_string()); @@ -299,6 +302,13 @@ fn setup( ChatText, )); }); + + // AR-related things + ambient_light.brightness = if settings.hud_active { + AMBIENT_LIGHT_AR + } else { + AMBIENT_LIGHT + }; } fn update( @@ -342,7 +352,7 @@ fn update( let mut choices: Vec = Vec::new(); let mut count = 1; for choice in &q_choices { - choices.push(format!("[{}. @{}: {}]", + choices.push(format!("[{}] @{}: {}", count, choice.recipient, choice.text)); count += 1; } @@ -377,6 +387,7 @@ fn handle_input( mut evwriter_sfx: EventWriter, mut evwriter_togglemusic: EventWriter, q_choices: Query<&ChoiceAvailable>, + mut ambient_light: ResMut, ) { if keyboard_input.just_pressed(settings.key_togglehud) { if let Ok(mut vis) = query.get_single_mut() { @@ -384,10 +395,12 @@ fn handle_input( if *vis == Visibility::Inherited { *vis = Visibility::Hidden; settings.hud_active = false; + ambient_light.brightness = AMBIENT_LIGHT; bloomsettings.composite_mode = BloomCompositeMode::EnergyConserving; } else { *vis = Visibility::Inherited; settings.hud_active = true; + ambient_light.brightness = AMBIENT_LIGHT_AR; bloomsettings.composite_mode = BloomCompositeMode::EnergyConserving; //bloomsettings.composite_mode = BloomCompositeMode::Additive; } diff --git a/src/world.rs b/src/world.rs index 48337f9..ab64859 100644 --- a/src/world.rs +++ b/src/world.rs @@ -61,8 +61,6 @@ pub fn setup( mut commands: Commands, mut meshes: ResMut>, mut materials: ResMut>, - mut ambient_light: ResMut, -// settings: Res, asset_server: Res, ) { // let cubemap_handle = asset_server.load(ASSET_CUBEMAP); @@ -293,9 +291,6 @@ pub fn setup( }, )); - // Space is DARK - ambient_light.brightness = 0.0; - // Add Light from the Sun commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight {