mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
convert models in obj
This commit is contained in:
parent
0bad24a370
commit
88c6afce95
1 changed files with 36 additions and 27 deletions
|
|
@ -8,25 +8,36 @@ fn main() -> Result<(), MainError> {
|
||||||
let data = std::fs::read(args.next().expect("No demo file provided"))?;
|
let data = std::fs::read(args.next().expect("No demo file provided"))?;
|
||||||
let bsp = vbsp::Bsp::read(&data)?;
|
let bsp = vbsp::Bsp::read(&data)?;
|
||||||
|
|
||||||
|
let exclude_faces = TextureFlags::LIGHT
|
||||||
|
| TextureFlags::SKY2D
|
||||||
|
| TextureFlags::SKY
|
||||||
|
| TextureFlags::WARP
|
||||||
|
| TextureFlags::TRANS
|
||||||
|
| TextureFlags::TRIGGER
|
||||||
|
| TextureFlags::HINT
|
||||||
|
| TextureFlags::SKIP
|
||||||
|
| TextureFlags::NODRAW
|
||||||
|
| TextureFlags::HITBOX;
|
||||||
|
|
||||||
let vertices = bsp
|
let vertices = bsp
|
||||||
.vertices
|
.vertices
|
||||||
.iter()
|
.iter()
|
||||||
.map(|vertex| <[f32; 3]>::from(&vertex.position))
|
.map(|vertex| <[f32; 3]>::from(&vertex.position))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let polygons = bsp
|
let objects = bsp
|
||||||
.original_faces()
|
.models()
|
||||||
|
.next() // only do "worldspawn" for now
|
||||||
|
.into_iter()
|
||||||
|
.map(|model| Group {
|
||||||
|
name: "".to_string(),
|
||||||
|
index: 0,
|
||||||
|
material: None,
|
||||||
|
polys: model
|
||||||
|
.faces()
|
||||||
.filter(|face| {
|
.filter(|face| {
|
||||||
face.texture()
|
face.texture()
|
||||||
.map(|texture| {
|
.map(|texture| !texture.flags.intersects(exclude_faces))
|
||||||
!texture.flags.intersects(
|
|
||||||
TextureFlags::LIGHT
|
|
||||||
| TextureFlags::SKY2D
|
|
||||||
| TextureFlags::SKY
|
|
||||||
| TextureFlags::SKIP
|
|
||||||
| TextureFlags::NODRAW,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
})
|
})
|
||||||
.map(|face| {
|
.map(|face| {
|
||||||
|
|
@ -36,21 +47,19 @@ fn main() -> Result<(), MainError> {
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.collect(),
|
||||||
|
})
|
||||||
|
.map(|group| Object {
|
||||||
|
name: "".to_string(),
|
||||||
|
groups: vec![group],
|
||||||
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let obj_data = ObjData {
|
let obj_data = ObjData {
|
||||||
position: vertices,
|
position: vertices,
|
||||||
texture: Vec::new(),
|
texture: Vec::new(),
|
||||||
normal: Vec::new(),
|
normal: Vec::new(),
|
||||||
objects: vec![Object {
|
objects,
|
||||||
name: "".to_string(),
|
|
||||||
groups: vec![Group {
|
|
||||||
name: "".to_string(),
|
|
||||||
index: 0,
|
|
||||||
material: None,
|
|
||||||
polys: polygons,
|
|
||||||
}],
|
|
||||||
}],
|
|
||||||
material_libs: Vec::new(),
|
material_libs: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue