This commit is contained in:
numzero 2024-04-27 19:59:17 +03:00
parent afc4970023
commit 8a5bce290c

View File

@ -100,7 +100,10 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut f = BufReader::new(f);
load_mesh(&mut f)?
};
let m_view = ypr_to_mat(vec3(135.0 * PI / 180.0, -30.0 * PI / 180.0, 0.0f32));
let window = show_image::create_window("Raytracing", WindowOptions::default())?;
loop {
for phi in 0..360 {
let m_view = ypr_to_mat(vec3((135.0 + phi as f32) * PI / 180.0, -30.0 * PI / 180.0, 0.0f32));
let m_camera = transpose(&m_view);
let img = render(mesh.as_slice(), |off| {
// perspective projection
@ -114,11 +117,10 @@ fn main() -> Result<(), Box<dyn Error>> {
(m_camera * base, m_camera * ray)
});
let window = show_image::create_window("Raytracing", WindowOptions::default())?;
let image = ImageView::new(ImageInfo::rgb8(W as u32, H as u32), img.data());
window.set_image("image", image)?;
window.wait_until_destroyed()?;
Ok(())
}
}
}
fn edge_dist(a: Vec3, b: Vec3, base: Vec3, dir: Vec3) -> f32 {