mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 10:44:07 +02:00
fix texture transforms
This commit is contained in:
parent
6b4f553221
commit
160370b5f8
3 changed files with 16 additions and 10 deletions
|
|
@ -172,8 +172,8 @@ impl<const LEN: usize> BinRead for FixedString<LEN> {
|
||||||
|
|
||||||
#[derive(Debug, Clone, BinRead)]
|
#[derive(Debug, Clone, BinRead)]
|
||||||
pub struct TextureInfo {
|
pub struct TextureInfo {
|
||||||
pub texture_scale: [f32; 4],
|
pub texture_transforms_u: [f32; 4],
|
||||||
pub texture_transform: [f32; 4],
|
pub texture_transform_v: [f32; 4],
|
||||||
pub light_map_scale: [f32; 4],
|
pub light_map_scale: [f32; 4],
|
||||||
pub light_map_transform: [f32; 4],
|
pub light_map_transform: [f32; 4],
|
||||||
pub flags: TextureFlags,
|
pub flags: TextureFlags,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use super::Handle;
|
use super::Handle;
|
||||||
use crate::data::*;
|
use crate::data::*;
|
||||||
|
|
||||||
impl Handle<'_, StaticPropLump> {
|
impl<'a> Handle<'a, StaticPropLump> {
|
||||||
pub fn model(&self) -> &str {
|
pub fn model(&self) -> &'a str {
|
||||||
self.bsp.static_props.dict.name[self.prop_type as usize].as_str()
|
self.bsp.static_props.dict.name[self.prop_type as usize].as_str()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,10 @@ impl<'a> Handle<'a, Model> {
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |face| Handle::new(bsp, face))
|
.map(move |face| Handle::new(bsp, face))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn textures(&self) -> impl Iterator<Item = Handle<'_, TextureInfo>> {
|
||||||
|
self.bsp.textures()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Handle<'_, Node> {
|
impl Handle<'_, Node> {
|
||||||
|
|
@ -128,16 +132,18 @@ impl<'a> Handle<'a, TextureInfo> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn u(&self, pos: Vector) -> f32 {
|
pub fn u(&self, pos: Vector) -> f32 {
|
||||||
(self.texture_scale[0] * pos.x
|
(self.texture_transforms_u[0] * pos.x
|
||||||
+ self.texture_scale[1] * pos.y
|
+ self.texture_transforms_u[1] * pos.y
|
||||||
+ self.texture_scale[2] * pos.z)
|
+ self.texture_transforms_u[2] * pos.z
|
||||||
|
+ self.texture_transforms_u[3])
|
||||||
/ self.texture_data().width as f32
|
/ self.texture_data().width as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn v(&self, pos: Vector) -> f32 {
|
pub fn v(&self, pos: Vector) -> f32 {
|
||||||
(self.texture_transform[0] * pos.x
|
(self.texture_transform_v[0] * pos.x
|
||||||
+ self.texture_transform[1] * pos.y
|
+ self.texture_transform_v[1] * pos.y
|
||||||
+ self.texture_transform[2] * pos.z)
|
+ self.texture_transform_v[2] * pos.z
|
||||||
|
+ self.texture_transform_v[3])
|
||||||
/ self.texture_data().height as f32
|
/ self.texture_data().height as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue