From 6caf34650d54197894cf21a64ec7454a34bba88f Mon Sep 17 00:00:00 2001 From: kuviman Date: Mon, 10 Jun 2024 14:10:30 +0400 Subject: [PATCH] assuming that i fixed the camera rotation --- crates/geng-camera/src/camera_2d.rs | 2 +- examples/04_camera_controls.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/geng-camera/src/camera_2d.rs b/crates/geng-camera/src/camera_2d.rs index bc26b15e..d42faa1a 100644 --- a/crates/geng-camera/src/camera_2d.rs +++ b/crates/geng-camera/src/camera_2d.rs @@ -10,7 +10,7 @@ pub struct Camera2d { impl AbstractCamera2d for Camera2d { fn view_matrix(&self) -> mat3 { - mat3::rotate(self.rotation) * mat3::translate(-self.center) + mat3::rotate(-self.rotation) * mat3::translate(-self.center) } fn projection_matrix(&self, framebuffer_size: vec2) -> mat3 { mat3::scale(vec2(2.0 * framebuffer_size.y / framebuffer_size.x, 2.0) / self.fov) diff --git a/examples/04_camera_controls.rs b/examples/04_camera_controls.rs index f9ec8513..39c5608a 100644 --- a/examples/04_camera_controls.rs +++ b/examples/04_camera_controls.rs @@ -36,10 +36,10 @@ impl geng::State for State { // Rotating camera if self.geng.window().is_key_pressed(geng::Key::Q) { - self.camera.rotation += Angle::from_radians(delta_time); + self.camera.rotation -= Angle::from_radians(delta_time); } if self.geng.window().is_key_pressed(geng::Key::E) { - self.camera.rotation -= Angle::from_radians(delta_time); + self.camera.rotation += Angle::from_radians(delta_time); } } fn draw(&mut self, framebuffer: &mut ugli::Framebuffer) { @@ -130,7 +130,7 @@ impl geng::State for State { self.prev_touch_distance = now_dist; let now_angle = diff.map(|x| x as f32).arg(); let angle_diff = (now_angle - self.prev_touch_angle).normalized_pi(); - self.camera.rotation -= angle_diff; + self.camera.rotation += angle_diff; self.prev_touch_angle = now_angle; if let Some(start) = self.drag_start { let current_pos = self.camera.screen_to_world(