From 0d5e6bd9363d5ed5c4f28174819fc0f5fd9aa586 Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 6 Feb 2021 17:27:42 +0100 Subject: Reorganized scene module, and fixed bug in sphere intersect --- src/main.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index c1383ad..c3d11e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use pathtrace::camera::{Camera, Film}; +use pathtrace::camera::{Camera, Film, CameraSettings}; use pathtrace::scene::Scene; use pathtrace::trace::Tracer; use pathtrace::scene::shapes::Sphere; @@ -9,17 +9,19 @@ use pathtrace::sample::UniformSampler; fn main() { let res = Vector2i::new_xy(500, 500); - let cam = Camera::new( - Vector3f::new_xyz(10.0, 0.0, 0.0), - Vector3f::new(0.0), - Vector3f::new_xyz(0.0, 0.1, 0.0), - 90.0, res, - ); + let cam = Camera::new(&CameraSettings { + target: Vector3f::new_xyz(0.0, 0.0, -1.0), + origin: Vector3f::new_xyz(0.0, 0.0, 0.0), + up: Vector3f::new_xyz(0.0, 1.0, 0.0), + fov: 90.0, + screensize: res, + }); let mut scn = Scene::new(); - scn.add_shape( - Box::new(Sphere::new(4.0, Vector3f::new(0.0))), - ); + scn.add_shapes(vec![ + Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0))), + Box::new(Sphere::new(100.0, Vector3f::new_xyz(0.0, -100.5, -1.0))), + ]); let tracer = Tracer::new(); @@ -30,7 +32,7 @@ fn main() { let mut film = Film::new(res); let tile = film.get_tile(&film.frame); - let mut task = RenderTask::new(Box::new(tile), 500); + let mut task = RenderTask::new(Box::new(tile), 10); task.render(&ctx, &mut sampler); film.commit_tile(&task.tile); -- cgit v1.2.3