use roxlap_core::Camera;
use roxlap_formats::{OverlayColor, Rgb, VoxColor};
fn packed_colors() {
let grass = VoxColor::rgb(0x4d, 0x8a, 0x3a);
assert_eq!(grass.0, 0x80_4d_8a_3a); assert_eq!(grass.with_brightness(0xff).0, 0xff_4d_8a_3a);
assert_eq!(Rgb::new(0x8f, 0xbc, 0xd4).0, 0x00_8f_bc_d4);
assert_eq!(OverlayColor::rgba(0xff, 0xd0, 0x40, 0x80).0, 0x80_ff_d0_40);
}
fn cross(a: [f64; 3], b: [f64; 3]) -> [f64; 3] {
[
a[1] * b[2] - a[2] * b[1],
a[2] * b[0] - a[0] * b[2],
a[0] * b[1] - a[1] * b[0],
]
}
fn approx_eq(a: [f64; 3], b: [f64; 3]) -> bool {
a.iter().zip(b).all(|(x, y)| (x - y).abs() < 1e-12)
}
fn main() {
packed_colors();
let cam = Camera::from_yaw_pitch([0.0, 0.0, 128.0], 0.0, 0.4);
assert!(cam.forward[2] > 0.0);
let cam = Camera::from_yaw_pitch([0.0, 0.0, 128.0], 0.6, 0.2);
assert!(approx_eq(cross(cam.right, cam.down), cam.forward));
let trap = Camera::default();
let anti = cross(trap.right, trap.down);
assert!(approx_eq(anti, [0.0, -1.0, 0.0]));
println!("book_conventions: all convention assertions hold");
}