From 4fbe0d8a5745ba31d9b0391fa71f9d749f8a2eb9 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 31 Aug 2023 00:55:27 -0700 Subject: [PATCH] use camera offset --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 99bbe59..57968c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ struct Camera { vel: glam::Vec3, gravity: glam::Vec3, screen_size: (u32, u32), + offset: glam::Vec3, yaw: f32, pitch: f32, controls: u32, @@ -70,7 +71,7 @@ impl Camera { fn to_uniform_data(&self) -> [f32; 16 * 3 + 4] { let aspect = self.screen_size.0 as f32 / self.screen_size.1 as f32; let proj = glam::Mat4::perspective_rh(consts::FRAC_PI_2, aspect, 1.0, 200.0); - let view = (glam::Mat4::from_translation(self.pos) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.yaw, self.pitch, 0f32)).inverse(); + let view = (glam::Mat4::from_translation(self.pos+self.offset) * glam::Mat4::from_euler(glam::EulerRot::YXZ, self.yaw, self.pitch, 0f32)).inverse(); let proj_inv = proj.inverse(); let mut raw = [0f32; 16 * 3 + 4]; @@ -211,6 +212,7 @@ impl strafe_client::framework::Example for Skybox { vel: glam::Vec3 { x: 0.0, y: 0.0, z: 0.0 }, gravity: glam::Vec3 { x: 0.0, y: -100.0, z: 0.0 }, screen_size: (config.width, config.height), + offset: glam::Vec3::new(0.0,4.5,0.0), pitch: 0.0, yaw: 0.0, mv: 2.7,