Skip to content

Commit

Permalink
assuming that i fixed the camera rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
kuviman committed Jun 10, 2024
1 parent 71cbb5e commit 6caf346
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/geng-camera/src/camera_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Camera2d {

impl AbstractCamera2d for Camera2d {
fn view_matrix(&self) -> mat3<f32> {
mat3::rotate(self.rotation) * mat3::translate(-self.center)
mat3::rotate(-self.rotation) * mat3::translate(-self.center)
}
fn projection_matrix(&self, framebuffer_size: vec2<f32>) -> mat3<f32> {
mat3::scale(vec2(2.0 * framebuffer_size.y / framebuffer_size.x, 2.0) / self.fov)
Expand Down
6 changes: 3 additions & 3 deletions examples/04_camera_controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 6caf346

Please sign in to comment.