diff --git a/src/load_roblox.rs b/src/load_roblox.rs index 1fe10e26..d555879e 100644 --- a/src/load_roblox.rs +++ b/src/load_roblox.rs @@ -10,10 +10,8 @@ fn class_is_a(class: &str, superclass: &str) -> bool { } return false } -pub fn get_objects(buf_thing: R, superclass: &str) -> Result, Box> { - // Using buffered I/O is recommended with rbx_binary - let dom = rbx_binary::from_reader(buf_thing)?; +pub fn get_objects(dom:rbx_dom_weak::WeakDom, superclass: &str) -> Result, Box> { let mut objects = std::vec::Vec::::new(); //move matching instances into objects let (_,mut instances) = dom.into_raw(); diff --git a/src/main.rs b/src/main.rs index 4871c2c3..1aaf2d9e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,9 +161,9 @@ impl GraphicsData { depth_texture.create_view(&wgpu::TextureViewDescriptor::default()) } - fn generate_modeldatas_roblox(&self,input:R) -> Vec{ + fn generate_modeldatas_roblox(&self,dom:rbx_dom_weak::WeakDom) -> Vec{ let mut modeldatas=generate_modeldatas(self.handy_unit_cube.clone(),ModelData::COLOR_FLOATS_WHITE); - match load_roblox::get_objects(input, "BasePart") { + match load_roblox::get_objects(dom, "BasePart") { Ok(objects)=>{ for object in objects.iter() { if let ( @@ -830,13 +830,40 @@ impl framework::Example for GraphicsData { println!("opening file: {:?}", &path); //oh boy! let's load the map! if let Ok(file)=std::fs::File::open(path){ - let input = std::io::BufReader::new(file); - let modeldatas=self.generate_modeldatas_roblox(input); - //if generate_modeldatas succeeds, clear the previous ones - self.models.clear(); - self.physics.models.clear(); - self.generate_model_physics(&modeldatas); - self.generate_model_graphics(device,modeldatas); + let mut input = std::io::BufReader::new(file); + let mut first_8=[0u8;8]; + //.rbxm roblox binary = "