implement zooming on right click
This commit is contained in:
parent
b91effd5b2
commit
0f8ef18123
|
@ -49,7 +49,7 @@ Augmented Reality features: (toggle with TAB)
|
||||||
- Heads-Up Display of physical and biological statistics
|
- Heads-Up Display of physical and biological statistics
|
||||||
- Low Light Amplification
|
- Low Light Amplification
|
||||||
- View object information on left click
|
- View object information on left click
|
||||||
- Zoom on right click [planned]
|
- Zoom on right click
|
||||||
- Customizable avatar overlay [planned]
|
- Customizable avatar overlay [planned]
|
||||||
- Distance and time of arrival to targets [planned]
|
- Distance and time of arrival to targets [planned]
|
||||||
- Hackable by malicious agents [planned]
|
- Hackable by malicious agents [planned]
|
||||||
|
|
|
@ -92,11 +92,24 @@ pub fn sync_camera_to_player(
|
||||||
|
|
||||||
pub fn update_fov(
|
pub fn update_fov(
|
||||||
q_player: Query<&actor::LifeForm, With<actor::Player>>,
|
q_player: Query<&actor::LifeForm, With<actor::Player>>,
|
||||||
|
mouse_input: Res<ButtonInput<MouseButton>>,
|
||||||
|
mut settings: ResMut<settings::Settings>,
|
||||||
mut q_camera: Query<&mut Projection, With<Camera>>,
|
mut q_camera: Query<&mut Projection, With<Camera>>,
|
||||||
) {
|
) {
|
||||||
if let (Ok(lifeform), Ok(mut projection)) = (q_player.get_single(), q_camera.get_single_mut())
|
if let (Ok(lifeform), Ok(mut projection)) = (q_player.get_single(), q_camera.get_single_mut())
|
||||||
{
|
{
|
||||||
let fov = (lifeform.adrenaline.powf(3.0) * 45.0 + 45.0).to_radians();
|
let fov: f32;
|
||||||
|
if mouse_input.pressed(settings.key_zoom) {
|
||||||
|
fov = settings.zoom_fov_radians;
|
||||||
|
if !settings.is_zooming {
|
||||||
|
settings.is_zooming = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fov = (lifeform.adrenaline.powf(3.0) * 45.0 + 45.0).to_radians();
|
||||||
|
if settings.is_zooming {
|
||||||
|
settings.is_zooming = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
*projection = Projection::Perspective(PerspectiveProjection { fov: fov, ..default() });
|
*projection = Projection::Perspective(PerspectiveProjection { fov: fov, ..default() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,7 +264,8 @@ pub fn apply_input_to_player(
|
||||||
let mut play_reactionwheel_sound = false;
|
let mut play_reactionwheel_sound = false;
|
||||||
let mut mouse_delta = Vec2::ZERO;
|
let mut mouse_delta = Vec2::ZERO;
|
||||||
let mut pitch_yaw_rot = Vec3::ZERO;
|
let mut pitch_yaw_rot = Vec3::ZERO;
|
||||||
let mouseless_sensitivity = 40.0;
|
let sensitivity_factor = if settings.is_zooming { settings.zoom_sensitivity_factor } else { 1.0 };
|
||||||
|
let mouseless_sensitivity = 40.0 * sensitivity_factor;
|
||||||
if key_input.pressed(settings.key_mouseup) {
|
if key_input.pressed(settings.key_mouseup) {
|
||||||
pitch_yaw_rot[0] -= mouseless_sensitivity;
|
pitch_yaw_rot[0] -= mouseless_sensitivity;
|
||||||
}
|
}
|
||||||
|
@ -284,7 +298,7 @@ pub fn apply_input_to_player(
|
||||||
let angular_slowdown: f64 = (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64;
|
let angular_slowdown: f64 = (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64;
|
||||||
if pitch_yaw_rot.length_squared() > 0.0001 {
|
if pitch_yaw_rot.length_squared() > 0.0001 {
|
||||||
play_reactionwheel_sound = true;
|
play_reactionwheel_sound = true;
|
||||||
pitch_yaw_rot *= settings.mouse_sensitivity * engine.reaction_wheels;
|
pitch_yaw_rot *= settings.mouse_sensitivity * sensitivity_factor * engine.reaction_wheels;
|
||||||
torque.apply_torque(DVec3::from(
|
torque.apply_torque(DVec3::from(
|
||||||
player_transform.rotation * Vec3::new(
|
player_transform.rotation * Vec3::new(
|
||||||
pitch_yaw_rot[0] * 2.0,
|
pitch_yaw_rot[0] * 2.0,
|
||||||
|
|
|
@ -9,11 +9,15 @@ pub struct Settings {
|
||||||
pub volume_sfx: u8,
|
pub volume_sfx: u8,
|
||||||
pub volume_music: u8,
|
pub volume_music: u8,
|
||||||
pub mouse_sensitivity: f32,
|
pub mouse_sensitivity: f32,
|
||||||
|
pub zoom_fov_radians: f32,
|
||||||
|
pub zoom_sensitivity_factor: f32,
|
||||||
pub font_size_hud: f32,
|
pub font_size_hud: f32,
|
||||||
pub font_size_conversations: f32,
|
pub font_size_conversations: f32,
|
||||||
pub hud_active: bool,
|
pub hud_active: bool,
|
||||||
|
pub is_zooming: bool,
|
||||||
pub third_person: bool,
|
pub third_person: bool,
|
||||||
pub key_selectobject: MouseButton,
|
pub key_selectobject: MouseButton,
|
||||||
|
pub key_zoom: MouseButton,
|
||||||
pub key_togglehud: KeyCode,
|
pub key_togglehud: KeyCode,
|
||||||
pub key_exit: KeyCode,
|
pub key_exit: KeyCode,
|
||||||
pub key_restart: KeyCode,
|
pub key_restart: KeyCode,
|
||||||
|
@ -83,11 +87,15 @@ impl Default for Settings {
|
||||||
volume_sfx: 100,
|
volume_sfx: 100,
|
||||||
volume_music: 100,
|
volume_music: 100,
|
||||||
mouse_sensitivity: 0.5,
|
mouse_sensitivity: 0.5,
|
||||||
|
zoom_fov_radians: 20.0f32.to_radians(),
|
||||||
|
zoom_sensitivity_factor: 0.1,
|
||||||
font_size_hud: 32.0,
|
font_size_hud: 32.0,
|
||||||
font_size_conversations: 32.0,
|
font_size_conversations: 32.0,
|
||||||
hud_active: false,
|
hud_active: false,
|
||||||
|
is_zooming: false,
|
||||||
third_person: false,
|
third_person: false,
|
||||||
key_selectobject: MouseButton::Left,
|
key_selectobject: MouseButton::Left,
|
||||||
|
key_zoom: MouseButton::Right,
|
||||||
key_togglehud: KeyCode::Tab,
|
key_togglehud: KeyCode::Tab,
|
||||||
key_exit: KeyCode::Escape,
|
key_exit: KeyCode::Escape,
|
||||||
key_restart: KeyCode::F12,
|
key_restart: KeyCode::F12,
|
||||||
|
|
Loading…
Reference in a new issue