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/vec3.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'racer-tracer/src/vec3.rs') diff --git a/racer-tracer/src/vec3.rs b/racer-tracer/src/vec3.rs index 9d04cb4..6877eea 100644 --- a/racer-tracer/src/vec3.rs +++ b/racer-tracer/src/vec3.rs @@ -1,3 +1,6 @@ +//TODO: Replace this with glam. +use glam::f32::Vec3 as FVec3; + use std::{fmt, ops}; use serde::Deserialize; @@ -326,6 +329,22 @@ impl fmt::Display for Vec3 { } } +impl From for Vec3 { + fn from(v: FVec3) -> Self { + Vec3::new(v.x as f64, v.y as f64, v.z as f64) + } +} + +impl From for FVec3 { + fn from(v: Vec3) -> Self { + FVec3 { + x: v.data[0] as f32, + y: v.data[1] as f32, + z: v.data[2] as f32, + } + } +} + impl std::fmt::Debug for Vec3 { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Vec3").field("data", &self.data).finish() -- cgit v1.2.3