diff --git a/rtiow/src/renderer.rs b/rtiow/src/renderer.rs index 9e9188e..7823448 100644 --- a/rtiow/src/renderer.rs +++ b/rtiow/src/renderer.rs @@ -1,6 +1,4 @@ use std::fmt; -use std::io; -use std::io::Write; use std::path::Path; use std::path::PathBuf; use std::str; @@ -24,8 +22,11 @@ use rand::Rng; use crate::camera::Camera; use crate::hitable::Hit; use crate::human; +use crate::material::Lambertian; use crate::ray::Ray; use crate::scenes; +use crate::sphere::Sphere; +use crate::texture::ConstantTexture; use crate::texture::EnvMap; use crate::vec3::Vec3; @@ -186,6 +187,42 @@ pub struct Scene { pub env_map: Option, } +impl Default for Scene { + fn default() -> Scene { + let lookfrom = Vec3::new(20., 20., 20.); + let lookat = Vec3::new(0., 0., 0.); + let dist_to_focus = (lookfrom - lookat).length(); + let aperture = 0.1; + let time_min = 0.; + let time_max = 1.; + let camera = Camera::new( + lookfrom, + lookat, + Vec3::new(0., 1., 0.), + 70., + 1., + aperture, + dist_to_focus, + time_min, + time_max, + ); + Scene { + world: Box::new(Sphere::new( + Vec3::new(0., 0., 0.), + 1.0, + Lambertian::new(ConstantTexture::new([0., 1., 0.])), + )), + camera, + subsamples: 0, + num_threads: None, + width: 0, + height: 0, + global_illumination: false, + env_map: None, + } + } +} + // color will trace ray up to 50 bounces deep accumulating color as it goes. If // global_illumination is true, a default light background color is assumed and will light the // world. If false, it is expected the scene has emissive light sources. diff --git a/rtiow/src/scenes/bench.rs b/rtiow/src/scenes/bench.rs index dcb0b32..e1a6bf7 100644 --- a/rtiow/src/scenes/bench.rs +++ b/rtiow/src/scenes/bench.rs @@ -72,7 +72,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: true, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/book.rs b/rtiow/src/scenes/book.rs index fcd372b..fd2cea0 100644 --- a/rtiow/src/scenes/book.rs +++ b/rtiow/src/scenes/book.rs @@ -56,6 +56,7 @@ pub fn new(opt: &Opt) -> Scene { height: opt.height, global_illumination: true, env_map: Some(EnvMap::new(skybox)), + ..Default::default() } } diff --git a/rtiow/src/scenes/bvh.rs b/rtiow/src/scenes/bvh.rs index ea23381..f99a0a9 100644 --- a/rtiow/src/scenes/bvh.rs +++ b/rtiow/src/scenes/bvh.rs @@ -66,7 +66,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: true, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/cornell_box.rs b/rtiow/src/scenes/cornell_box.rs index cb80974..8ab3136 100644 --- a/rtiow/src/scenes/cornell_box.rs +++ b/rtiow/src/scenes/cornell_box.rs @@ -134,6 +134,6 @@ pub fn new(opt: &Opt) -> Scene { width: opt.width, height: opt.height, global_illumination: false, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/cornell_smoke.rs b/rtiow/src/scenes/cornell_smoke.rs index c9ae2b5..5aeb764 100644 --- a/rtiow/src/scenes/cornell_smoke.rs +++ b/rtiow/src/scenes/cornell_smoke.rs @@ -119,7 +119,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: false, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/final_scene.rs b/rtiow/src/scenes/final_scene.rs index fea2a6e..27f223a 100644 --- a/rtiow/src/scenes/final_scene.rs +++ b/rtiow/src/scenes/final_scene.rs @@ -172,7 +172,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: false, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/mandelbrot.rs b/rtiow/src/scenes/mandelbrot.rs index 9ca3166..30bf0ec 100644 --- a/rtiow/src/scenes/mandelbrot.rs +++ b/rtiow/src/scenes/mandelbrot.rs @@ -152,7 +152,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: false, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/perlin_debug.rs b/rtiow/src/scenes/perlin_debug.rs index 3f9b8cf..9410a99 100644 --- a/rtiow/src/scenes/perlin_debug.rs +++ b/rtiow/src/scenes/perlin_debug.rs @@ -69,6 +69,6 @@ pub fn new(opt: &Opt) -> Scene { width: opt.width, height: opt.height, global_illumination: true, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/test.rs b/rtiow/src/scenes/test.rs index dd13d15..92b7511 100644 --- a/rtiow/src/scenes/test.rs +++ b/rtiow/src/scenes/test.rs @@ -145,7 +145,6 @@ pub fn new(opt: &Opt) -> Scene { num_threads: opt.num_threads, width: opt.width, height: opt.height, - global_illumination: false, - env_map: None, + ..Default::default() } } diff --git a/rtiow/src/scenes/tutorial.rs b/rtiow/src/scenes/tutorial.rs index a693012..80e6021 100644 --- a/rtiow/src/scenes/tutorial.rs +++ b/rtiow/src/scenes/tutorial.rs @@ -74,6 +74,6 @@ pub fn new(opt: &Opt) -> Scene { width: opt.width, height: opt.height, global_illumination: true, - env_map: None, + ..Default::default() } }