use bvh::BVH; use camera::Camera; use hitable::Hit; use material::Lambertian; use material::Metal; use moving_sphere::MovingSphere; use renderer::Opt; use renderer::Scene; use sphere::Sphere; use texture::ConstantTexture; use vec3::Vec3; pub fn new(opt: &Opt) -> Scene { let lookfrom = Vec3::new(3., 3., 2.); let lookat = Vec3::new(0., 0., -1.); 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.), 45., opt.width as f32 / opt.height as f32, aperture, dist_to_focus, time_min, time_max, ); let b = BVH::new( vec![ Box::new(Sphere::new( Vec3::new(0., 0., -1.), 0.5, Box::new(Lambertian::new(Box::new(ConstantTexture::new(Vec3::new( 0.1, 0.2, 0.5, ))))), )), Box::new(Sphere::new( Vec3::new(0., -100.5, -1.), 100., Box::new(Lambertian::new(Box::new(ConstantTexture::new(Vec3::new( 0.8, 0.8, 0.8, ))))), )), Box::new(Sphere::new( Vec3::new(1., 0., -1.), 0.5, Box::new(Metal::new(Vec3::new(0.6, 0.6, 0.6), 0.2)), )), Box::new(MovingSphere::new( Vec3::new(-1., 0., -1.25), Vec3::new(-1., 0., -0.75), 0.5, time_min, time_max, Box::new(Lambertian::new(Box::new(ConstantTexture::new(Vec3::new( 0.2, 0.8, 0.2, ))))), )), ], time_min, time_max, ); trace!(target: "bvh", "World {}", b); let world: Box = Box::new(b); Scene { camera, world, subsamples: opt.subsamples, width: opt.width, height: opt.height, global_illumination: true, } }