From 4296c6ac4b94d51755a7058857efd502fc1881e5 Mon Sep 17 00:00:00 2001 From: yuni Date: Mon, 11 Nov 2024 23:20:29 +0100 Subject: [PATCH] add spotlights to mirrors (slow T_T, but faster than ray tracing) --- src/actor.rs | 2 ++ src/cmd.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/actor.rs b/src/actor.rs index 8d0d2c7..f476bf3 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -168,6 +168,8 @@ pub struct MessageOnVehicleEntry(pub String); #[derive(Component)] pub struct PlayersFlashLight; #[derive(Component)] +pub struct MirrorLight; +#[derive(Component)] pub struct WantsMaxRotation(pub f64); #[derive(Component)] pub struct WantsMaxVelocity(pub f64); diff --git a/src/cmd.rs b/src/cmd.rs index c514f8b..e914949 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -101,6 +101,7 @@ struct ParserState { is_planet: bool, is_point_of_interest: bool, is_tidally_locked: bool, + is_mirror: bool, orbit_distance: Option, orbit_object_id: Option, orbit_phase: Option, @@ -163,6 +164,7 @@ impl Default for ParserState { is_planet: false, is_point_of_interest: false, is_tidally_locked: false, + is_mirror: false, orbit_distance: None, orbit_object_id: None, orbit_phase: None, @@ -442,6 +444,9 @@ pub fn load_defs(mut ew_spawn: EventWriter) { ["sphere", "yes"] => { state.is_sphere = true; } + ["mirror", "yes"] => { + state.is_mirror = true; + } ["id", id] => { state.id = id.to_string(); } @@ -915,6 +920,9 @@ fn spawn_scenes( state.angular_momentum = DVec3::ZERO; } + // command: mirror yes + state.is_mirror = true; + // command: scale 10.0 state.model_scale = 10.0; @@ -1239,6 +1247,32 @@ fn spawn_entities( if !state.ar_models.is_empty() { actor.insert(hud::AugmentedRealityOverlayBroadcaster); } + if state.is_mirror { + actor.with_children(|builder| { + // TODO: rotate the light appropriately + builder.spawn(( + world::DespawnOnPlayerDeath, + actor::MirrorLight, + SpotLightBundle { + transform: Transform { + translation: Vec3::new(0.0, 0.0, 1.0), + rotation: Quat::from_rotation_y(180f32.to_radians()), + ..default() + }, + spot_light: SpotLight { + intensity: 2e7, + color: Color::WHITE, + shadows_enabled: false, + inner_angle: PI32 / 16.0, + outer_angle: PI32 / 13.0, + range: 1000.0, + ..default() + }, + ..default() + }, + )); + }); + } if state.is_player { actor.with_children(|builder| { builder.spawn((