1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
use crate::{ get_box_size, parse_float, }; #[derive(Debug, Default, Copy, Clone)] pub struct Bounded { pub x: i32, pub y: i32, pub z: i32, pub width: usize, pub height: usize, pub depth: usize, } impl Bounded { pub fn from_bytes(bytes: Vec<u8>) -> Option<Self> { if bytes.len() > 0 { let mut matrix = [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], ]; let mut index = 0; for i in 0..4 { for j in 0..4 { matrix[i][j] = parse_float(&[ bytes[index], bytes[index+1], bytes[index+2], bytes[index+3] ]); index += 4; } } let x = 0; let y = 0; let z = 0; let (width, height, depth) = get_box_size(&matrix); Some(Bounded { x, y, z, width, height, depth }) } else { None } } }