From 8201c8e2a7ff85383ff7606513778253aae7e666 Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Fri, 14 Apr 2023 20:58:23 +0200 Subject: =?UTF-8?q?=E2=9C=A8=20Add=20support=20for=20camera=20rotation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before you could only move the position of the camera. - Add support for turning camera by holding down left mouse. - Add support for turning camera with arrow keys. - Add Mouse move callback for key_inputs. --- racer-tracer/src/scene_controller.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'racer-tracer/src/scene_controller.rs') diff --git a/racer-tracer/src/scene_controller.rs b/racer-tracer/src/scene_controller.rs index 4a867f5..3ca5b70 100644 --- a/racer-tracer/src/scene_controller.rs +++ b/racer-tracer/src/scene_controller.rs @@ -3,8 +3,13 @@ pub mod interactive; use slog::Logger; use crate::{ - camera::Camera, config::Config, error::TracerError, image::Image, key_inputs::KeyCallback, - scene::Scene, terminal::Terminal, + camera::Camera, + config::Config, + error::TracerError, + image::Image, + key_inputs::{KeyCallback, MouseCallback}, + scene::Scene, + terminal::Terminal, }; pub fn create_screen_buffer(image: &Image) -> Vec { @@ -23,7 +28,9 @@ pub struct SceneData { pub trait SceneController: Send + Sync { // Return a vector of key callbacks. The provided closure will be // called when the corresponding key is release/pressed. - fn get_inputs(&self) -> Vec; + fn key_inputs(&self) -> Vec; + + fn mouse_input(&self) -> Option; // Render function fn render(&self) -> Result<(), TracerError>; -- cgit v1.2.3