From 397a86043af97c298638067873910bdae2f23a65 Mon Sep 17 00:00:00 2001 From: Melik Houij Date: Thu, 30 Mar 2023 15:57:25 +0200 Subject: [PATCH] got some of it to work --- src/debug.rs | 13 ++++++------- src/objects.rs | 5 +++++ src/scene.rs | 14 +++++++++----- src/scene/objects.rs | 7 +++++++ 4 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 src/objects.rs diff --git a/src/debug.rs b/src/debug.rs index eefa13f..330b74c 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -15,7 +15,7 @@ pub enum dEvent getObj(i32), addWindow(OpenWindows), removeWindow(OpenWindows), - setObj(cgmath::Vector3, cgmath::Vector3), + setObj(cgmath::Vector3), exit, } @@ -176,7 +176,7 @@ impl Debug { let mut selectedModel = testI.selectedModel; let mut spinSpeed = testI.spinSpeed; ui.window("POLY I WILL FUCKING") - .size([500.0, 100.0], imgui::Condition::FirstUseEver) + .always_auto_resize(true) .build(|| { ui.text("you serve no purpose in life"); ui.text("Your Purpose in life is to suck my dick"); @@ -197,7 +197,7 @@ impl Debug { { let mut ret = Vec::new(); ui.window("Stats") - .size([300.0, 500.0], imgui::Condition::Always) + .always_auto_resize(true) .build(|| { ui.text("Model Information"); ui.text(format!("count meshes: {}", model.meshesCount)); @@ -219,7 +219,7 @@ impl Debug { { let mut ret = Vec::new(); ui.window("Welcome to the main Menu") - .size([500.0, 500.0], imgui::Condition::Always) + .always_auto_resize(true) .build(|| { ui.text("this is the main Debugger Menu, it's used to Debug the game"); ui.text("although it isn't done yet"); @@ -244,15 +244,14 @@ impl Debug { { let mut ret = Vec::new(); let mut position = makeMint(object.Position); - let mut rotation = makeMint(object.Rotation.v); ui.window("ObjectInfo") + .always_auto_resize(true) .build(|| { ui.text("Position"); ui.input_float3("Position", &mut position).build(); - ui.input_float3("Rotation", &mut rotation).build(); ui.text("WIP"); - ret.push(dEvent::setObj(makeCG(position), makeCG(rotation))); + ret.push(dEvent::setObj(makeCG(position))); }); ret diff --git a/src/objects.rs b/src/objects.rs new file mode 100644 index 0000000..4903397 --- /dev/null +++ b/src/objects.rs @@ -0,0 +1,5 @@ +//! an Object Module for defining Objects + +use crate::model::Model; + +struct diff --git a/src/scene.rs b/src/scene.rs index 1734202..3a691fd 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -137,13 +137,19 @@ impl Scene{ }, Event::KeyDown {keycode: Some(Keycode::P), ..} => { }, - Event::KeyDown {keycode: Some(Keycode::D), ..} => { + Event::KeyDown {keycode: Some(Keycode::Q), ..} => { self.tempData.DebugMode = !self.tempData.DebugMode + }, + Event::KeyDown {keycode: Some(Keycode::W), ..} => { + self.Car.forward(); + }, + Event::KeyDown {keycode: Some(Keycode::A), .. }=> { + self.Car.turn(2.5); } Event::KeyDown {keycode: Some(Keycode::M), ..} => { self.debug.addWindow(debug::OpenWindows::ModelInfo) }, - Event::KeyDown {keycode: Some(Keycode::W), ..} => { + Event::KeyDown {keycode: Some(Keycode::T), ..} => { self.camera.ProcessKeyboard(Camera_Movement::FORWARD, self.tempData.deltaTime); }, _ => {} @@ -183,11 +189,9 @@ impl Scene{ }, dEvent::addWindow(a) => self.debug.addWindow(a), dEvent::removeWindow(a) => self.debug.removeWindow(a), - dEvent::setObj(p, r) => + dEvent::setObj(p) => { self.Car.Transform.Position = p; - self.Car.Transform.Rotation.v = r; - self.Car.Transform.Rotation.normalize(); } // TODO dEvent::getObj(_a) => () diff --git a/src/scene/objects.rs b/src/scene/objects.rs index 6ab090c..c86300c 100644 --- a/src/scene/objects.rs +++ b/src/scene/objects.rs @@ -52,6 +52,13 @@ impl Player { self.Transform.Position += self.Transform.Velocity; self.Transform.Rotation = self.Transform.Rotation.normalize(); } + pub fn forward(&mut self) + { + let forward = self.Transform.Rotation.rotate_vector(cgmath::Vector3::unit_z()); + let distance = forward * 0.01; + self.Transform.Position += distance; + + } pub fn turn(&mut self, amount: f32) {