mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
allow getting prop data from static and dynamic props
This commit is contained in:
parent
89f2f3ba7a
commit
b4e08b6e65
2 changed files with 55 additions and 0 deletions
|
|
@ -1,11 +1,13 @@
|
|||
mod displacement;
|
||||
mod entity;
|
||||
mod game;
|
||||
mod prop;
|
||||
mod vector;
|
||||
|
||||
pub use self::displacement::*;
|
||||
pub use self::entity::*;
|
||||
pub use self::game::*;
|
||||
pub use self::prop::PropPlacement;
|
||||
pub use self::vector::*;
|
||||
use crate::bspfile::LumpType;
|
||||
use crate::{BspResult, StringError};
|
||||
|
|
|
|||
53
src/data/prop.rs
Normal file
53
src/data/prop.rs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
use crate::{Handle, PropDynamic, PropDynamicOverride, StaticPropLump, Vector};
|
||||
use cgmath::{Deg, Quaternion, Rotation3};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PropPlacement<'a> {
|
||||
pub model: &'a str,
|
||||
pub rotation: Quaternion<f32>,
|
||||
pub scale: f32,
|
||||
pub origin: Vector,
|
||||
pub skin: i32,
|
||||
}
|
||||
|
||||
impl<'a> Handle<'a, StaticPropLump> {
|
||||
pub fn as_prop_placement(&self) -> PropPlacement<'a> {
|
||||
PropPlacement {
|
||||
model: self.model(),
|
||||
rotation: self.rotation(),
|
||||
scale: 1.0,
|
||||
origin: self.origin,
|
||||
skin: self.skin,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn rotation(angles: [f32; 3]) -> Quaternion<f32> {
|
||||
Quaternion::from_angle_y(Deg(angles[1]))
|
||||
* Quaternion::from_angle_x(Deg(angles[0]))
|
||||
* Quaternion::from_angle_z(Deg(angles[2]))
|
||||
}
|
||||
|
||||
impl<'a> PropDynamic<'a> {
|
||||
pub fn as_prop_placement(&self) -> PropPlacement<'a> {
|
||||
PropPlacement {
|
||||
model: self.model,
|
||||
rotation: rotation(self.angles),
|
||||
scale: self.scale,
|
||||
origin: self.origin,
|
||||
skin: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PropDynamicOverride<'a> {
|
||||
pub fn as_prop_placement(&self) -> PropPlacement<'a> {
|
||||
PropPlacement {
|
||||
model: self.model,
|
||||
rotation: rotation(self.angles),
|
||||
scale: self.scale,
|
||||
origin: self.origin,
|
||||
skin: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue