source_demo_tool/
engine_types.rs1use std::{io::Read, fmt::Display};
2use crate::parse_tools::parse_f64;
3
4#[derive(Debug, Clone)]
5pub struct Vector3F64 {
6 pub x: f64,
7 pub y: f64,
8 pub z: f64
9}
10
11impl Vector3F64 {
12 pub fn from_readable(mut reader: impl Read) -> Result<Self, &'static str> {
13 let x = parse_f64(&mut reader);
14 let y = parse_f64(&mut reader);
15 let z = parse_f64(&mut reader);
16
17 if x.is_err() || y.is_err() || z.is_err() {
18 return Err("couldn't parse vector")
19 }
20
21 let x = x.unwrap();
22 let y = y.unwrap();
23 let z = z.unwrap();
24
25 Ok(Self { x, y, z })
26 }
27}
28
29impl Display for Vector3F64 {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 f.write_fmt(format_args!("< {:.3}, {:.3}, {:.3} >", self.x, self.y, self.z))
32 }
33}