tweak map loading
This commit is contained in:
parent
79262ce3b4
commit
d16404167b
@ -1,5 +1,3 @@
|
||||
use crate::model::{IndexedModelInstances,ModelInstance};
|
||||
|
||||
use crate::primitives;
|
||||
|
||||
fn class_is_a(class: &str, superclass: &str) -> bool {
|
||||
@ -111,7 +109,7 @@ enum RobloxBasePartDescription{
|
||||
Wedge(RobloxWedgeDescription),
|
||||
CornerWedge(RobloxCornerWedgeDescription),
|
||||
}
|
||||
pub fn generate_indexed_models_roblox(dom:rbx_dom_weak::WeakDom) -> Result<(IndexedModelInstances,glam::Vec3), Box<dyn std::error::Error>>{
|
||||
pub fn generate_indexed_models(dom:rbx_dom_weak::WeakDom) -> crate::model::IndexedModelInstances{
|
||||
//IndexedModelInstances includes textures
|
||||
let mut spawn_point=glam::Vec3::ZERO;
|
||||
|
||||
@ -335,15 +333,16 @@ pub fn generate_indexed_models_roblox(dom:rbx_dom_weak::WeakDom) -> Result<(Inde
|
||||
});
|
||||
model_id
|
||||
};
|
||||
indexed_models[model_id].instances.push(ModelInstance {
|
||||
indexed_models[model_id].instances.push(crate::model::ModelInstance {
|
||||
transform:model_transform,
|
||||
color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((IndexedModelInstances{
|
||||
crate::model::IndexedModelInstances{
|
||||
textures:asset_id_from_texture_id.iter().map(|t|t.to_string()).collect(),
|
||||
models:indexed_models,
|
||||
},spawn_point))
|
||||
spawn_point,
|
||||
}
|
||||
}
|
||||
|
17
src/main.rs
17
src/main.rs
@ -769,6 +769,7 @@ impl framework::Example for GraphicsData {
|
||||
let indexed_model_instances=model::IndexedModelInstances{
|
||||
textures:Vec::new(),
|
||||
models:indexed_models,
|
||||
spawn_point:glam::Vec3::Y*50.0,
|
||||
};
|
||||
graphics.generate_model_physics(&indexed_model_instances);
|
||||
graphics.generate_model_graphics(&device,&queue,indexed_model_instances);
|
||||
@ -795,7 +796,7 @@ impl framework::Example for GraphicsData {
|
||||
//.snf = "SNBF"
|
||||
if let (Ok(()),Ok(()))=(std::io::Read::read_exact(&mut input, &mut first_8),std::io::Seek::rewind(&mut input)){
|
||||
//
|
||||
if let Some(Ok((indexed_model_instances,spawn_point)))={
|
||||
if let Some(indexed_model_instances)={
|
||||
match &first_8[0..4]{
|
||||
b"<rob"=>{
|
||||
match match &first_8[4..8]{
|
||||
@ -803,19 +804,23 @@ impl framework::Example for GraphicsData {
|
||||
b"lox "=>rbx_xml::from_reader(input,rbx_xml::DecodeOptions::default()).map_err(|e|format!("{:?}",e)),
|
||||
other=>Err(format!("Unknown Roblox file type {:?}",other)),
|
||||
}{
|
||||
Ok(dom)=>Some(load_roblox::generate_indexed_models_roblox(dom)),
|
||||
Ok(dom)=>Some(load_roblox::generate_indexed_models(dom)),
|
||||
Err(e)=>{
|
||||
println!("Error loading roblox file:{:?}",e);
|
||||
None
|
||||
},
|
||||
}
|
||||
},
|
||||
//b"VBSP"=>load_valve::generate_indexed_models_valve(input),
|
||||
//b"SNFM"=>sniffer::generate_indexed_models(input),
|
||||
//b"SNFB"=>sniffer::load_bot(input),
|
||||
_=>None,
|
||||
//b"VBSP"=>Some(load_bsp::generate_indexed_models(input)),
|
||||
//b"SNFM"=>Some(sniffer::generate_indexed_models(input)),
|
||||
//b"SNFB"=>Some(sniffer::load_bot(input)),
|
||||
other=>{
|
||||
println!("loser file {:?}",other);
|
||||
None
|
||||
},
|
||||
}
|
||||
}{
|
||||
let spawn_point=indexed_model_instances.spawn_point;
|
||||
//if generate_indexed_models succeeds, clear the previous ones
|
||||
self.models.clear();
|
||||
self.physics.models.clear();
|
||||
|
@ -63,6 +63,7 @@ pub struct IndexedModelInstances{
|
||||
pub textures:Vec<String>,//RenderPattern
|
||||
pub models:Vec<IndexedModel>,
|
||||
//object_index for spawns, triggers etc?
|
||||
pub spawn_point:glam::Vec3,
|
||||
}
|
||||
|
||||
pub fn generate_indexed_model_list_from_obj(data:obj::ObjData,color:[f32;4]) -> Vec<IndexedModel>{
|
||||
|
Loading…
Reference in New Issue
Block a user