got some of it to work

Objects
Milk.H 2023-03-30 15:57:25 +02:00
parent 83d940b25b
commit 397a86043a
No known key found for this signature in database
GPG Key ID: 3D9DAE46AAC37BD8
4 changed files with 27 additions and 12 deletions

View File

@ -15,7 +15,7 @@ pub enum dEvent
getObj(i32),
addWindow(OpenWindows),
removeWindow(OpenWindows),
setObj(cgmath::Vector3<f32>, cgmath::Vector3<f32>),
setObj(cgmath::Vector3<f32>),
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

5
src/objects.rs Normal file
View File

@ -0,0 +1,5 @@
//! an Object Module for defining Objects
use crate::model::Model;
struct

View File

@ -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) => ()

View File

@ -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)
{