mirror of https://github.com/Leinnan/doppler.git
Client debug info draw
This commit is contained in:
parent
d778df90c3
commit
eea2935e4e
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
use crate::gaia::camera::*;
|
use crate::gaia::camera::*;
|
||||||
use crate::gaia::{consts,macros};
|
use crate::gaia::{consts};
|
||||||
use crate::gaia::*;
|
use crate::gaia::*;
|
||||||
use imgui_glfw_rs::glfw;
|
use imgui_glfw_rs::glfw;
|
||||||
use crate::gaia::components::{Transform,ModelComponent};
|
use crate::gaia::components::{Transform,ModelComponent};
|
||||||
|
|
@ -81,6 +81,23 @@ impl Client for ExampleClient {
|
||||||
.enable_mouse_movement(window.get_key(Key::LeftControl) != Action::Press);
|
.enable_mouse_movement(window.get_key(Key::LeftControl) != Action::Press);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui) {
|
||||||
|
use imgui_glfw_rs::imgui;
|
||||||
|
use imgui::*;
|
||||||
|
use imgui_inspect::InspectArgsStruct;
|
||||||
|
Window::new(im_str!("Object info"))
|
||||||
|
.size([250.0, 250.0], Condition::FirstUseEver)
|
||||||
|
.build(&ui, || {
|
||||||
|
let mut selected_mut = vec![&mut self.model.transform];
|
||||||
|
<Transform as imgui_inspect::InspectRenderStruct<Transform>>::render_mut(
|
||||||
|
&mut selected_mut,
|
||||||
|
"Example Struct - Writable",
|
||||||
|
&ui,
|
||||||
|
&InspectArgsStruct::default(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn on_mouse_scroll(&mut self, yoffset: f32){
|
fn on_mouse_scroll(&mut self, yoffset: f32){
|
||||||
self.camera.process_mouse_scroll(yoffset as f32);
|
self.camera.process_mouse_scroll(yoffset as f32);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,5 @@ pub trait Client {
|
||||||
fn on_mouse_move(&mut self, x: f32, y: f32);
|
fn on_mouse_move(&mut self, x: f32, y: f32);
|
||||||
// fn draw<T>(&mut self, engine: &mut Engine<T>) where T: Client;
|
// fn draw<T>(&mut self, engine: &mut Engine<T>) where T: Client;
|
||||||
unsafe fn draw(&mut self);
|
unsafe fn draw(&mut self);
|
||||||
|
fn debug_draw(&mut self, ui: &imgui_glfw_rs::imgui::Ui);
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,49 @@
|
||||||
use crate::gaia::*;
|
use imgui_inspect::InspectArgsDefault;
|
||||||
use crate::gaia::macros;
|
use imgui_inspect::InspectRenderDefault;
|
||||||
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Rad, Vector3};
|
use cgmath::{perspective, vec3, Deg, Matrix4, Point3, Rad, Vector3};
|
||||||
use crate::gaia::model::Model;
|
use crate::gaia::model::Model;
|
||||||
use crate::gaia::shader::Shader;
|
use crate::gaia::shader::Shader;
|
||||||
|
use imgui_glfw_rs::imgui;
|
||||||
|
use imgui_inspect::*;
|
||||||
|
use imgui_inspect_derive::Inspect;
|
||||||
|
use imgui_inspect::InspectArgsStruct;
|
||||||
|
|
||||||
|
struct cgmathVec3f32;
|
||||||
|
impl InspectRenderDefault<Vector3<f32>> for cgmathVec3f32 {
|
||||||
|
fn render(data: &[&Vector3<f32>], label: &'static str, ui: &imgui::Ui, args: &InspectArgsDefault) {
|
||||||
|
ui.text(label);
|
||||||
|
ui.text(format!("{:?}", data));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render_mut(data: &mut [&mut Vector3<f32>], label: &'static str, ui: &imgui::Ui, args: &InspectArgsDefault) -> bool {
|
||||||
|
use imgui::*;
|
||||||
|
ui.text(label);
|
||||||
|
let mut change = false;
|
||||||
|
for el in data.iter_mut() {
|
||||||
|
change |= ui.input_float(im_str!("x"), &mut el.x)
|
||||||
|
.step(0.01)
|
||||||
|
.step_fast(1.0)
|
||||||
|
.build();
|
||||||
|
change |= ui.input_float(im_str!("y"), &mut el.y)
|
||||||
|
.step(0.01)
|
||||||
|
.step_fast(1.0)
|
||||||
|
.build();
|
||||||
|
change |= ui.input_float(im_str!("z"), &mut el.z)
|
||||||
|
.step(0.01)
|
||||||
|
.step_fast(1.0)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
change
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Inspect, Clone)]
|
||||||
pub struct Transform {
|
pub struct Transform {
|
||||||
|
#[inspect(proxy_type = "cgmathVec3f32")]
|
||||||
pub position: Vector3<f32>,
|
pub position: Vector3<f32>,
|
||||||
|
#[inspect(proxy_type = "cgmathVec3f32")]
|
||||||
pub scale: Vector3<f32>,
|
pub scale: Vector3<f32>,
|
||||||
|
#[inspect(proxy_type = "cgmathVec3f32")]
|
||||||
pub rotation: Vector3<f32>,
|
pub rotation: Vector3<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ impl Engine {
|
||||||
let ui = self.imgui_glfw.frame(&mut self.window, &mut self.imgui);
|
let ui = self.imgui_glfw.frame(&mut self.window, &mut self.imgui);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
self.client.debug_draw(&ui);
|
||||||
use imgui::*;
|
use imgui::*;
|
||||||
let fps = 1.0 / delta_time;
|
let fps = 1.0 / delta_time;
|
||||||
let mut info = self.bg_info;
|
let mut info = self.bg_info;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::mpsc::Receiver;
|
|
||||||
|
|
||||||
use gl;
|
use gl;
|
||||||
|
|
||||||
use image;
|
use image;
|
||||||
use image::DynamicImage::*;
|
use image::DynamicImage::*;
|
||||||
use image::GenericImage;
|
use image::GenericImage;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue