forked from StrafesNET/strafe-client
make a bit better
This commit is contained in:
parent
bf1d7cb20f
commit
d8043a9265
@ -1,4 +1,4 @@
|
|||||||
|
const VALVE_SCALE:f32=1.0/16.0;
|
||||||
pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Result<crate::model::IndexedModelInstances,vbsp::BspError>{
|
pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Result<crate::model::IndexedModelInstances,vbsp::BspError>{
|
||||||
let mut s=Vec::new();
|
let mut s=Vec::new();
|
||||||
|
|
||||||
@ -16,13 +16,10 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
|||||||
let vertices: Vec<_> = bsp
|
let vertices: Vec<_> = bsp
|
||||||
.vertices
|
.vertices
|
||||||
.iter()
|
.iter()
|
||||||
.map(|vertex| <[f32; 3]>::from(vertex.position*0.01))
|
.map(|vertex|[vertex.position.x*VALVE_SCALE,vertex.position.z*VALVE_SCALE,vertex.position.y*VALVE_SCALE])
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
println!("num vertices={}",vertices.len());
|
let world_objects=bsp.models().map(|world_model|{
|
||||||
|
|
||||||
for world_model in bsp.models(){
|
|
||||||
|
|
||||||
let world_polygons:Vec<obj::SimplePolygon> = world_model
|
let world_polygons:Vec<obj::SimplePolygon> = world_model
|
||||||
.faces()
|
.faces()
|
||||||
.filter(|face| face.is_visible())
|
.filter(|face| face.is_visible())
|
||||||
@ -34,9 +31,7 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
|||||||
.map(obj::SimplePolygon)
|
.map(obj::SimplePolygon)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
println!("num world_polygons={}",world_polygons.len());
|
obj::Object {
|
||||||
|
|
||||||
let world_object = obj::Object {
|
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
groups: vec![obj::Group {
|
groups: vec![obj::Group {
|
||||||
name: "".to_string(),
|
name: "".to_string(),
|
||||||
@ -44,13 +39,14 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
|||||||
material: None,
|
material: None,
|
||||||
polys: world_polygons,
|
polys: world_polygons,
|
||||||
}],
|
}],
|
||||||
};
|
}
|
||||||
|
}).collect();
|
||||||
|
|
||||||
let obj_data = obj::ObjData {
|
let obj_data = obj::ObjData {
|
||||||
position: vertices.clone(),//TODO: don't clone all vertices lmao
|
position: vertices,
|
||||||
texture: vec![[0.0,0.0]],
|
texture: vec![[0.0,0.0]],
|
||||||
normal: vec![[1.0,0.0,0.0]],
|
normal: vec![[1.0,0.0,0.0]],
|
||||||
objects: vec![world_object],
|
objects: world_objects,
|
||||||
material_libs: Vec::new(),
|
material_libs: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -61,7 +57,6 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
|||||||
}
|
}
|
||||||
|
|
||||||
indexed_models.append(&mut new_indexed_models);
|
indexed_models.append(&mut new_indexed_models);
|
||||||
}
|
|
||||||
|
|
||||||
Ok(crate::model::IndexedModelInstances{
|
Ok(crate::model::IndexedModelInstances{
|
||||||
textures:Vec::new(),
|
textures:Vec::new(),
|
||||||
|
Loading…
Reference in New Issue
Block a user