From 35befda2422c70ebe016c72cf4311e550136a796 Mon Sep 17 00:00:00 2001 From: Piotr Siuszko Date: Sun, 12 Sep 2021 00:17:50 +0200 Subject: [PATCH] Map basics --- Cargo.lock | 52 +++++++++++++++ doppler/Cargo.lock | 50 ++++++++++++++ doppler/Cargo.toml | 1 + doppler/src/assets_cache.rs | 24 ++++--- doppler/src/camera.rs | 3 +- doppler/src/components.rs | 1 + doppler/src/lib.rs | 1 + doppler/src/map.rs | 126 ++++++++++++++++++++++++++++++++++++ resources/test_map.yaml | 115 ++++++++++++++++++++++++++++++++ resources/test_objects.txt | 8 +++ src/example_client.rs | 114 ++++++-------------------------- 11 files changed, 391 insertions(+), 104 deletions(-) create mode 100644 doppler/src/map.rs create mode 100644 resources/test_map.yaml create mode 100644 resources/test_objects.txt diff --git a/Cargo.lock b/Cargo.lock index 512c25b..2a822b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "ab_glyph_rasterizer" version = "0.1.4" @@ -322,6 +324,7 @@ dependencies = [ "log", "serde", "serde_json", + "serde_yaml", "simple-logging", "tobj", ] @@ -339,6 +342,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "fnv" version = "1.0.7" @@ -468,6 +477,12 @@ dependencies = [ "gl_generator", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "ident_case" version = "1.0.1" @@ -547,6 +562,16 @@ dependencies = [ "winit", ] +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inline_tweak" version = "1.0.8" @@ -640,6 +665,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "lock_api" version = "0.4.3" @@ -1108,6 +1139,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +dependencies = [ + "dtoa", + "indexmap", + "serde", + "yaml-rust", +] + [[package]] name = "shared_library" version = "0.1.9" @@ -1451,3 +1494,12 @@ name = "xml-rs" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/doppler/Cargo.lock b/doppler/Cargo.lock index 9d11c8f..3a7596e 100644 --- a/doppler/Cargo.lock +++ b/doppler/Cargo.lock @@ -324,6 +324,7 @@ dependencies = [ "log", "serde", "serde_json", + "serde_yaml", "simple-logging", "tobj", ] @@ -334,6 +335,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "dtoa" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56899898ce76aaf4a0f24d914c97ea6ed976d42fec6ad33fcbb0a1103e07b2b0" + [[package]] name = "fnv" version = "1.0.7" @@ -463,6 +470,12 @@ dependencies = [ "gl_generator", ] +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + [[package]] name = "ident_case" version = "1.0.1" @@ -541,6 +554,16 @@ dependencies = [ "winit", ] +[[package]] +name = "indexmap" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] + [[package]] name = "inline_tweak" version = "1.0.8" @@ -634,6 +657,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "linked-hash-map" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" + [[package]] name = "lock_api" version = "0.4.5" @@ -1119,6 +1148,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_yaml" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c608a35705a5d3cdc9fbe403147647ff34b921f8e833e49306df898f9b20af" +dependencies = [ + "dtoa", + "indexmap", + "serde", + "yaml-rust", +] + [[package]] name = "shared_library" version = "0.1.9" @@ -1462,3 +1503,12 @@ name = "xml-rs" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" + +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] diff --git a/doppler/Cargo.toml b/doppler/Cargo.toml index 815f67a..0ece9b6 100644 --- a/doppler/Cargo.toml +++ b/doppler/Cargo.toml @@ -20,6 +20,7 @@ image2 = { git = "https://github.com/Leinnan/image2-rs", branch="legacy", defaul glutin = "0.26.0" serde = { version = "1.0.117", features = ["derive"] } serde_json = "1.0.59" +serde_yaml = "0.8" [features] default = ["imgui_inspect"] diff --git a/doppler/src/assets_cache.rs b/doppler/src/assets_cache.rs index e265645..2f79447 100644 --- a/doppler/src/assets_cache.rs +++ b/doppler/src/assets_cache.rs @@ -31,20 +31,19 @@ impl AssetsCache { for line in lines { let mut splitted = line.split_whitespace(); - let id = splitted.next(); let path = splitted.next(); - if id.is_none() || path.is_none() || self.has_model(&path.unwrap()) { + if path.is_none() || self.has_model(&path.unwrap()) { error!("Skip wrong line: {}", line); continue; } let texture = splitted.next(); self.load_model_ext(path.unwrap(), texture); - info!("Added model {} from path {}", id.unwrap(), path.unwrap()); + info!("Added model from path {}", path.unwrap()); } } pub fn has_model(&self, path: &str) -> bool { - self.models.contains_key(&Self::to_hash(path)) + self.models.contains_key(&Self::path_hash(path)) } pub fn get_model(&mut self, path: &str) -> Model { @@ -52,7 +51,7 @@ impl AssetsCache { } pub fn get_model_ext(&mut self, path: &str, diff_texture: Option<&str>) -> Model { - match self.models.get(&Self::to_hash(path)) { + match self.models.get(&Self::path_hash(path)) { Some(model) => model.clone(), None => { self.load_model_ext(path, diff_texture); @@ -61,15 +60,22 @@ impl AssetsCache { } } + pub fn get_model_by_hash(&mut self, hash: &u64) -> Option { + match self.models.get(hash) { + Some(model) => Some(model.clone()), + None => None + } + } + fn load_model_ext(&mut self, path: &str, diff_texture: Option<&str>) { - let hash = Self::to_hash(path); + let hash = Self::path_hash(path); info!("Loading model: {}({})", path, hash); let model = Model::new_ext(path, diff_texture, self); self.models.insert(hash, model); } pub fn get_material_texture(&mut self, dir: &str, path: &str, type_name: &str) -> Texture { - match self.textures.get(&Self::to_hash(path)) { + match self.textures.get(&Self::path_hash(path)) { Some(texture) => texture.clone(), None => { let directory: String = dir.into(); @@ -78,13 +84,13 @@ impl AssetsCache { type_: type_name.into(), path: path.into(), }; - self.textures.insert(Self::to_hash(path), texture.clone()); + self.textures.insert(Self::path_hash(path), texture.clone()); texture } } } - fn to_hash(path: &str) -> u64 { + pub fn path_hash(path: &str) -> u64 { let mut hasher = DefaultHasher::new(); path.hash(&mut hasher); hasher.finish() diff --git a/doppler/src/camera.rs b/doppler/src/camera.rs index 0287b12..4f61816 100644 --- a/doppler/src/camera.rs +++ b/doppler/src/camera.rs @@ -3,6 +3,7 @@ #[cfg(feature = "imgui_inspect")] use crate::imgui_helper::*; use cgmath; +use serde::{Deserialize, Serialize}; use cgmath::prelude::*; use cgmath::vec3; #[cfg(feature = "imgui_inspect")] @@ -31,7 +32,7 @@ const SPEED: f32 = 0.5; const SENSITIVTY: f32 = 0.1; const ZOOM: f32 = 45.0; -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] #[cfg_attr(feature = "imgui_inspect", derive(Inspect))] pub struct Camera { // Camera Attributes diff --git a/doppler/src/components.rs b/doppler/src/components.rs index 2e10cc5..a90ef29 100644 --- a/doppler/src/components.rs +++ b/doppler/src/components.rs @@ -43,6 +43,7 @@ impl Transform { pub struct ModelComponent { pub model: Model, + pub hash: u64, pub transform: Transform, } diff --git a/doppler/src/lib.rs b/doppler/src/lib.rs index b5bb626..ea4de9c 100644 --- a/doppler/src/lib.rs +++ b/doppler/src/lib.rs @@ -25,3 +25,4 @@ pub mod model; pub mod shader; pub mod sky; pub mod utils; +pub mod map; \ No newline at end of file diff --git a/doppler/src/map.rs b/doppler/src/map.rs new file mode 100644 index 0000000..9f60106 --- /dev/null +++ b/doppler/src/map.rs @@ -0,0 +1,126 @@ +use crate::assets_cache::AssetsCache; +use crate::model::Model; +use crate::components::*; +use crate::shader::Shader; +use crate::sky::Sky; +use crate::light::*; +use crate::consts; +use crate::camera::*; +use serde::{Deserialize, Serialize}; +use crate::math::{perspective, vec3, Deg, Matrix4, Point3}; +use log::{info,error}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct MapObject { + pub model_hash: u64, + pub transform: Transform, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct MapSave { + pub objects: Vec, + pub camera: Camera +} + +impl MapSave { + pub fn save(map: &Map, _path: &str) { + let mut objects = Vec::with_capacity(map.models.len()); + for m in &map.models { + objects.push(MapObject{ + model_hash: m.hash, + transform: m.transform + }); + } + let ms = MapSave { + camera: map.camera.clone(), + objects: objects + }; + match serde_yaml::to_string(&ms) { + Ok(result) => + println!("{}", result), + Err(e) => println!("{:?}", e) + } + } + pub fn load(path: &str, cache: &mut AssetsCache) -> Map { + let mut map = Map::default(); + info!("Loading map from file: {}", path); + + use std::fs; + let savefile = fs::read_to_string(path); + if savefile.is_err() { + error!("Cannot read file {}: {:?}",path, savefile); + return map; + } + + let save : Result = serde_yaml::from_str(&savefile.unwrap()); + + if save.is_err() { + error!("Cannot parse file {}: {:?}",path, save); + return map; + } + + for m in &save.unwrap().objects { + let model = cache.get_model_by_hash(&m.model_hash); + if model.is_none() { + continue; + } + map.models.push(ModelComponent { + transform: m.transform, + hash: m.model_hash, + model: model.unwrap(), + }) + } + info!("Map loaded: {}", path); + + map + } +} + +pub struct Map { + pub models: Vec, + pub camera: Camera, + pub lighting_system: LightingSystem, + pub sky: Sky, +} + +impl Default for Map { + fn default() -> Self { + let sky = unsafe { Sky::new() }; + Map { + models: Vec::new(), + camera: Camera { + position: Point3::new(0.0, 8.0, 13.0), + front: vec3(0.0, -0.4, -1.0), + up: vec3(0.0, 1.0, -0.4), + right: vec3(1.0, 0.0, 0.0), + yaw: -90.0, + pitch: -20.0, + ..Camera::default() + }, + lighting_system: LightingSystem::default(), + sky: sky, + } + } +} + +impl Map { + pub unsafe fn draw(&mut self) { + use crate::math::prelude::*; + // view/projection transformations + let projection: Matrix4 = perspective( + Deg(self.camera.zoom), + consts::SCR_WIDTH as f32 / consts::SCR_HEIGHT as f32, + 0.1, + 1000.0, + ); + let view = self.camera.get_view_matrix(); + let view_pos = self.camera.position.to_vec(); + self.lighting_system + .prepare_for_draw(&projection, &view, &view_pos); + + for model in self.models.iter() { + model.draw(&self.lighting_system.shader); + } + self.sky.draw(view, projection); + } +} \ No newline at end of file diff --git a/resources/test_map.yaml b/resources/test_map.yaml new file mode 100644 index 0000000..e2729bf --- /dev/null +++ b/resources/test_map.yaml @@ -0,0 +1,115 @@ +objects: + - model_hash: 15116225178797259971 + transform: + position: + x: 10.0 + y: 0.0 + z: 26.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 2.5 + - model_hash: 12030087559729388911 + transform: + position: + x: -9.0 + y: 0.0 + z: -15.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 2.5 + - model_hash: 12030087559729388911 + transform: + position: + x: 15.0 + y: 0.0 + z: -7.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 2.5 + - model_hash: 10272171414862311589 + transform: + position: + x: 0.0 + y: 0.0 + z: 0.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 0.56 + - model_hash: 5402531760391502974 + transform: + position: + x: 0.0 + y: 0.0 + z: 0.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 1.0 + - model_hash: 4360533331876312021 + transform: + position: + x: 0.0 + y: 0.0 + z: 0.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 1.0 + - model_hash: 6024833582843300776 + transform: + position: + x: 8.3 + y: 0.0 + z: 3.0 + rotation: + x: 0.0 + y: 120.0 + z: 0.0 + scale: 0.025 + - model_hash: 12474845581084103280 + transform: + position: + x: 0.0 + y: 0.0 + z: 0.0 + rotation: + x: 0.0 + y: 0.0 + z: 0.0 + scale: 1.0 +camera: + position: + x: 0.0 + y: 8.0 + z: 13.0 + front: + x: 0.0 + y: -0.4 + z: -1.0 + up: + x: 0.0 + y: 1.0 + z: -0.4 + right: + x: 1.0 + y: 0.0 + z: 0.0 + worldup: + x: 0.0 + y: 1.0 + z: 0.0 + yaw: -90.0 + pitch: -20.0 + movement_speed: 0.5 + mouse_sensivity: 0.1 + zoom: 45.0 \ No newline at end of file diff --git a/resources/test_objects.txt b/resources/test_objects.txt new file mode 100644 index 0000000..7fde642 --- /dev/null +++ b/resources/test_objects.txt @@ -0,0 +1,8 @@ +resources/objects/ground/ground.obj +resources/objects/robot/robot.obj +resources/objects/grass/grass.obj foliage.png +resources/objects/gaz_tank/gaz_tank.obj +resources/objects/tree/tree_6_d.obj tree_e.png +resources/objects/tree/tree_6_c.obj tree_e.png +resources/objects/tree/tree_6_c.obj tree_e.png +resources/objects/ruins/ruins.obj \ No newline at end of file diff --git a/src/example_client.rs b/src/example_client.rs index d55d45b..6b790ee 100644 --- a/src/example_client.rs +++ b/src/example_client.rs @@ -6,15 +6,13 @@ use doppler::consts; use doppler::glutin::event::{ElementState, VirtualKeyCode}; use doppler::imgui::*; use doppler::light::*; +use doppler::map::*; use doppler::math::prelude::*; use doppler::math::{perspective, vec3, Deg, Matrix4, Point3}; use doppler::sky::Sky; pub struct ExampleClient { - models: Vec, - camera: Camera, - lighting_system: LightingSystem, - sky: Sky, + map: Map, delta: f32, show_object_info: bool, show_camera_info: bool, @@ -25,21 +23,9 @@ pub struct ExampleClient { impl Default for ExampleClient { fn default() -> Self { - let sky = unsafe { Sky::new() }; ExampleClient { delta: 0.0, - models: vec![], - camera: Camera { - position: Point3::new(0.0, 8.0, 13.0), - front: vec3(0.0, -0.4, -1.0), - up: vec3(0.0, 1.0, -0.4), - right: vec3(1.0, 0.0, 0.0), - yaw: -90.0, - pitch: -20.0, - ..Camera::default() - }, - lighting_system: LightingSystem::default(), - sky: sky, + map: Map::default(), object_info_id: 0, show_camera_info: false, show_object_info: false, @@ -53,18 +39,23 @@ impl Client for ExampleClient { fn on_keyboard(&mut self, code: &VirtualKeyCode, state: &ElementState) { match (code, state) { (VirtualKeyCode::W, ElementState::Pressed) => self + .map .camera .process_keyboard(CameraMovement::FORWARD, self.delta), (VirtualKeyCode::S, ElementState::Pressed) => self + .map .camera .process_keyboard(CameraMovement::BACKWARD, self.delta), (VirtualKeyCode::A, ElementState::Pressed) => self + .map .camera .process_keyboard(CameraMovement::LEFT, self.delta), (VirtualKeyCode::D, ElementState::Pressed) => self + .map .camera .process_keyboard(CameraMovement::RIGHT, self.delta), (VirtualKeyCode::LControl, _) => self + .map .camera .enable_mouse_movement(state == &ElementState::Released), (_, _) => (), @@ -72,78 +63,13 @@ impl Client for ExampleClient { } fn load_assets(&mut self, cache: &mut AssetsCache) { - let ground = ModelComponent { - transform: Transform { - scale: 0.56, - ..Transform::default() - }, - model: cache.get_model("resources/objects/ground/ground.obj"), - }; - let robot = ModelComponent { - transform: Transform::default(), - model: cache.get_model("resources/objects/robot/robot.obj"), - }; - let grass = ModelComponent { - transform: Transform::default(), - model: cache.get_model_ext("resources/objects/grass/grass.obj", Some("foliage.png")), - }; - let gaz_tank = ModelComponent { - transform: Transform { - position: vec3(8.3, 0.0, 3.0), - rotation: vec3(0.0, 120.0, 0.0), - scale: 0.025, - ..Transform::default() - }, - model: cache.get_model("resources/objects/gaz_tank/gaz_tank.obj"), - }; - let tree = ModelComponent { - transform: Transform { - position: vec3(10.0, 0.0, 26.0), - scale: 2.5, - ..Transform::default() - }, - model: cache.get_model_ext("resources/objects/tree/tree_6_d.obj", Some("tree_e.png")), - }; - let tree2 = ModelComponent { - transform: Transform { - position: vec3(-9.0, 0.0, -15.0), - scale: 2.5, - ..Transform::default() - }, - model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")), - }; - let tree3 = ModelComponent { - transform: Transform { - position: vec3(15.0, 0.0, -7.0), - scale: 2.5, - ..Transform::default() - }, - model: cache.get_model_ext("resources/objects/tree/tree_6_c.obj", Some("tree_e.png")), - }; - let ruins = ModelComponent { - transform: Transform::default(), - model: cache.get_model("resources/objects/ruins/ruins.obj"), - }; - self.models = vec![tree, tree2, tree3, ground, robot, ruins, gaz_tank, grass]; + cache.load_all_from_file("resources/test_objects.txt"); + self.map = MapSave::load("resources/test_map.yaml", cache); + MapSave::save(&self.map, "test"); } unsafe fn draw(&mut self) { - // view/projection transformations - let projection: Matrix4 = perspective( - Deg(self.camera.zoom), - consts::SCR_WIDTH as f32 / consts::SCR_HEIGHT as f32, - 0.1, - 1000.0, - ); - let view = self.camera.get_view_matrix(); - let view_pos = self.camera.position.to_vec(); - self.lighting_system - .prepare_for_draw(&projection, &view, &view_pos); - - for model in self.models.iter() { - model.draw(&self.lighting_system.shader); - } - self.sky.draw(view, projection); + self.map.draw(); } fn update(&mut self, delta: f32) { self.delta = delta; @@ -191,7 +117,7 @@ impl Client for ExampleClient { ui.text(im_str!("Camera info")); ui.separator(); >::render( - &[&self.camera], + &[&self.map.camera], &"CameraInfo", ui, &imgui_inspect::InspectArgsDefault { @@ -203,7 +129,7 @@ impl Client for ExampleClient { } if self.show_object_info { let mut id = self.object_info_id; - let max: i32 = self.models.len() as i32 - 1; + let max: i32 = self.map.models.len() as i32 - 1; let mut show_window = self.show_object_info; Window::new(im_str!("Object info")) @@ -219,7 +145,7 @@ impl Client for ExampleClient { id }; - let mut selected_mut = vec![&mut self.models[id as usize].transform]; + let mut selected_mut = vec![&mut self.map.models[id as usize].transform]; >::render_mut( &mut selected_mut, "Object info", @@ -232,7 +158,7 @@ impl Client for ExampleClient { } if self.show_light_info { let mut id = self.light_info_id; - let max: i32 = self.lighting_system.point_lights.len() as i32 - 1; + let max: i32 = self.map.lighting_system.point_lights.len() as i32 - 1; let mut show_window = self.show_light_info; Window::new(im_str!("Lights info")) @@ -240,7 +166,7 @@ impl Client for ExampleClient { .opened(&mut show_window) .build(&ui, || { { - let mut selected_mut = vec![&mut self.lighting_system.directional_light]; + let mut selected_mut = vec![&mut self.map.lighting_system.directional_light]; >::render_mut( @@ -256,7 +182,7 @@ impl Client for ExampleClient { id = if id < 0 { 0 } else if id > max { max } else { id }; { let mut selected_mut = - vec![&mut self.lighting_system.point_lights[id as usize]]; + vec![&mut self.map.lighting_system.point_lights[id as usize]]; >::render_mut( &mut selected_mut, "PointLightInfo", @@ -273,9 +199,9 @@ impl Client for ExampleClient { } fn on_mouse_scroll(&mut self, yoffset: f32) { - self.camera.process_mouse_scroll(yoffset as f32); + self.map.camera.process_mouse_scroll(yoffset as f32); } fn on_mouse_move(&mut self, x: f32, y: f32) { - self.camera.process_mouse_movement(x, y, true); + self.map.camera.process_mouse_movement(x, y, true); } }