diff --git a/src/gui.rs b/src/gui.rs index c145a1f..2e7ccd6 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,8 +1,10 @@ use crate::{ camera::Camera, light::Light, + material::*, + node::*, primitive::*, - scene::{Node, Scene}, + scene::*, state::{INIT_FILE, SAVE_FILE}, }; use imgui::*; @@ -33,21 +35,21 @@ const RAYS_MAX: i32 = 10000; const MIN_COLOUR: f32 = 0.0; const MIN_FALLOFF: f32 = 0.0; const MIN_SCALE: f64 = 0.0; -const MIN_POSITION: f64 = -10.0; +//const MIN_POSITION: f64 = -10.0; const MIN_ROTATION: f64 = -180.0; const MIN_TRANSLATE: f64 = -10.0; //-- const MAX_COLOUR: f32 = 1.0; const MAX_FALLOFF: f32 = 1.0; const MAX_SCALE: f64 = 3.0; -const MAX_POSITION: f64 = 10.0; +//const MAX_POSITION: f64 = 10.0; const MAX_ROTATION: f64 = 180.0; const MAX_TRANSLATE: f64 = 10.0; // CAMERA CONSTANTS const MIN_FOV: f32 = 10.0; const MAX_FOV: f32 = 160.0; -const CAMERA_INIT: f32 = 5.0; +//const CAMERA_INIT: f32 = 5.0; /// Manages all state required for rendering Dear ImGui over `Pixels`test. pub enum GuiEvent { @@ -272,6 +274,8 @@ impl Gui { // Edit transformation of nodes if let Some(_t) = ui.tree_node("Nodes") { for (label, node) in &mut self.scene.nodes { + ui.checkbox(format!("##active{label}"), &mut node.active); + ui.same_line(); if let Some(_t) = ui.tree_node(label) { ui.slider_config("Translation", MIN_TRANSLATE, MAX_TRANSLATE) .build_array(&mut node.translation); @@ -297,6 +301,8 @@ impl Gui { //Edit color, position and falloff of lights if let Some(_t) = ui.tree_node("Lights") { for (label, light) in &mut self.scene.lights { + ui.checkbox(format!("##activelight{label}"), &mut light.active); + ui.same_line(); if let Some(_t) = ui.tree_node(label) { ui.slider_config("Colour", MIN_COLOUR, MAX_COLOUR) .build_array(light.colour.as_mut_slice()); @@ -377,11 +383,13 @@ pub fn init_engine() -> Engine { .register_fn("translate", Node::translate) .register_fn("rotate", Node::rotate) .register_fn("scale", Node::scale) - .register_fn("child", Node::child); + .register_fn("child", Node::child) + .register_fn("active", Node::set_active); engine .register_type::() .register_fn("Light", Light::new) - .register_fn("Ambient", Light::ambient); + .register_fn("Ambient", Light::ambient) + .register_fn("active", Light::set_active); engine .register_type::() .register_fn("Material", Material::new) @@ -398,6 +406,10 @@ pub fn init_engine() -> Engine { .register_type::() .register_fn("Cube", Cube::new) .register_fn("CubeUnit", Cube::unit); + engine + .register_type::() + .register_fn("Triangle", Triangle::new) + .register_fn("TriangleUnit", Triangle::unit); engine .register_type::() .register_fn("Cone", Cone::new) @@ -435,4 +447,11 @@ pub fn init_engine() -> Engine { .register_type::() .register_fn("Gnonom", Gnonom::new); engine + .register_type::() + .register_fn("Mesh", Mesh::from_file); + engine + .register_type::() + .register_fn("Rectange", Rectangle::new) + .register_fn("RectangleUnit", Rectangle::unit); + engine } diff --git a/src/light.rs b/src/light.rs index a2087ab..cece712 100644 --- a/src/light.rs +++ b/src/light.rs @@ -6,6 +6,7 @@ pub struct Light { pub colour: Vector3, pub falloff: Vector3, pub ambient: bool, + pub active: bool, } impl Light { @@ -17,6 +18,7 @@ impl Light { colour, falloff, ambient: false, + active: true, } } pub fn ambient(colour: Vector3) -> Light { @@ -25,6 +27,10 @@ impl Light { colour: colour.cast(), falloff: Vector3::new(0.0, 0.0, 0.0), ambient: true, + active: true, } } + pub fn set_active(&mut self, active: bool) { + self.active = active; + } }