Maraiah/maraiah/map/stex.rs

38 lines
744 B
Rust
Raw Normal View History

2019-04-01 00:39:47 -07:00
//! `SideTex` type.
2019-06-13 18:09:07 -07:00
use crate::{bin::OptU16, err::*};
2019-04-01 01:50:05 -07:00
use super::pnts;
2019-04-01 00:39:47 -07:00
/// Reads a `SideTex` object.
pub fn read(b: &[u8]) -> ResultS<SideTex>
{
read_data! {
endian: BIG, buf: b, size: 6, start: 0, data {
2019-04-01 01:50:05 -07:00
let offs = pnts::read_o[0; 4];
2019-04-01 00:39:47 -07:00
let tex_id = OptU16[4];
}
}
Ok(SideTex{offs, tex_id})
}
/// Writes a `SideTex` object.
pub fn write(v: &SideTex) -> Vec<u8>
{
let mut o = Vec::with_capacity(6);
2019-04-01 01:50:05 -07:00
o.extend(pnts::write_o(v.offs));
2019-04-01 00:39:47 -07:00
o.extend(&v.tex_id.to_be_bytes());
o
}
/// The texture of a side segment.
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
2019-06-21 18:34:10 -07:00
#[derive(Clone, Debug, Eq, PartialEq)]
2019-04-01 00:39:47 -07:00
pub struct SideTex
{
2019-04-01 01:50:05 -07:00
pub offs: pnts::Point,
2019-04-01 00:39:47 -07:00
pub tex_id: OptU16,
}
// EOF