37 lines
744 B
Rust
37 lines
744 B
Rust
//! `SideTex` type.
|
|
|
|
use crate::{bin::OptU16, err::*};
|
|
use super::pnts;
|
|
|
|
/// Reads a `SideTex` object.
|
|
pub fn read(b: &[u8]) -> ResultS<SideTex>
|
|
{
|
|
read_data! {
|
|
endian: BIG, buf: b, size: 6, start: 0, data {
|
|
let offs = pnts::read_o[0; 4];
|
|
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);
|
|
o.extend(pnts::write_o(v.offs));
|
|
o.extend(&v.tex_id.to_be_bytes());
|
|
o
|
|
}
|
|
|
|
/// The texture of a side segment.
|
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
|
pub struct SideTex {
|
|
pub offs: pnts::Point,
|
|
pub tex_id: OptU16,
|
|
}
|
|
|
|
// EOF
|